Merge branch 'dev' into 'main'

Dev

See merge request illegitimate/illegitimate-bot!271
This commit is contained in:
2024-08-26 20:31:48 +00:00
9 changed files with 36 additions and 97 deletions

View File

@@ -1,13 +1,13 @@
import { REST, Routes } from "discord.js"
import env from "../src/utils/Env"
const rest = new REST({ version: "10" }).setToken(env.dev.devtoken!)
const rest = new REST({ version: "10" }).setToken(env.dev.devtoken)
async function deleteCommands() {
try {
console.log("Started deleting application (/) commands.")
await rest.put(
Routes.applicationGuildCommands(env.dev.devid!, env.dev.guildid!),
Routes.applicationGuildCommands(env.dev.devid, env.dev.guildid),
{ body: [] },
)
console.log("Successfully deleted application (/) commands.")
@@ -15,4 +15,4 @@ async function deleteCommands() {
console.error(error)
}
}
deleteCommands()
deleteCommands()

View File

@@ -3,7 +3,7 @@ import fs from "node:fs"
import { ICommand } from "../src/interfaces"
import env from "../src/utils/Env"
import color from "../src/utils/functions/colors"
const rest = new REST({ version: "10" }).setToken(env.prod.token!)
const rest = new REST({ version: "10" }).setToken(env.prod.token)
const commands: RESTPutAPIApplicationCommandsJSONBody = []
const commandFiles = fs.readdirSync("./src/commands").filter(file => file.endsWith(".ts"))
@@ -26,7 +26,7 @@ for (const file of contentMenuCommands) {
console.log(color(commandsString.join("\n"), "lavender"))
await rest.put(
Routes.applicationCommands(env.dev.clientid!),
Routes.applicationCommands(env.dev.clientid),
{ body: commands },
).then(() => {
console.log(color(`Successfully reloaded ${commands.length} application (/) commands.`, "green"))
@@ -36,4 +36,4 @@ for (const file of contentMenuCommands) {
} catch (error) {
console.error(error)
}
})()
})()

View File

@@ -2,7 +2,7 @@ import { REST, RESTPutAPIApplicationCommandsJSONBody, Routes } from "discord.js"
import fs from "fs"
import env from "../src/utils/Env"
import { ICommand } from "../src/interfaces"
const rest = new REST({ version: "10" }).setToken(env.dev.devtoken!)
const rest = new REST({ version: "10" }).setToken(env.dev.devtoken)
const commands: RESTPutAPIApplicationCommandsJSONBody = []
const commandFiles = fs.readdirSync("./src/commands/").filter(file => file.endsWith(".ts"))
@@ -26,7 +26,7 @@ for (const file of contentMenuCommands) {
console.log(`Started refreshing ${commands.length} application (/) commands.`)
await rest.put(
Routes.applicationGuildCommands(env.dev.devid!, env.dev.guildid!),
Routes.applicationGuildCommands(env.dev.devid, env.dev.guildid),
{ body: commands },
).then(() => {
console.log(`Successfully reloaded ${commands.length} application (/) commands.`)
@@ -35,4 +35,4 @@ for (const file of contentMenuCommands) {
} catch (error) {
console.error(error)
}
})()
})()

View File

@@ -1,61 +0,0 @@
import { userMention, channelMention, VoiceState } from "discord.js"
import { embedColor } from "config/options.js"
import { IEvent } from "interfaces"
import logToChannel from "utils/functions/logtochannel.js"
export default {
name: "vcJoinLeave",
description: "Logs when a user joins or leaves a voice channel.",
event: "voiceStateUpdate",
execute(oldState: VoiceState, newState: VoiceState) {
if (process.env.NODE_ENV === "dev") return
const oldChannel = oldState.channel
const newChannel = newState.channel
if (oldChannel === null && newChannel !== null) {
logToChannel("bot", {
embeds: [{
title: "Voice Channel Join",
description: userMention(newState.member!.id) + " joined " + channelMention(newChannel.id),
color: embedColor,
footer: {
text: "ID: " + newState.member!.id,
icon_url: newState.member!.user.avatarURL() || undefined
},
timestamp: new Date().toISOString()
}]
})
} else if (oldChannel !== null && newChannel === null) {
logToChannel("bot", {
embeds: [{
title: "Voice Channel Leave",
description: userMention(oldState.member!.id) + " left " + channelMention(oldChannel.id),
color: embedColor,
footer: {
text: "ID: " + oldState.member!.id,
icon_url: oldState.member!.user.avatarURL() || undefined
},
timestamp: new Date().toISOString()
}]
})
} else if (oldChannel !== null && newChannel !== null) {
if (oldChannel.id === newChannel.id) return
logToChannel("bot", {
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,
icon_url: oldState.member!.user.avatarURL() || undefined
},
timestamp: new Date().toISOString()
}]
})
}
}
} as IEvent

