Kira
Kira

Reputation: 25

I want to get System Messages Channel in discord.js v12

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

Answers (2)

Michael
Michael

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

Syntle
Syntle

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

Related Questions