Added alot of functions
This commit is contained in:
@@ -12,13 +12,14 @@ module.exports = {
|
||||
.setThumbnail(member.user.avatarURL());
|
||||
|
||||
const channel = client.channels.cache.get(process.env.LOG_CHANNEL_ID);
|
||||
channel.send({ embeds: [addMemberEmbed] });
|
||||
await channel.send({ embeds: [addMemberEmbed] });
|
||||
|
||||
try {
|
||||
await Users.create({
|
||||
id: member.user.id,
|
||||
});
|
||||
} catch (error) {
|
||||
if (error.name === 'SequelizeUniqueConstraintError') return;
|
||||
console.error(error);
|
||||
}
|
||||
},
|
||||
|
@@ -3,20 +3,21 @@ const { Events } = require('discord.js');
|
||||
module.exports = {
|
||||
name: Events.InteractionCreate,
|
||||
async execute(interaction) {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
if (interaction.isChatInputCommand() || interaction.isUserContextMenuCommand()) {
|
||||
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);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
35
discordbot/events/messageCreate.js
Normal file
35
discordbot/events/messageCreate.js
Normal file
@@ -0,0 +1,35 @@
|
||||
const { Events } = require('discord.js');
|
||||
const { Users } = require('../functions/models.js');
|
||||
|
||||
module.exports = {
|
||||
name: Events.MessageCreate,
|
||||
async execute(message) {
|
||||
if (message.channelId === process.env.MINECRAFT_CHANNEL_ID && !message.author.bot) {
|
||||
try {
|
||||
const user = await Users.findOne({ where: { id: message.author.id } });
|
||||
|
||||
if (!user) return;
|
||||
|
||||
const team = await user.getTeam();
|
||||
|
||||
let tellraw;
|
||||
|
||||
if (!team) {
|
||||
tellraw = `tellraw @a ["",{"text":"DC","color":"gray"},{"text":" ${user.rawUsername} > ${message.content}"}]`;
|
||||
} else {
|
||||
tellraw = `tellraw @a ["",{"text":"DC ","color":"dark_gray"},{"text":"[","color":"gray"},{"text":"${team.name}","color":"${team.color}"},{"text":"]","color":"gray"},{"text":" ${user.rawUsername} "},{"text":"> ${message.content}"}]`;
|
||||
}
|
||||
|
||||
await fetch(process.env.MINECRAFT_HOST + '/console', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'content-type': 'text/plain',
|
||||
},
|
||||
body: tellraw,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
@@ -1,13 +1,13 @@
|
||||
const { Events } = require('discord.js');
|
||||
const deployCommands = require('../functions/deployCommands');
|
||||
const { Users, Teams, Minecraft } = require('../functions/models');
|
||||
const { Users, Team, Minecraft } = require('../functions/models');
|
||||
|
||||
module.exports = {
|
||||
name: Events.ClientReady,
|
||||
once: true,
|
||||
execute(client) {
|
||||
Users.sync();
|
||||
Teams.sync();
|
||||
Team.sync();
|
||||
Minecraft.sync();
|
||||
|
||||
console.log(`Ready! Logged in as ${client.user.tag}`);
|
||||
|
Reference in New Issue
Block a user