使用discord bot向特定频道发送消息



我正在研究如何向特定通道发送消息。我看到一些人使用client.channels.cache.get('channelidhere').send('text')然而,整件事对我来说是个错误。这是我的全部代码。为一个朋友开发一个售票机器人并没有什么疯狂的。

import { ICommand } from "wokcommands";
export default {
category: 'Utility',
description: 'Makes a support ticket.',
slash: false,
testOnly: true,
callback: async({ message, args, client, guild, member }) => {
let number = 0
let timeout = 200
const channel = await message.guild?.channels.create('Ticket', {
permissionOverwrites: [
{
id: message.author,
allow: ['VIEW_CHANNEL', 'READ_MESSAGE_HISTORY'],
}
],
})
channel?.setParent('956314466201514064')
console.log(channel?.id)
let setID = channel?.id

client.channels.cache.get('956314466201514064').send('')




}
} as ICommand```

对于仍在这里寻找答案的人来说,它是。

对于常规消息,做

message.guild.channels.cache.get('channel-id').send('message')

对于交互,

interaction.guild.channels.cache.get('channel-id').send('message')

最新更新