View File

@@ -1,17 +1,17 @@
interface ProdEnv {
token: string | undefined
mongoURI: string | undefined
dev: string | undefined
hypixelapikey: string | undefined
redisURI: string | undefined
postgresURI: string | undefined
token: string
mongoURI: string
dev: string
hypixelapikey: string
redisURI: string
postgresURI: string
}
interface DevEnv {
devtoken: string | undefined
clientid: string | undefined
devid: string | undefined
guildid: string | undefined
devtoken: string
clientid: string
devid: string
guildid: string
}
export default interface IEnv {

View File

@@ -44,7 +44,7 @@ export default async function autoDeployCommands(fileType: FileType, client: Ext
}).sort((a, b) => a.name > b.name ? 1 : -1)
client.on("ready", async (c) => {
const guildclient = c.guilds.cache.get(env.dev.guildid!)!
const guildclient = c.guilds.cache.get(env.dev.guildid)!
const currentCommands = await guildclient.commands.fetch()
if (!currentCommands) return

View File

@@ -34,15 +34,15 @@ export class ExtendedClient extends Client {
let token: string
if (process.env.NODE_ENV === "dev" && process.env.TYPESCRIPT === "true") {
console.log(color("Running in development mode. [ts-node]", "lavender"))
token = env.dev.devtoken!
token = env.dev.devtoken
autoDeployCommands("ts", this)
} else if (process.env.NODE_ENV === "dev" && !process.env.TYPESCRIPT) {
console.log(color("Running in development mode.", "lavender"))
token = env.dev.devtoken!
token = env.dev.devtoken
autoDeployCommands("js", this)
} else {
console.log(color("Running in production mode.", "green"))
token = env.prod.token!
token = env.prod.token
}
this.login(token)

View File

@@ -3,18 +3,18 @@ import "dotenv/config"
const env: IEnv = {
prod: {
token: process.env.TOKEN,
mongoURI: process.env.MONGOURI,
dev: process.env.DEV,
hypixelapikey: process.env.HYPIXELAPIKEY,
redisURI: process.env.REDISURI,
postgresURI: process.env.POSTGRESURI
token: process.env.TOKEN!,
mongoURI: process.env.MONGOURI!,
dev: process.env.DEV!,
hypixelapikey: process.env.HYPIXELAPIKEY!,
redisURI: process.env.REDISURI!,
postgresURI: process.env.POSTGRESURI!
},
dev: {
devtoken: process.env.DEVTOKEN,
clientid: process.env.CLIENTID,
devid: process.env.DEVID,
guildid: process.env.GUILDID,
devtoken: process.env.DEVTOKEN!,
clientid: process.env.CLIENTID!,
devid: process.env.DEVID!,
guildid: process.env.GUILDID!
}
}

View File

@@ -9,7 +9,7 @@ import { Sequelize } from "sequelize"
import { YoutubeiExtractor } from "discord-player-youtubei"
const client = new Client()
const redis = new Redis(env.prod.redisURI!)
const redis = new Redis(env.prod.redisURI)
const player = new Player(client)
let sequelize: Sequelize
@@ -19,7 +19,7 @@ if (process.env.NODE_ENV === "dev") {
storage: "data/db.sqlite"
})
} else {
sequelize = new Sequelize(env.prod.postgresURI!, { dialect: "postgres" })
sequelize = new Sequelize(env.prod.postgresURI, { dialect: "postgres" })
}
let ft: "js" | "ts"
@@ -49,7 +49,7 @@ class Illegitimate {
console.log(color("Synced the db [dev]", "green"))
})
}
// connect(env.prod.mongoURI!, {}).then(() => {
// connect(env.prod.mongoURI, {}).then(() => {
// console.log(color("Connected to MongoDB", "green"))
// })
}