Merge branch 'dev' into 'main'
Dev See merge request illegitimate/illegitimate-bot!138
This commit is contained in:
@@ -2,7 +2,7 @@ import { ChannelType, GuildMember, userMention } from "discord.js"
|
||||
import { color, botLogChannel } from "../../../../config/options.json"
|
||||
import { Event } from "../../../interfaces"
|
||||
|
||||
const event: Event = {
|
||||
export = {
|
||||
name: "logNewJoins",
|
||||
description: "Logs new joins",
|
||||
type: "event",
|
||||
@@ -44,6 +44,4 @@ const event: Event = {
|
||||
],
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
export = event
|
||||
} as Event
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ChatInputCommandInteraction, ButtonInteraction } from "discord.js"
|
||||
import { Event } from "../../../interfaces"
|
||||
|
||||
const event: Event = {
|
||||
export = {
|
||||
name: "logBtnsCmds",
|
||||
description: "Logs all button and command interactions",
|
||||
type: "event",
|
||||
@@ -37,6 +37,4 @@ const event: Event = {
|
||||
return
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export = event
|
||||
} as Event
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Event } from "../../../interfaces"
|
||||
import { Message } from "discord.js"
|
||||
|
||||
const event: Event = {
|
||||
export = {
|
||||
name: "ur mom",
|
||||
description: "ur moms someone",
|
||||
type: "event",
|
||||
@@ -15,6 +15,4 @@ const event: Event = {
|
||||
message.react("Woot:734345936347725885")
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export = event
|
||||
} as Event
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Event } from "../../../interfaces"
|
||||
import { ExtendedClient as Client } from "../../../utils/Client"
|
||||
|
||||
const event: Event = {
|
||||
export = {
|
||||
name: "conolelog",
|
||||
description: "console log",
|
||||
type: "event",
|
||||
@@ -10,6 +10,4 @@ const event: Event = {
|
||||
execute(client: Client) {
|
||||
console.log("Logged in as " + client.user!.tag + "!")
|
||||
},
|
||||
}
|
||||
|
||||
export = event
|
||||
} as Event
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Event } from "../../../interfaces"
|
||||
import { ExtendedClient as Client } from "../../../utils/Client"
|
||||
import { ChannelType } from "discord.js"
|
||||
|
||||
const event: Event = {
|
||||
export = {
|
||||
name: "sendonlinemessage",
|
||||
description: "send an online message",
|
||||
type: "event",
|
||||
@@ -36,6 +36,4 @@ const event: Event = {
|
||||
],
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
export = event
|
||||
} as Event
|
||||
|
||||
@@ -2,7 +2,7 @@ import statuses = require("../../../../config/statuses.json")
|
||||
import { Event } from "../../../interfaces"
|
||||
import { ExtendedClient as Client } from "../../../utils/Client"
|
||||
|
||||
const event: Event = {
|
||||
export = {
|
||||
name: "status",
|
||||
description: "Sets the status of the bot",
|
||||
type: "event",
|
||||
@@ -28,6 +28,4 @@ const event: Event = {
|
||||
|
||||
user.setStatus("dnd")
|
||||
},
|
||||
}
|
||||
|
||||
export = event
|
||||
} as Event
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
import { botLogChannel, color } from "../../../../config/options.json"
|
||||
import { Event } from "../../../interfaces"
|
||||
|
||||
const event: Event = {
|
||||
export = {
|
||||
name: "vcJoinLeave",
|
||||
description: "Logs when a user joins or leaves a voice channel.",
|
||||
type: "event",
|
||||
@@ -94,6 +94,4 @@ const event: Event = {
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export = event
|
||||
} as Event
|
||||
|
||||
48
src/index.ts
48
src/index.ts
@@ -1,46 +1,4 @@
|
||||
import { ExtendedClient as Client } from "./utils/Client"
|
||||
import { GatewayIntentBits, Partials } from "discord.js"
|
||||
import config from "./utils/Config"
|
||||
import { redis } from "./utils/Redis"
|
||||
import { connect } from "mongoose"
|
||||
import { loadAllEvents } from "./utils/Events"
|
||||
import { autoDeployCommands } from "./utils/Autodeploy"
|
||||
import Illegitimate from "./utils/Illegitimate"
|
||||
const illegitimate = new Illegitimate()
|
||||
|
||||
const client = new Client({
|
||||
intents: [
|
||||
GatewayIntentBits.Guilds,
|
||||
GatewayIntentBits.GuildMessages,
|
||||
GatewayIntentBits.GuildMembers,
|
||||
GatewayIntentBits.MessageContent,
|
||||
GatewayIntentBits.DirectMessages,
|
||||
GatewayIntentBits.GuildVoiceStates,
|
||||
],
|
||||
partials: [
|
||||
Partials.GuildMember,
|
||||
Partials.User,
|
||||
Partials.Message,
|
||||
Partials.Channel,
|
||||
],
|
||||
})
|
||||
|
||||
loadAllEvents(client)
|
||||
|
||||
let token: string
|
||||
if (process.env.NODE_ENV === "dev") {
|
||||
console.log("Running in development mode.")
|
||||
token = config.dev.devtoken
|
||||
autoDeployCommands()
|
||||
} else {
|
||||
console.log("Running in production mode.")
|
||||
token = config.prod.token
|
||||
}
|
||||
|
||||
client.login(token)
|
||||
|
||||
redis.on("ready", () => {
|
||||
console.log("Connected to Redis")
|
||||
})
|
||||
|
||||
connect(config.prod.mongoURI, {}).then(() => {
|
||||
console.log("Connected to MongoDB")
|
||||
})
|
||||
illegitimate.start()
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import { Client, Collection } from "discord.js"
|
||||
import { Client, Collection, GatewayIntentBits, Partials } from "discord.js"
|
||||
import { Command } from "../interfaces"
|
||||
import { ContextMenu } from "../interfaces"
|
||||
import { Button } from "../interfaces"
|
||||
import { Modal } from "../interfaces"
|
||||
import { Autocomplete } from "../interfaces"
|
||||
import config from "./Config"
|
||||
import { autoDeployCommands } from "./Autodeploy"
|
||||
import { loadAllEvents } from "./Events"
|
||||
|
||||
export class ExtendedClient extends Client {
|
||||
commands: Collection<string, Command> = new Collection()
|
||||
@@ -11,4 +14,39 @@ export class ExtendedClient extends Client {
|
||||
buttons: Collection<string, Button> = new Collection()
|
||||
modals: Collection<string, Modal> = new Collection()
|
||||
autocomplete: Collection<string, Autocomplete> = new Collection()
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
intents: [
|
||||
GatewayIntentBits.Guilds,
|
||||
GatewayIntentBits.GuildMessages,
|
||||
GatewayIntentBits.GuildMembers,
|
||||
GatewayIntentBits.MessageContent,
|
||||
GatewayIntentBits.DirectMessages,
|
||||
GatewayIntentBits.GuildVoiceStates,
|
||||
],
|
||||
partials: [
|
||||
Partials.GuildMember,
|
||||
Partials.User,
|
||||
Partials.Message,
|
||||
Partials.Channel,
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
async start() {
|
||||
loadAllEvents(this)
|
||||
|
||||
let token: string
|
||||
if (process.env.NODE_ENV === "dev") {
|
||||
console.log("Running in development mode.")
|
||||
token = config.dev.devtoken
|
||||
autoDeployCommands()
|
||||
} else {
|
||||
console.log("Running in production mode.")
|
||||
token = config.prod.token
|
||||
}
|
||||
|
||||
this.login(token)
|
||||
}
|
||||
}
|
||||
|
||||
24
src/utils/Illegitimate.ts
Normal file
24
src/utils/Illegitimate.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { ExtendedClient as Client } from "./Client"
|
||||
import config from "./Config"
|
||||
import { redis } from "./Redis"
|
||||
import { connect } from "mongoose"
|
||||
import init from "./Init"
|
||||
const client = new Client()
|
||||
|
||||
export default class Illegitimate {
|
||||
constructor() {}
|
||||
|
||||
async start() {
|
||||
init()
|
||||
|
||||
client.start()
|
||||
|
||||
redis.on("ready", () => {
|
||||
console.log("Connected to Redis")
|
||||
})
|
||||
|
||||
connect(config.prod.mongoURI, {}).then(() => {
|
||||
console.log("Connected to MongoDB")
|
||||
})
|
||||
}
|
||||
}
|
||||
26
src/utils/Init.ts
Normal file
26
src/utils/Init.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import config from "./Config"
|
||||
|
||||
const prodValues = config.prod
|
||||
const devValues = config.dev
|
||||
|
||||
export default function init() {
|
||||
if (process.env.NODE_ENV === "dev") {
|
||||
Object.keys(devValues).forEach(key => {
|
||||
if (!process.env[key]) {
|
||||
throw new Error(`[DEV] Missing environment variable: ${key}`)
|
||||
}
|
||||
})
|
||||
|
||||
Object.keys(prodValues).forEach(key => {
|
||||
if (!process.env[key]) {
|
||||
throw new Error(`[PROD] Missing environment variable: ${key}`)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
Object.keys(prodValues).forEach(key => {
|
||||
if (!process.env[key]) {
|
||||
throw new Error(`[PROD] Missing environment variable: ${key}`)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user