Merge branch 'dev' into 'main'
Added other events with voice state logging See merge request illegitimate/illegitimate-bot!75
This commit is contained in:
@@ -2,8 +2,9 @@
|
|||||||
"color": "#eeaadb",
|
"color": "#eeaadb",
|
||||||
"applicationsChannel": "776705352456470550",
|
"applicationsChannel": "776705352456470550",
|
||||||
"staffApplicationsChannel": "1039258641393520700",
|
"staffApplicationsChannel": "1039258641393520700",
|
||||||
"inactivityLogChannel": "829742524796239882",
|
"inactivityLogChannel": "829742524796239882",
|
||||||
"staffOtherChannel": "1082036748558803104",
|
"staffOtherChannel": "1082036748558803104",
|
||||||
"hypixelGuildID": "5a353a170cf2e529044f2935",
|
"hypixelGuildID": "5a353a170cf2e529044f2935",
|
||||||
"botLogChannel": "1101144489306886226"
|
"onlineLogChannel": "1101144489306886226",
|
||||||
|
"botLogChannel": "1174403585149243472"
|
||||||
}
|
}
|
||||||
|
|||||||
76
events/other/vcJoinLeave.js
Normal file
76
events/other/vcJoinLeave.js
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
const { userMention, channelMention } = require('discord.js')
|
||||||
|
const { botLogChannel, color } = require('../../config/options.json')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'vcJoinLeave',
|
||||||
|
description: 'Logs when a user joins or leaves a voice channel.',
|
||||||
|
type: 'other',
|
||||||
|
event: 'voiceStateUpdate',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param { import('discord.js').VoiceState } oldState
|
||||||
|
* @param { import('discord.js').VoiceState } newState
|
||||||
|
*/
|
||||||
|
|
||||||
|
execute(oldState, newState) {
|
||||||
|
|
||||||
|
const oldChannel = oldState.channel
|
||||||
|
const newChannel = newState.channel
|
||||||
|
const guild = oldState.guild
|
||||||
|
const channel = guild.channels.cache.get(botLogChannel)
|
||||||
|
const embedColor = Number(color.replace('#', '0x'))
|
||||||
|
|
||||||
|
if (oldChannel === null && newChannel !== null) {
|
||||||
|
|
||||||
|
channel.send({
|
||||||
|
embeds: [{
|
||||||
|
title: "Voice Channel Join",
|
||||||
|
description: userMention(oldState.member.id) +
|
||||||
|
" joined " +
|
||||||
|
channelMention(newChannel.id),
|
||||||
|
color: embedColor,
|
||||||
|
footer: {
|
||||||
|
text: "ID: " + oldState.member.id
|
||||||
|
},
|
||||||
|
timestamp: new Date()
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
} else if (oldChannel !== null && newChannel === null) {
|
||||||
|
|
||||||
|
channel.send({
|
||||||
|
embeds: [{
|
||||||
|
title: "Voice Channel Leave",
|
||||||
|
description: userMention(oldState.member.id) +
|
||||||
|
" left " +
|
||||||
|
channelMention(oldChannel.id),
|
||||||
|
color: embedColor,
|
||||||
|
footer: {
|
||||||
|
text: "ID: " + oldState.member.id
|
||||||
|
},
|
||||||
|
timestamp: new Date()
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
} else if (oldChannel !== null && newChannel !== null) {
|
||||||
|
|
||||||
|
channel.send({
|
||||||
|
embeds: [{
|
||||||
|
title: "Voice Channel Switch",
|
||||||
|
description: userMention(oldState.member.id) +
|
||||||
|
" switched from " +
|
||||||
|
channelMention(oldChannel.id) +
|
||||||
|
" to " +
|
||||||
|
channelMention(newChannel.id),
|
||||||
|
color: embedColor,
|
||||||
|
footer: {
|
||||||
|
text: "ID: " + oldState.member.id
|
||||||
|
},
|
||||||
|
timestamp: new Date()
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
const { botLogChannel, color } = require('../../config/options.json');
|
const { onlineLogChannel, color } = require('../../config/options.json');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'sendonlinemessage',
|
name: 'sendonlinemessage',
|
||||||
@@ -7,10 +7,11 @@ module.exports = {
|
|||||||
|
|
||||||
execute(client) {
|
execute(client) {
|
||||||
if (process.env.NODE_ENV !== 'dev') {
|
if (process.env.NODE_ENV !== 'dev') {
|
||||||
const channel = client.channels.cache.get(botLogChannel);
|
const channel = client.channels.cache.get(onlineLogChannel);
|
||||||
const embedColor = Number(color.replace('#', '0x'))
|
const embedColor = Number(color.replace('#', '0x'))
|
||||||
|
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
|
console.log(`[ERROR] Could not find channel used for online message.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
15
index.js
15
index.js
@@ -1,5 +1,14 @@
|
|||||||
const { Client, GatewayIntentBits, Partials, Collection } = require('discord.js');
|
const { Client, GatewayIntentBits, Partials, Collection } = require('discord.js');
|
||||||
const { loadSlashCommands, loadMessageEvents, loadContextMenu, loadModalEvents, loadButtonEvents, loadReadyEvents, loadInteractionEvents } = require('./utils/eventHandler.js')
|
const {
|
||||||
|
loadSlashCommands,
|
||||||
|
loadMessageEvents,
|
||||||
|
loadContextMenu,
|
||||||
|
loadModalEvents,
|
||||||
|
loadButtonEvents,
|
||||||
|
loadReadyEvents,
|
||||||
|
loadInteractionEvents,
|
||||||
|
loadOtherEvents
|
||||||
|
} = require('./utils/eventHandler.js')
|
||||||
const { autoDeployCommands } = require('./utils/autodeploy.js');
|
const { autoDeployCommands } = require('./utils/autodeploy.js');
|
||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
const mongoURI = process.env.MONGOURI;
|
const mongoURI = process.env.MONGOURI;
|
||||||
@@ -20,7 +29,8 @@ const client = new Client({
|
|||||||
GatewayIntentBits.GuildMessages,
|
GatewayIntentBits.GuildMessages,
|
||||||
GatewayIntentBits.GuildMembers,
|
GatewayIntentBits.GuildMembers,
|
||||||
GatewayIntentBits.MessageContent,
|
GatewayIntentBits.MessageContent,
|
||||||
GatewayIntentBits.DirectMessages
|
GatewayIntentBits.DirectMessages,
|
||||||
|
GatewayIntentBits.GuildVoiceStates
|
||||||
],
|
],
|
||||||
partials: [
|
partials: [
|
||||||
Partials.GuildMember,
|
Partials.GuildMember,
|
||||||
@@ -41,6 +51,7 @@ loadModalEvents(client);
|
|||||||
loadMessageEvents(client);
|
loadMessageEvents(client);
|
||||||
loadReadyEvents(client)
|
loadReadyEvents(client)
|
||||||
loadInteractionEvents(client);
|
loadInteractionEvents(client);
|
||||||
|
loadOtherEvents(client);
|
||||||
|
|
||||||
client.login(token);
|
client.login(token);
|
||||||
|
|
||||||
|
|||||||
@@ -5,5 +5,15 @@ const { loadMessageEvents } = require('./eventHandlers/message.js')
|
|||||||
const { loadModalEvents } = require('./eventHandlers/modal.js')
|
const { loadModalEvents } = require('./eventHandlers/modal.js')
|
||||||
const { loadReadyEvents } = require('./eventHandlers/ready.js')
|
const { loadReadyEvents } = require('./eventHandlers/ready.js')
|
||||||
const { loadInteractionEvents } = require('./eventHandlers/interaction.js')
|
const { loadInteractionEvents } = require('./eventHandlers/interaction.js')
|
||||||
|
const { loadOtherEvents } = require('./eventHandlers/other.js')
|
||||||
|
|
||||||
module.exports = { loadSlashCommands, loadButtonEvents, loadContextMenu, loadMessageEvents, loadModalEvents, loadReadyEvents, loadInteractionEvents }
|
module.exports = {
|
||||||
|
loadSlashCommands,
|
||||||
|
loadButtonEvents,
|
||||||
|
loadContextMenu,
|
||||||
|
loadMessageEvents,
|
||||||
|
loadModalEvents,
|
||||||
|
loadReadyEvents,
|
||||||
|
loadInteractionEvents,
|
||||||
|
loadOtherEvents
|
||||||
|
}
|
||||||
|
|||||||
22
utils/eventHandlers/other.js
Normal file
22
utils/eventHandlers/other.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
const path = require('path');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
/** @param { import('discord.js').Client } client */
|
||||||
|
|
||||||
|
function loadOtherEvents(client) {
|
||||||
|
const otherPath = path.join(__dirname, '..', '..', 'events', 'other')
|
||||||
|
const otherFiles = fs.readdirSync(otherPath).filter(file => file.endsWith('.js'));
|
||||||
|
|
||||||
|
for (const file of otherFiles) {
|
||||||
|
const filePath = path.join(otherPath, file);
|
||||||
|
const other = require(filePath);
|
||||||
|
|
||||||
|
if ('name' in other && 'execute' in other && 'event' in other && other.type === 'other') {
|
||||||
|
client.on(other.event, other.execute)
|
||||||
|
} else {
|
||||||
|
console.log(`[WARNING] The other event at ${filePath} is missing a required "name", "execute", "type" or "event" property.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { loadOtherEvents }
|
||||||
Reference in New Issue
Block a user