Command to send text to a specific channel

孤街醉人 提交于 2019-12-11 04:51:49

问题


I want to make a command that sends the text to a channel of my choosing.
Example:

!command "text"

Then the "text" is sent to the channel I chose.


回答1:


That's the same code from this thread, I just modified a little part as I told you in the comments.

client.on('message', msg => {
  if (msg.guild && msg.content.startsWith('/log')) {
    let text = msg.content.slice('/log'.length); // cuts off the /log part
    let channel = msg.guild.channels.find('name', 'channel_name_here');
    if (channel) channel.send(text);
    else msg.reply("Can't find channel");
});


来源:https://stackoverflow.com/questions/51753661/command-to-send-text-to-a-specific-channel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!