mirror of
https://github.com/nx-bat/pet-the-pond.git
synced 2026-09-22 02:19:10 -04:00
added error reporting
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
import { CommandClient, Event } from 'athena-prime';
|
||||||
|
|
||||||
|
// ----------
|
||||||
|
|
||||||
|
class ErrorEvent extends Event<CommandClient> {
|
||||||
|
event: string = 'ready' as const;
|
||||||
|
|
||||||
|
async handle(context: CommandClient<any, any>, error: string | Error, shard?: number | undefined) {
|
||||||
|
const _err = error as Error;
|
||||||
|
|
||||||
|
await context.createMessage('1548676420136599624', {
|
||||||
|
embed: {
|
||||||
|
color: 0xff5555,
|
||||||
|
|
||||||
|
fields: [
|
||||||
|
{ name: 'Message', value: _err.message, inline: false },
|
||||||
|
{ name: 'Cause', value: `${_err.cause ?? 'N/A'}`, inline: false },
|
||||||
|
{ name: 'Stack', value: `${_err.stack ?? 'N/A'}`, inline: false }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default new ErrorEvent('error');
|
||||||
@@ -8,6 +8,22 @@ class ReadyEvent extends Event<CommandClient> {
|
|||||||
async handle(context: CommandClient<any, any>) {
|
async handle(context: CommandClient<any, any>) {
|
||||||
await context.deployCommands();
|
await context.deployCommands();
|
||||||
context.setCustomActivity('Tracking your petting!');
|
context.setCustomActivity('Tracking your petting!');
|
||||||
|
|
||||||
|
context.on('error', async (error: string | Error, shard?: number | undefined) => {
|
||||||
|
const _err = error as Error;
|
||||||
|
|
||||||
|
await context.createMessage('1548676420136599624', {
|
||||||
|
embed: {
|
||||||
|
color: 0xff5555,
|
||||||
|
|
||||||
|
fields: [
|
||||||
|
{ name: 'Message', value: _err.message, inline: false },
|
||||||
|
{ name: 'Cause', value: `${_err.cause ?? 'N/A'}`, inline: false },
|
||||||
|
{ name: 'Stack', value: `${_err.stack ?? 'N/A'}`, inline: false }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-5
@@ -1,11 +1,8 @@
|
|||||||
import messageReactionAdd from './message/messageReactionAdd';
|
import messageReactionAdd from './message/messageReactionAdd';
|
||||||
import messageReactionRemove from './message/messageReactionRemove';
|
import messageReactionRemove from './message/messageReactionRemove';
|
||||||
|
import error from './client/error';
|
||||||
import ready from './client/ready';
|
import ready from './client/ready';
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
|
|
||||||
export default [
|
export default [messageReactionAdd, messageReactionRemove, error, ready];
|
||||||
messageReactionAdd,
|
|
||||||
messageReactionRemove,
|
|
||||||
ready,
|
|
||||||
];
|
|
||||||
|
|||||||
@@ -7,19 +7,15 @@ class MessageReactionAddEvent extends Event<CommandClient> {
|
|||||||
event: string = 'messageReactionAdd' as const;
|
event: string = 'messageReactionAdd' as const;
|
||||||
|
|
||||||
async handle(context: CommandClient<any, any>, message: Message, emoji: Constants.APIEmoji, member: Member) {
|
async handle(context: CommandClient<any, any>, message: Message, emoji: Constants.APIEmoji, member: Member) {
|
||||||
try {
|
const _message = await context.getMessage(message.channel.id, message.id);
|
||||||
const _message = await context.getMessage(message.channel.id, message.id);
|
if (!_message.guildID || emoji.id != '1547870117080342548' || member.id == _message.author.id) return;
|
||||||
if (!_message.guildID || emoji.id != '1547870117080342548' || member.id == _message.author.id) return;
|
|
||||||
|
|
||||||
await database`
|
await database`
|
||||||
INSERT INTO points AS p (user_id, guild_id, points)
|
INSERT INTO points AS p (user_id, guild_id, points)
|
||||||
VALUES (${_message.author.id}, ${_message.guildID}, 1)
|
VALUES (${_message.author.id}, ${_message.guildID}, 1)
|
||||||
ON CONFLICT (user_id, guild_id)
|
ON CONFLICT (user_id, guild_id)
|
||||||
DO UPDATE SET points = p.points + 1
|
DO UPDATE SET points = p.points + 1
|
||||||
`;
|
`;
|
||||||
} catch (error) {
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user