// Require the necessary discord.js classes
const { token } = require('./config.json');
// Create a new client instance
const Discord = require('discord.js');
const settings = require('./config.json');
const { Client, GatewayIntentBits, Partials } = require('discord.js');
const client = new Client({
intents: [
GatewayIntentBits.DirectMessages,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.Guilds,
GatewayIntentBits.MessageContent,
GatewayIntentBits.DirectMessageTyping,
],
partials: [Partials.Channel],
});
client.on('ready', () => {
console.log("- Bot logged in -");
});
client.on('guildMemberUpdate', (oldMember, newMember) => {
const oldRoles = oldMember.roles.cache,
newRoles = newMember.roles.cache;
// Has Role?
const oldHas = oldRoles.has('1093515437792305222'),
newHas = newRoles.has('1093515437792305222');
// Check if removed
if (!oldHas && newHas) {
newMember.user.send("Please enter your nickname")
}
});
client.on('messageCreate', async (message) => {
console.log(message.channel.type)
if (message.channel.type == 1) {
console.log("dm recieved")
const guild = client.guilds.cache.get('975539628855660575')
console.log(guild.members.fetch(message.author.id))
//if guild.members.fetch(author.id).roles.cache.has('1093515437792305222'))
//console.log("dm'd with role")
}
}
});
client.login(settings.token);
// start
// Require the necessary discord.js classes
const { token } = require('./config.json');
// Create a new client instance
const Discord = require('discord.js');
const settings = require('./config.json');
const { Client, GatewayIntentBits, Partials } = require('discord.js');
const client = new Client({
intents: [
GatewayIntentBits.DirectMessages,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.Guilds,
GatewayIntentBits.MessageContent,
GatewayIntentBits.DirectMessageTyping,
],
partials: [Partials.Channel],
});
client.on('ready', () => {
console.log("- Bot logged in -");
});
client.on('guildMemberUpdate', (oldMember, newMember) => {
const oldRoles = oldMember.roles.cache,
newRoles = newMember.roles.cache;
// Has Role?
const oldHas = oldRoles.has('1093515437792305222'),
newHas = newRoles.has('1093515437792305222');
// Check if removed
if (!oldHas && newHas) {
newMember.user.send("Please enter your nickname")
}
});
client.on('messageCreate', async (message) => {
console.log(message.channel.type)
if (message.channel.type == 1) {
console.log("dm recieved")
const guild = client.guilds.cache.get('975539628855660575')
console.log(guild.members.fetch(message.author.id))
//if guild.members.fetch(author.id).roles.cache.has('1093515437792305222'))
//console.log("dm'd with role")
}
}
});
client.login(settings.token);
// start