Reputation: 25
I want to get SystemChannel
. I am using discord.js v12, this is what I have so far:
bot.on('guildMemberAdd', member => {
// I want to get this channel, not by name
[System Messages Channel][1]
const channel = (getDefaultChannel)
if(!channel) return;
channel.send(`hello ${member}!`);
});
Upvotes: 0
Views: 2949
Reputation: 11
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
// Get the "System Messages Channel"
const systemMessagesChannel = client.guilds.cache.first().systemChannel;
// Send a message to the channel
systemMessagesChannel.send('Hello from the bot!');
});
client.login('YOUR_BOT_TOKEN_HERE');
Upvotes: 0
Reputation: 5174
You can get the SystemChannel
by using member.guild.systemChannel
, or member.guild.systemChannelID
in case you want the channel's ID, in your guildMemberAdd
event.
Upvotes: 3