Compare commits

...

4 Commits

Author SHA1 Message Date
nxbat ef5a59205a (docs): update readme.
Signed-off-by: Nix Krystik <nix@archwing.dev>
2026-09-16 17:36:46 +08:00
nxbat b32278c108 some logging for me. 2026-09-13 21:14:56 +08:00
nxbat b7b26796bd added error reporting 2026-09-13 20:53:22 +08:00
nxbat 145e0f7365 it's uhh, fixed. 2026-09-13 20:42:50 +08:00
9 changed files with 120 additions and 8 deletions
+1
View File
@@ -2,3 +2,4 @@
DATABASE_URL=postgresql://postgres:postgres@postgres:5432/pond
DEV_GUILD=
DISCORD_TOKEN=
LOGGING_CHANNEL=
+12 -2
View File
@@ -1,2 +1,12 @@
# Pet the Pond
A points-based reaction bot for Discord. If anyone wants to take this project off my hands, please take it. I don't want it anymore.
# Pond's Petting Zoo
A small joke bot which counts petting reactions on messages, giving points to the message author & placing them on the leaderboard.
It includes some basic commands which are restricted to specific users by default.
Please note this is was a "for the meme" request and isn't supposed to be used by other servers. Use it however you want though.
## Packages
These are packages I mainly use due to them not being a total headache to use and don't require a million packages.
- `athena-prime` - A modified fork of [Eris](https://github.com/abalabahaha/eris), maintained by [Team Hydra](https://teamhydra.dev/).
- [`postgres`](https://github.com/porsager/postgres) - A postgres client written in JavaScript. The only one I will use.
- [`dotenv`](https://github.com/motdotla/dotenv) - A library for loading variables from .env files.
+27
View File
@@ -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');
+13
View File
@@ -8,6 +8,19 @@ class ReadyEvent extends Event<CommandClient> {
async handle(context: CommandClient<any, any>) {
await context.deployCommands();
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 },
]
}
});
}
}
+31
View File
@@ -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');
+23
View File
@@ -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
View File
@@ -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 messageReactionRemove from './message/messageReactionRemove';
import ready from './client/ready';
// ----------
export default [
messageReactionAdd,
messageReactionRemove,
ready,
error, ready, // Client.
guildCreate, guildDelete, // Guild.
messageReactionAdd, messageReactionRemove // Message.
];
+3 -2
View File
@@ -7,11 +7,12 @@ class MessageReactionAddEvent extends Event<CommandClient> {
event: string = 'messageReactionAdd' as const;
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`
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)
DO UPDATE SET points = p.points + 1
`;
+1
View File
@@ -3,6 +3,7 @@ declare global {
interface ProcessEnv {
DATABASE_URL: string;
DISCORD_TOKEN: string;
LOGGING_CHANNEL: string;
}
}
}