[英]How to fix Discord API: Unknown Message error?
I'm trying to make a meme command but whenever I try to use it I get this error "DiscordAPIError: Unknown Message".我正在尝试创建一个 meme 命令,但是每当我尝试使用它时,我都会收到此错误“DiscordAPIError:未知消息”。
This was working earlier but when I came back to my PC it started glitching out.这在早些时候工作,但当我回到我的电脑时,它开始出现故障。
Here's my code这是我的代码
const { RichEmbed } = require("discord.js");
const randomPuppy = require("random-puppy");
const usedCommandRecently = new Set();
module.exports = {
name: "meme",
aliases: ["memes", "reddit"],
category: "fun",
description: "Sends a random meme",
run: async (client, message, args) => {
if (message.deletable) message.delete();
var Channel = message.channel.name
//Check it's in the right channel
if(Channel != "memes") {
const channelembed = new RichEmbed()
.setColor("BLUE")
.setTitle(`Use me in #memes`)
.setDescription(`Sorry ${message.author.username} this command is only usable in #memes !`)
return message.channel.send(channelembed);
}
//Check cooldown
if(usedCommandRecently.has(message.author.id)){
const cooldownembed = new RichEmbed()
.setColor("GREEN")
.setTitle("Slow it down, pal")
.setDescription(`Sorry ${message.author.username} this command has a 30 second cooldown per member, sorry for any inconvenice this may cause`)
message.channel.send(cooldownembed)
} else{
//Post meme
const subReddits = ["dankmeme", "meme", "me_irl"];
const random = subReddits[Math.floor(Math.random() * subReddits.length)];
const img = await randomPuppy(random);
const embed = new RichEmbed()
.setColor("RANDOM")
.setImage(img)
.setTitle(`From /r/${random}`)
.setURL(`https://reddit.com/r/${random}`);
message.channel.send(embed);
}
}
}
Im not sure, but maybe problem in your require block.我不确定,但也许你的 require 块有问题。
const { RichEmbed } = require("discord.js");
the right way its:正确的方法是:
const Discord = require("discord.js");
let cooldownembed = new Discord.RichEmbed();
and why you use return here以及为什么在这里使用return
return message.channel.send(channelembed);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.