所以我希望我的 discord bot 能够将消息发送到某个频道,这样它就可以接收报告并回复它们,所以如果我这样做了 ;report {message} 它会将消息放在某个频道或 dm 中
答案 0 :(得分:1)
所以首先它非常简单,我将向您展示我的完整代码和语法
const channel = client.channels.cache.get('CHANNEL ID HERE')
channel.send('MESSAGE OR VARIABLE')
虽然为了运行这个你需要导入discord js,所以我现在将向你展示我的完整机器人
const Discord = require('discord.js');
const client = new Discord.Client();
client.on("disconnected", function () {
// alert the console
console.log("Disconnected!");
// exit node.js with an error
process.exit(1);
});
client.on('ready', async () => {
console.log('Bot is ready');
client.user.setActivity('Blood Samurai', { type: 'STREAMING', url: 'https://www.youtube.com/watch?v=hOyfFPwas_A&t=324s' });
})
/** Direct Message Command */
client.on('message', msg => { // Message function
if (msg.author.bot) return; // Ignore all bots
//Report Command
if (msg.content.startsWith(";report ")) { // When a player does '!report'
if (msg.content.slice(8) === '') return
const help = msg.content.slice(8)
const url = msg.author.avatarURL
const exampleEmbed = new Discord.MessageEmbed()
.setColor('#de0000')
.setTitle('Oktan`s Report System')
.setDescription('```lua\n--[TYPE]--\nServer reports\n--[DESCRIPTION]--\nServer reports deal with Moderation, request and assistance.\n--[SENDER]--\n' +msg.author.tag+ '\n--[REPORT INFORMATION]--\n' + help + '```')
.setFooter('Please report random and usless reports to an admin -Server Staff Team','https://www.pinclipart.com/picdir/middle/74-746204_open-disclaimer-png-clipart.png',)
const channel = client.channels.cache.get('ID HERE')
channel.send(exampleEmbed);
msg.channel.send('Your message will be moderated soon.')
}
});
client.login('TOKEN HERE')
这将允许您使用报告命令将此命令修改为您想要的任何内容,并将其修改为您希望的内容。