mirror of
https://github.com/nx-bat/pet-the-pond.git
synced 2026-09-22 10:29:11 -04:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b32278c108 | |||
| b7b26796bd | |||
| 145e0f7365 |
@@ -2,3 +2,4 @@
|
|||||||
DATABASE_URL=postgresql://postgres:postgres@postgres:5432/pond
|
DATABASE_URL=postgresql://postgres:postgres@postgres:5432/pond
|
||||||
DEV_GUILD=
|
DEV_GUILD=
|
||||||
DISCORD_TOKEN=
|
DISCORD_TOKEN=
|
||||||
|
LOGGING_CHANNEL=
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import { CommandClient, Event } from 'athena-prime';
|
||||||
|
|
||||||
|
// ----------
|
||||||
|
|
||||||
|
class ErrorEvent extends Event<CommandClient> {
|
||||||
|
event: string = 'error' as const;
|
||||||
|
|
||||||
|
async handle(context: CommandClient<any, any>, error: string | Error, shard?: number | undefined) {
|
||||||
|
const _err = error as Error;
|
||||||
|
|
||||||
|
await context.createMessage(process.env.LOGGING_CHANNEL, {
|
||||||
|
embed: {
|
||||||
|
color: 0xff5555,
|
||||||
|
|
||||||
|
title: 'Error',
|
||||||
|
|
||||||
|
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,19 @@ 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!');
|
||||||
|
|
||||||
|
await context.createMessage(process.env.LOGGING_CHANNEL, {
|
||||||
|
embed: {
|
||||||
|
color: 0x55ff55,
|
||||||
|
|
||||||
|
title: 'Bot Ready',
|
||||||
|
|
||||||
|
fields: [
|
||||||
|
{ name: 'Guilds', value: `${context.guilds.size}`, inline: true },
|
||||||
|
{ name: 'Shards', value: `${context.shards.size}`, inline: true },
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import { CommandClient, Event, Guild } from 'athena-prime';
|
||||||
|
|
||||||
|
// ----------
|
||||||
|
|
||||||
|
class GuildCreateEvent extends Event<CommandClient> {
|
||||||
|
event: string = 'guildCreate' as const;
|
||||||
|
|
||||||
|
async handle(context: CommandClient<any, any>, guild: Guild) {
|
||||||
|
await context.createMessage(process.env.LOGGING_CHANNEL, {
|
||||||
|
embed: {
|
||||||
|
color: 0x55ff55,
|
||||||
|
|
||||||
|
thumbnail: {
|
||||||
|
url: guild.iconURL!,
|
||||||
|
},
|
||||||
|
|
||||||
|
title: 'Joined Guild',
|
||||||
|
|
||||||
|
fields: [
|
||||||
|
{ name: 'Name', value: `${guild.name}`, inline: false },
|
||||||
|
{ name: 'Name', value: `${guild.id}`, inline: false },
|
||||||
|
{ name: 'Owner', value: `${(await context.fetchUser(guild.ownerID)).username}`, inline: false },
|
||||||
|
{ name: 'Members', value: `${guild.memberCount}`, inline: false },
|
||||||
|
{ name: 'Large', value: `${guild.large}`, inline: false },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default new GuildCreateEvent('guildCreate');
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { CommandClient, Event, Guild } from 'athena-prime';
|
||||||
|
|
||||||
|
// ----------
|
||||||
|
|
||||||
|
class GuildCreateEvent extends Event<CommandClient> {
|
||||||
|
event: string = 'guildCreate' as const;
|
||||||
|
|
||||||
|
async handle(context: CommandClient<any, any>, guild: { id: string; }) {
|
||||||
|
await context.createMessage(process.env.LOGGING_CHANNEL, {
|
||||||
|
embed: {
|
||||||
|
color: 0xff5555,
|
||||||
|
|
||||||
|
title: 'Left Guild',
|
||||||
|
|
||||||
|
fields: [
|
||||||
|
{ name: 'Name', value: `${guild.id}`, inline: false }
|
||||||
|
],
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default new GuildCreateEvent('guildCreate');
|
||||||
+9
-4
@@ -1,11 +1,16 @@
|
|||||||
|
import error from './client/error';
|
||||||
|
import ready from './client/ready';
|
||||||
|
|
||||||
|
import guildCreate from './guild/guildCreate';
|
||||||
|
import guildDelete from './guild/guildDelete';
|
||||||
|
|
||||||
import messageReactionAdd from './message/messageReactionAdd';
|
import messageReactionAdd from './message/messageReactionAdd';
|
||||||
import messageReactionRemove from './message/messageReactionRemove';
|
import messageReactionRemove from './message/messageReactionRemove';
|
||||||
import ready from './client/ready';
|
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
messageReactionAdd,
|
error, ready, // Client.
|
||||||
messageReactionRemove,
|
guildCreate, guildDelete, // Guild.
|
||||||
ready,
|
messageReactionAdd, messageReactionRemove // Message.
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -7,11 +7,12 @@ 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) {
|
||||||
if (!message.guildID || emoji.id != '1547870117080342548' || member.id == message.author.id) return;
|
const _message = await context.getMessage(message.channel.id, message.id);
|
||||||
|
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}, ${member.guild.id}, 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
|
||||||
`;
|
`;
|
||||||
|
|||||||
Vendored
+1
@@ -3,6 +3,7 @@ declare global {
|
|||||||
interface ProcessEnv {
|
interface ProcessEnv {
|
||||||
DATABASE_URL: string;
|
DATABASE_URL: string;
|
||||||
DISCORD_TOKEN: string;
|
DISCORD_TOKEN: string;
|
||||||
|
LOGGING_CHANNEL: string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user