javascript - 将文本发送到特定 channel 的命令

标签 javascript discord discord.js

我想制作一个命令,将文本发送到我选择的 channel 。
示例:

!command "text"

然后“文本”被发送到我选择的 channel 。

最佳答案

这与 this thread 中的代码相同,我只是修改了一小部分,就像我在评论中告诉你的那样。

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");
});

关于javascript - 将文本发送到特定 channel 的命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51753661/

相关文章:

javascript - 在 Javascript 中查找引号内的字符串

typescript - 如何检查discord.js 中交互的权限

javascript - 单选按钮中的 ng-model 类型更改

javascript - AngularJS Form 和 $scope 不互相更新

javascript - "Warning: react-modal: App element is not defined. Please use ` Modal.setAppElement(el) ` or set ` appElement={el} `"

javascript - 递归:当可能存在多个子路径时,跟踪所有递归路径中的变量

javascript - 票证命令 : DiscordAPIError: Interaction has already been acknowledged

javascript - 如何避免同时发送两个命令?

javascript - Bot 未在 overwritePermissions 上设置权限

javascript - Node.js 异步/Promise 与 JIMP 的解释?