Converted main codebase to typescript
Signed-off-by: Taken <taken@mairimashita.org>
This commit is contained in:
@@ -1,20 +1,16 @@
|
||||
const { userMention, channelMention } = require("discord.js")
|
||||
const { botLogChannel, color } = require("../../../../config/options.json")
|
||||
import { userMention, channelMention, VoiceState, ChannelType } from "discord.js"
|
||||
import { botLogChannel, color } from "../../../../config/options.json"
|
||||
import { Event } from "../../../interfaces"
|
||||
|
||||
module.exports = {
|
||||
const event: Event = {
|
||||
name: "vcJoinLeave",
|
||||
description: "Logs when a user joins or leaves a voice channel.",
|
||||
type: "event",
|
||||
event: "voiceStateUpdate",
|
||||
|
||||
/**
|
||||
* @param { import('discord.js').VoiceState } oldState
|
||||
* @param { import('discord.js').VoiceState } newState
|
||||
*/
|
||||
execute(oldState: VoiceState, newState: VoiceState) {
|
||||
|
||||
execute(oldState, newState) {
|
||||
|
||||
// if (process.env.NODE_ENV === 'dev') return
|
||||
if (process.env.NODE_ENV === 'dev') return
|
||||
|
||||
const guild = oldState.guild
|
||||
const channel = guild.channels.cache.get(botLogChannel)
|
||||
@@ -25,6 +21,11 @@ module.exports = {
|
||||
return
|
||||
}
|
||||
|
||||
if (channel.type !== ChannelType.GuildText) {
|
||||
console.log("[ERROR] The channel used for voice channel join/leave logging is not a text channel.")
|
||||
return
|
||||
}
|
||||
|
||||
const oldChannel = oldState.channel
|
||||
const newChannel = newState.channel
|
||||
|
||||
@@ -33,14 +34,14 @@ module.exports = {
|
||||
channel.send({
|
||||
embeds: [{
|
||||
title: "Voice Channel Join",
|
||||
description: userMention(oldState.member.id) +
|
||||
description: userMention(newState.member!.id) +
|
||||
" joined " +
|
||||
channelMention(newChannel.id),
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "ID: " + oldState.member.id
|
||||
text: "ID: " + newState.member!.id
|
||||
},
|
||||
timestamp: new Date()
|
||||
timestamp: new Date().toISOString()
|
||||
}]
|
||||
})
|
||||
|
||||
@@ -49,14 +50,14 @@ module.exports = {
|
||||
channel.send({
|
||||
embeds: [{
|
||||
title: "Voice Channel Leave",
|
||||
description: userMention(oldState.member.id) +
|
||||
description: userMention(oldState.member!.id) +
|
||||
" left " +
|
||||
channelMention(oldChannel.id),
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "ID: " + oldState.member.id
|
||||
text: "ID: " + oldState.member!.id
|
||||
},
|
||||
timestamp: new Date()
|
||||
timestamp: new Date().toISOString()
|
||||
}]
|
||||
})
|
||||
|
||||
@@ -67,16 +68,16 @@ module.exports = {
|
||||
channel.send({
|
||||
embeds: [{
|
||||
title: "Voice Channel Switch",
|
||||
description: userMention(oldState.member.id) +
|
||||
description: userMention(oldState.member!.id) +
|
||||
" switched from " +
|
||||
channelMention(oldChannel.id) +
|
||||
" to " +
|
||||
channelMention(newChannel.id),
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "ID: " + oldState.member.id
|
||||
text: "ID: " + oldState.member!.id
|
||||
},
|
||||
timestamp: new Date()
|
||||
timestamp: new Date().toISOString()
|
||||
}]
|
||||
})
|
||||
|
||||
@@ -84,3 +85,5 @@ module.exports = {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export = event
|
||||
Reference in New Issue
Block a user