Skip to content

Commit

Permalink
🔨
Browse files Browse the repository at this point in the history
  • Loading branch information
idinium96 committed Jul 18, 2024
1 parent ee60ecf commit 8d3d144
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/classes/DiscordBot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ export default class DiscordBot {
});

// 'ready' binding should be executed BEFORE the login() is complete
/* eslint-disable */
this.client.on('ready', this.onClientReady.bind(this));
this.client.on('messageCreate', async message => this.onMessage(message));
/* eslint-enable */
this.prefix = this.bot.options.miscSettings?.prefixes?.discord ?? this.prefix;
}

Expand All @@ -49,13 +51,15 @@ export default class DiscordBot {
}
]);

/* eslint-disable */
this.client.on('interactionCreate', async interaction => {
if (!interaction.isChatInputCommand()) return;

if (interaction.commandName === 'uptime') {
await interaction.reply({ content: uptime() });
}
});
/* eslint-enable */
} catch (err) {
const error = err as DiscordAPIError;

Expand Down Expand Up @@ -174,8 +178,8 @@ export default class DiscordBot {
.send(message)
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
.then(() => log.info(`Message sent to ${origMessage.author.tag} (${origMessage.author.id}): ${message}`))
.catch(err => log.error('Failed to send message to Discord:', err));
.then(() => log.info(`Message sent to ${origMessage.author.tag} (${origMessage.author.id}): ${message}`));
// .catch((err: any) => log.error('Failed to send message to Discord:', err));
}

private async onClientReady() {
Expand Down Expand Up @@ -206,6 +210,7 @@ export default class DiscordBot {
setPresence(type: 'online' | 'halt'): void {
const opt = this.bot.options.discordChat[type];

/* eslint-disable */
this.client?.user?.setPresence({
activities: [
{
Expand All @@ -218,6 +223,7 @@ export default class DiscordBot {
],
status: opt.status
});
/* eslint-enable */
}

halt(): void {
Expand Down

0 comments on commit 8d3d144

Please sign in to comment.