我将如何创建Discord嵌入,但类似这样: 显示作者姓名 显示标题 嵌入的“说明”是用户在前缀;; ruling
之后的消息中键入的内容答案 0 :(得分:0)
这是您想要的工作版本
用法:;;ruling send-embed "My Title" "And my description"
const Discord = require('discord.js');
const bot = new Discord.Client();
bot.on('error' => console.log);
bot.on('message', message => {
let prefix = ';;ruling';
let sender = message.author;
let msg = message.content;
let cont = msg.split(' ');
let args = cont.slice(1);
let cmd = msg.startsWith(prefix) ? cont[0].slice(prefix.length).toUpperCase() : undefined;
if (cmd === 'SEND-EMBED' || cmd === 'SENDEMBED') {
if (!args[0]) {
message.channel.send('Please specify your message');
return;
}
let tokens = [].concat.apply([], args.join(' ').split('"').map(function(v,i){
return i%2 ? v : v.split(' ')
})).filter(Boolean);
message.channel.send({embed:{
author:{
name: sender.username,
icon_url: sender.avatarURL,
},
title: tokens[0],
description: tokens[1],
color: 0x2ff37a
}});
}
});
bot.login(token);