Added database
This commit is contained in:
25
discordbot/events/guildMemberAdd.js
Normal file
25
discordbot/events/guildMemberAdd.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const { Events, EmbedBuilder } = require('discord.js');
|
||||
const { client } = require('../index.js');
|
||||
const { Users } = require('../functions/models');
|
||||
|
||||
module.exports = {
|
||||
name: Events.GuildMemberAdd,
|
||||
async execute(member) {
|
||||
const addMemberEmbed = new EmbedBuilder()
|
||||
.setTitle(`${member.user.globalName} has joined!`)
|
||||
.setDescription(`Welcome ${member} to the **Polarcraft** Discord server!`)
|
||||
.setColor(process.env.EMBED_COLOR)
|
||||
.setThumbnail(member.user.avatarURL());
|
||||
|
||||
const channel = client.channels.cache.get(process.env.LOG_CHANNEL_ID);
|
||||
channel.send({ embeds: [addMemberEmbed] });
|
||||
|
||||
try {
|
||||
await Users.create({
|
||||
id: member.user.id,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
},
|
||||
};
|
14
discordbot/events/guildMemberRemove.js
Normal file
14
discordbot/events/guildMemberRemove.js
Normal file
@@ -0,0 +1,14 @@
|
||||
const { Events, EmbedBuilder } = require('discord.js');
|
||||
const { client } = require('../index.js');
|
||||
|
||||
module.exports = {
|
||||
name: Events.GuildMemberRemove,
|
||||
async execute(member) {
|
||||
const removeMemberEmbed = new EmbedBuilder()
|
||||
.setTitle(`${member.user.globalName} has left!`)
|
||||
.setColor(process.env.EMBED_COLOR);
|
||||
|
||||
const channel = client.channels.cache.get(process.env.LOG_CHANNEL_ID);
|
||||
channel.send({ embeds: [removeMemberEmbed] });
|
||||
},
|
||||
};
|
@@ -1,22 +1,22 @@
|
||||
const { Events } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
name: Events.InteractionCreate,
|
||||
async execute(interaction) {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
name: Events.InteractionCreate,
|
||||
async execute(interaction) {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
const command = interaction.client.commands.get(interaction.commandName);
|
||||
const command = interaction.client.commands.get(interaction.commandName);
|
||||
|
||||
if (!command) {
|
||||
console.error(`No command matching ${interaction.commandName} was found.`);
|
||||
return;
|
||||
}
|
||||
if (!command) {
|
||||
console.error(`No command matching ${interaction.commandName} was found.`);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await command.execute(interaction);
|
||||
} catch (error) {
|
||||
console.error(`Error executing ${interaction.commandName}`);
|
||||
console.error(error);
|
||||
}
|
||||
},
|
||||
try {
|
||||
await command.execute(interaction);
|
||||
} catch (error) {
|
||||
console.error(`Error executing ${interaction.commandName}`);
|
||||
console.error(error);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
@@ -1,12 +1,17 @@
|
||||
const { Events } = require('discord.js');
|
||||
const deployCommands = require('../functions/deployCommands');
|
||||
const { Users, Teams, Minecraft } = require('../functions/models');
|
||||
|
||||
module.exports = {
|
||||
name: Events.ClientReady,
|
||||
once: true,
|
||||
execute(client) {
|
||||
console.log(`Ready! Logged in as ${client.user.tag}`);
|
||||
name: Events.ClientReady,
|
||||
once: true,
|
||||
execute(client) {
|
||||
Users.sync();
|
||||
Teams.sync();
|
||||
Minecraft.sync();
|
||||
|
||||
deployCommands();
|
||||
},
|
||||
console.log(`Ready! Logged in as ${client.user.tag}`);
|
||||
|
||||
deployCommands();
|
||||
},
|
||||
};
|
||||
|
Reference in New Issue
Block a user