How To Send A Message To A Different Server | Discord Bot
I am very curious because I have seen other bots do this, the food bot command would be: '!Order' and then it would send another embed to a different server and a specific channel.
Solution 1:
You can get a guild and then get a channel from the guild.
client.guilds.get(<guildid>).channels.get(<channelid>).send(<message>)
Notice this requires the bot to be in both guilds
Solution 2:
Saddy's answer is not wrong but it only works on discord.js v11.
To use the same function on v12 you need to add "cache".
bot.guilds.cache.get('<GUILDID>').channels.cache.get('<MESSAGEID>').send('<MESSAGE>');
I recommend you to read this short article to know all the changes from v11 to v12.
https://v12.discordjs.guide/additional-info/changes-in-v12.html
Also, there is already a v13 version coming out, be aware!
Post a Comment for "How To Send A Message To A Different Server | Discord Bot"