-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* automod permit * unpermit a user * infractions * fix oversite * fix oversite v2 * Squashed commit of the following: commit a30f30c Author: Kath <[email protected]> Date: Thu Aug 1 08:51:50 2024 +0800 update renovate config commit 550d72a Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Thu Aug 1 08:37:43 2024 +0800 chore(deps): update dependency typescript-eslint to v8 (#18) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> commit 922806c Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Thu Aug 1 08:36:45 2024 +0800 chore(deps): Update dependency @types/node to ^22.0.2 (#22) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> commit 4fa7789 Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Wed Jul 31 20:36:20 2024 +0800 chore(deps): Update dependency tsx to ^4.16.3 (#21) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> commit 8c9c717 Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Wed Jul 31 20:35:47 2024 +0800 chore(deps): Update dependency mongoose to ^8.5.2 (#20) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * mute/unmute * Automod System * Fix automod url regex and logic (#25) * fix(allowed-urls): update regex and update logic * update(testfile): add new code to test file * simply logic * delete test file * remove else * Class based code * Fix urlTest being flipped * Move auto-link to mongo * Refractor automod * Save attachments when antilink is triggered * Buttons --------- Co-authored-by: Zickles <[email protected]>
- Loading branch information
Showing
24 changed files
with
1,197 additions
and
362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/config.json | ||
node_modules/ | ||
logs/ | ||
build/ | ||
build/ | ||
data/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,4 @@ | ||
import { Client, Events, GatewayIntentBits } from 'discord.js'; | ||
import deployCommands from './src/functions/deployCommands'; | ||
import { execute } from './src/events/ready'; | ||
import { token } from './config.json'; | ||
import DiscordManager from './src/DiscordManager'; | ||
const discord = new DiscordManager(); | ||
|
||
const client: Client = new Client({ | ||
intents: [ | ||
GatewayIntentBits.MessageContent, | ||
GatewayIntentBits.GuildMessages, | ||
GatewayIntentBits.GuildMembers, | ||
GatewayIntentBits.Guilds | ||
] | ||
}); | ||
|
||
deployCommands(client); | ||
|
||
client.on(Events.ClientReady, () => { | ||
execute(client); | ||
}); | ||
|
||
client.login(token); | ||
discord.connect(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { Client, GatewayIntentBits, Collection, REST, Routes } from 'discord.js'; | ||
import InteractionHandler from './handlers/InteractionHandler'; | ||
import MessageHandler from './handlers/MessageHandler'; | ||
import { token, serverId } from '../config.json'; | ||
import CheckPermits from './utils/CheckPermits'; | ||
import { SlashCommand } from './types/main'; | ||
import { connectDB } from './utils/mongo'; | ||
import { readdirSync } from 'fs'; | ||
import cron from 'node-cron'; | ||
|
||
class DiscordManager { | ||
interactionHandler: InteractionHandler; | ||
messageHandler: MessageHandler; | ||
client?: Client; | ||
constructor() { | ||
this.interactionHandler = new InteractionHandler(this); | ||
this.messageHandler = new MessageHandler(this); | ||
} | ||
|
||
connect(): void { | ||
this.client = new Client({ | ||
intents: [ | ||
GatewayIntentBits.MessageContent, | ||
GatewayIntentBits.GuildMessages, | ||
GatewayIntentBits.GuildMembers, | ||
GatewayIntentBits.Guilds | ||
] | ||
}); | ||
|
||
this.deployCommands(); | ||
this.client.on('ready', () => this.ready()); | ||
this.client.on('messageCreate', (message) => this.messageHandler.onMessage(message)); | ||
this.client.on('interactionCreate', (interaction) => this.interactionHandler.onInteraction(interaction)); | ||
|
||
this.client.login(token).catch((e) => console.log(e)); | ||
} | ||
|
||
async ready() { | ||
if (!this.client) return; | ||
console.log(`Logged in as ${this.client.user?.username} (${this.client.user?.id})!`); | ||
global.guild = await this.client.guilds.fetch(serverId); | ||
cron.schedule(`* * * * *`, () => CheckPermits()); | ||
connectDB(); | ||
} | ||
|
||
async deployCommands(): Promise<void> { | ||
if (!this.client) return; | ||
this.client.commands = new Collection<string, SlashCommand>(); | ||
const commandFiles = readdirSync('./src/commands'); | ||
const commands = []; | ||
for (const file of commandFiles) { | ||
const command = await import(`./commands/${file}`); | ||
commands.push(command.data.toJSON()); | ||
if (command.data.name) { | ||
this.client.commands.set(command.data.name, command); | ||
} | ||
} | ||
const rest = new REST({ version: '10' }).setToken(token); | ||
const clientID = Buffer.from(token.split('.')[0], 'base64').toString('ascii'); | ||
await rest.put(Routes.applicationCommands(clientID), { body: commands }); | ||
console.log(`Successfully reloaded ${commands.length} application command(s).`); | ||
} | ||
} | ||
|
||
export default DiscordManager; |
Oops, something went wrong.