-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from crowbartools/2.0
2.0 overhaul
- Loading branch information
Showing
37 changed files
with
7,237 additions
and
9,432 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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 |
---|---|---|
@@ -1,44 +1,39 @@ | ||
{ | ||
"name": "crowbartools-discord-bot", | ||
"version": "1.0.3", | ||
"version": "2.0.0", | ||
"description": "A bot that helps service the Crowbar Tools Discord server.", | ||
"main": "dist/app.js", | ||
"main": "dist/main.js", | ||
"dependencies": { | ||
"@discordjs/builders": "^0.13.0", | ||
"axios": "^0.21.1", | ||
"discord-api-types": "^0.32.0", | ||
"discord-modals": "^1.3.7", | ||
"discord-slash-commands-client": "ebiggz/discord-interactions#a688699a73a3dff2fd16dece1487265709e7c6c5", | ||
"discord.js": "^13.6.0", | ||
"dotenv": "^8.2.0", | ||
"graphql": "^16.4.0", | ||
"graphql-request": "^4.2.0", | ||
"moment": "^2.24.0", | ||
"node-cache": "^5.1.0" | ||
"axios": "^1.7.4", | ||
"discord.js": "^14.15.3", | ||
"dotenv": "^16.4.5", | ||
"luxon": "^3.5.0", | ||
"lz-string": "^1.5.0", | ||
"node-cache": "^5.1.2" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^27.0.2", | ||
"@types/moment": "^2.13.0", | ||
"@types/node": "^16.9.1", | ||
"@typescript-eslint/eslint-plugin": "^2.21.0", | ||
"@typescript-eslint/parser": "^2.21.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-prettier": "^6.10.0", | ||
"eslint-plugin-prettier": "^3.1.2", | ||
"jest": "^27.2.1", | ||
"prettier": "^1.19.1", | ||
"ts-jest": "^27.0.5", | ||
"typescript": "^4.4.3" | ||
"@types/jest": "^29.5.12", | ||
"@types/luxon": "^3.4.2", | ||
"@typescript-eslint/eslint-plugin": "^8.1.0", | ||
"@typescript-eslint/parser": "^8.1.0", | ||
"eslint": "^9.9.0", | ||
"eslint-config-prettier": "^ 9.1.0", | ||
"eslint-plugin-prettier": "^5.2.1", | ||
"jest": "^29.7.0", | ||
"prettier": "^3.3.3", | ||
"ts-jest": "^29.2.4", | ||
"typescript": "^5.5.4" | ||
}, | ||
"scripts": { | ||
"start": "tsc && node dist/app.js", | ||
"dev": "tsc && NODE_ENV=development node dist/main.js", | ||
"start": "tsc && NODE_ENV=production node dist/main.js", | ||
"build": "tsc", | ||
"lint": "eslint . --ext .js,.ts", | ||
"test": "jest" | ||
}, | ||
"author": "ebiggz", | ||
"license": "GPL-3.0", | ||
"volta": { | ||
"node": "16.9.1" | ||
"node": "20.16.0" | ||
} | ||
} |
This file was deleted.
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,97 @@ | ||
import { | ||
ActivityType, | ||
Client, | ||
Events, | ||
GatewayIntentBits, | ||
Partials, | ||
REST, | ||
Routes, | ||
} from 'discord.js'; | ||
import { config } from './config'; | ||
import { commandManager } from './interactions/commands/command-manager'; | ||
import { modalManager } from './interactions/modals/modal-manager'; | ||
import { IInteractionManager } from './interactions/interaction-manager.interface'; | ||
|
||
const discordClient = new Client({ | ||
intents: [ | ||
GatewayIntentBits.Guilds, | ||
GatewayIntentBits.GuildMessages, | ||
GatewayIntentBits.DirectMessages, | ||
], | ||
partials: [Partials.Message, Partials.Channel, Partials.User], | ||
presence: { | ||
status: 'dnd', | ||
activities: [ | ||
{ | ||
name: 'Firebot Streams', | ||
type: ActivityType.Watching, | ||
}, | ||
], | ||
}, | ||
}); | ||
|
||
const interactionManagers: IInteractionManager[] = [ | ||
commandManager, | ||
modalManager, | ||
]; | ||
|
||
export async function init(): Promise<void> { | ||
for (const manager of interactionManagers) { | ||
manager.loadHandlers(); | ||
} | ||
|
||
discordClient.once(Events.ClientReady, (readyClient) => { | ||
console.log(`Ready! Logged in as ${readyClient.user.tag}`); | ||
}); | ||
|
||
discordClient.on(Events.InteractionCreate, async (interaction) => { | ||
if (interaction.guildId !== config.discord.serverGuildId) { | ||
// Ignore interactions from other guilds | ||
return; | ||
} | ||
|
||
try { | ||
for (const manager of interactionManagers) { | ||
if (manager.interactionTypes.includes(interaction.type)) { | ||
await manager.handleInteraction(interaction); | ||
} | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
|
||
if (interaction.isAutocomplete()) { | ||
return; | ||
} | ||
|
||
if (interaction.replied || interaction.deferred) { | ||
await interaction.followUp({ | ||
content: | ||
'Sorry, there was a problem with this command - please let the Crowbar team know.', | ||
ephemeral: true, | ||
}); | ||
} else { | ||
await interaction.reply({ | ||
content: | ||
'Sorry, there was a problem with this command - please let the Crowbar team know.', | ||
ephemeral: true, | ||
}); | ||
} | ||
} | ||
}); | ||
|
||
const discordApi = new REST().setToken(config.discord.token); | ||
|
||
await discordApi.put( | ||
Routes.applicationGuildCommands( | ||
config.discord.botAppId, | ||
config.discord.serverGuildId | ||
), | ||
{ | ||
body: commandManager | ||
.getRegisteredCommandHandlers() | ||
.map((c) => c.config.toJSON()), | ||
} | ||
); | ||
|
||
discordClient.login(config.discord.token); | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.