【发布时间】:2020-04-22 02:04:32
【问题描述】:
我正在尝试在您键入时发出命令,例如 z!snipe
它向您显示最后删除的消息,作者在顶部,消息在中间。
但它不起作用。 youtube 上没有太多关于如何做到这一点的教程。
我设法找到了一个,但它不起作用。问题是:
TypeError: Cannot read property 'get' of undefined
我的代码是:
const { Discord, RichEmbed } = require("discord.js");
module.exports ={
name: "snipe",
category: "info",
description: "Shows the most recent deleted message.",
usage: "z!snipe",
run: async(client, message, args) => {
const msg = client.snipes.get(message.channel.id);
if(!msg) return message.reply("There are no recently deleted messages!");
const embed = new RichEmbed()
.setAuthor(`Deleted by ${msg.author.tag}`, msg.author.displayAvatarURL())
.setDescription(msg.content);
}
}
教程中的那个人没有说明他是如何得到那个狙击手的。所以它对我不起作用。 我不知道还要在那里添加什么,所以基本上我处于死胡同。
【问题讨论】:
-
它告诉你
client.snipes是未定义的。它不是客户端对象的标准部分。你创造了这个吗?如果是,你确定那部分代码被执行了吗? -
我没有创建这个.. 是的,正如我所说,没有 client.snipes 之类的东西.. 这家伙没有展示他是如何做到的.. 所以他实际上展示了一个最终在死胡同..我不知道在这个客户端中添加什么.snipes..我不知道该怎么做..
标签: discord discord.js