Skip to content

Commit

Permalink
Join and leave messages
Browse files Browse the repository at this point in the history
  • Loading branch information
BluDood committed Nov 3, 2022
1 parent 8dd87f6 commit 237a945
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
12 changes: 12 additions & 0 deletions events/guildMemberAdd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const { Events } = require('discord.js')
const config = require('../utils/config')

module.exports = {
event: Events.GuildMemberAdd,
async listener(event) {
if (!config.get().channels.welcome) return
const channel = await event.guild.channels.fetch(config.get().channels.welcome)
if (!channel) return
channel.send(`Hi <@${event.user.id}>, welcome to ${event.guild.name}!`)
}
}
12 changes: 12 additions & 0 deletions events/guildMemberRemove.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const { Events } = require('discord.js')
const config = require('../utils/config')

module.exports = {
event: Events.GuildMemberRemove,
async listener(event) {
if (!config.get().channels.welcome) return
const channel = await event.guild.channels.fetch(config.get().channels.welcome)
if (!channel) return
channel.send(`Goodbye <@${event.user.id}> 👋`)
}
}
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { token } = config.get()
if (!fs.existsSync('./databases')) fs.mkdirSync('./databases')

const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMessageReactions]
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMessageReactions, GatewayIntentBits.GuildMembers]
})

client.commands = new Collection()
Expand Down
10 changes: 7 additions & 3 deletions utils/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const current = {
},
modRoles: [],
channels: {
logs: null
logs: null,
welcome: null
}
}

Expand Down Expand Up @@ -53,14 +54,17 @@ function readline() {
current.customization.colors.bad = await readline()
}
console.log((customColors === 'y' ? '' : "Alright, i'll use the default colors. ") + 'Now, time to set up your moderation roles. Enter all your moderation role IDs here, separated by a comma.')
current.modRoles = (await readline()).split(',').map(r => parseInt(r.trim()))
current.modRoles = (await readline()).split(',').map(r => r.trim())
console.log("Got that. Now enter the channel you'd like me to send logs to:")
current.channels.logs = parseInt((await readline()).trim())
current.channels.logs = (await readline()).trim()
console.log("Now enter the channel you'd like me to send welcome message to. Leave blank to disable.")
current.channels.welcome = (await readline()).trim()
console.log(`
Guild ID: ${current.guildId}
Bot token: ${current.token}
Moderator Roles: ${current.modRoles.join(', ')}
Logging channel: ${current.channels.logs}
Welcome channel: ${current.channels.welcome}
Does this look correct? [Y/n]
`)
const correct = (await readline()).toLowerCase()
Expand Down

0 comments on commit 237a945

Please sign in to comment.