如何解决Disord Bot自动发送消息
所以这是我第一次使用DiscordJS(或一般编码)进行编码,我需要一些帮助以使bot自动在特定频道中发送消息。请给我一些帮助吗?谢谢!
这是我的代码:
const Discord = require("discord.js");
const client = new Discord.Client();
client.once("ready",() => {
console.log("LemonBot is online!");
});
const express = require("express");
const app = express();
const guildId = "739855462274695188";
const channelId = "739875350594584707";
const message = "!d bump"
client.login(my discord bot token)
解决方法
const Discord = require("discord.js");
const client = new Discord.Client();
client.on("ready",() => {
console.log(`${client.user.tag} is online!`);
// Getting the channel from client.channels Collection.
const Channel = client.channels.cache.get("739875350594584707");
// Checking if the channel exists.
if (!Channel) return console.error("Couldn't find the channel.");
// Sending "!d bump" to the channel.
Channel.send("!d bump").catch(e => console.log(e));
});
client.login(process.env.DISORD_AUTH_TOKEN)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。