【发布时间】:2023-04-05 20:00:01
【问题描述】:
我的想法是让机器人根据命令后的文本更改语音通道名称。例如,命令=changename p 会将人声通道名称更改为"???? Pepper"。但是,我无法让机器人执行此操作。
这是唯一对我有用的代码:
client.on('message', message =>
{
if (message.channel.id === '748181582241857657')
{
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
const channel = '843111736898617384'
//The ID of the vocal channel I want to change name
const name = message.content.replace('=changename ','')
if (command === 'changename')
{
if (name === 'p')
message.channel.setName('???? Pepper')
}
}
});
但是,这会更改写入消息的频道名称,而不是我想要的频道名称。除此之外的一切都让机器人崩溃了,所以我真的不知道。有什么想法吗?
【问题讨论】:
标签: javascript node.js discord.js bots