我想发送一个消息到每个频道/频道ID从每个公会是在我的数据库这里是我尝试和谢谢!
const { SlashCommandBuilder, PermissionFlagsBits, Client,} = require("discord.js");
const db = require("../../Structures/models/guild");
const mongoose = require("mongoose");
module.exports = {
data: new SlashCommandBuilder()
.setName("post")
.setDescription("Post Something")
.setDefaultMemberPermissions(PermissionFlagsBits.SendMessages),
async execute(interaction, client) {
const channelids = mongoose.get(`channelID_${interaction.guild.id}`);
channelids.forEach(async (id) => {
try {
const channel = await client.channels.fetch(id);
channel.send('Something');
} catch (error) {
console.log(error);
}
});
await interaction.reply({content: 'Brwww'})
},
};
错误
C:\用户\maako\OneDrive\文档\DiscordJS\Bumps\节点模块\mongoose\库\索引.js:223
抛出新错误(\
${key}“'是无效选项。”');
错误:channelID_1032246238126542950
是无效的选项。
1条答案
按热度按时间bttbmeg01#
试试看:
您将执行channelid的for const channelid,以便它将所有id分隔为1,然后您将执行channelid的cache.get,一旦获得它,它将在该通道中发送一条消息。