在say命令中添加Author



我想在命令中添加消息的作者say。类似的事情:你好世界-@作者我试着独自完成这项工作,但我失败了,我希望你能帮助我。(我真的不明白为什么它不起作用,我试图改变很多,但它仍然给了我没有作者的信息

我的当前代码:

const Command = require('../structures/command.js');
const SubCommand = require('../structures/subcommand.js');
module.exports = class Say extends Command {
constructor(client) {
super(client);
this.name = "say";
this.subcommands = [new EmbedSay(client, this)];
}
run(message, args, commandLang, databases, lang) {
if (message.member.hasPermission('ADMINISTRATOR')) {
message.channel.send(args.join(' '));
message.delete();
} else {
var embed = this.client.getg1cuEmbed(message);
embed.setDescription(lang.missing_manageguild_permission);
embed.setColor(this.client.config.colors.error);
message.channel.send(embed);
}
}
}
class EmbedSay extends SubCommand {
constructor(client, parentCommand) {
super(client, parentCommand);
this.name    = "embed";
this.aliases = ["--embed"];
}
run(message, args, commandLang, databases, lang) {
if (message.member.hasPermission('ADMINISTRATOR')) {
try {
var json = JSON.parse(args.join(' '));
} catch (e) {
var embed = this.client.getg1cuEmbed(message);
embed.setColor(this.client.config.colors.error);
embed.setTitle(commandLang.json_error_title);
embed.setDescription(commandLang.json_error_desc);
message.channel.send(embed);
return;

}
message.delete();
if (json.content) {
message.channel.send(json.content, json);
} else {
message.channel.send(json);
}
} else {
var embed = this.client.getg1cuEmbed(message);
embed.setDescription(lang.missing_manageguild_permission);
embed.setColor(this.client.config.colors.error);
message.channel.send(embed);
}
}
}

要获得discord.js中消息的作者,只需:
获得ID:message.author.id
获取标签:message.author.tag
要获得url:message.author'<@!' + message.author.id + '>'

我不是discord.js的粉丝,但我知道一件事,user.mention总是有效的,它提到了输入命令的用户。CCD_ 6也能起作用。

如果这不起作用,那么我很抱歉让你偏离正轨,但也许这会有所帮助:https://discord.js.org/#/docs/main/stable/general/welcome

最新更新