Skip to content

Commit db9af14

Browse files
committed
fix(api): updateGuildInfo() now works
1 parent 17e5032 commit db9af14

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

api/db/queries/guilds.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export async function updateGuild(guild: Omit<Guild, "cooldown" | "updates_enabl
2929
pool.query(
3030
`
3131
INSERT INTO guilds (id, name, icon, members)
32-
VALUES (?, ?, ?, ?, ?, ?)
32+
VALUES (?, ?, ?, ?)
3333
ON DUPLICATE KEY UPDATE
3434
name = VALUES(name),
3535
icon = VALUES(icon),
@@ -42,7 +42,6 @@ export async function updateGuild(guild: Omit<Guild, "cooldown" | "updates_enabl
4242
guild.members,
4343
],
4444
(err, results) => {
45-
console.dir(results, { depth: null });
4645
if (err) {
4746
reject([err, null]);
4847
} else {

bot/events/guildAdd.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Events } from "discord.js";
2+
import client from "../index";
3+
import { updateGuildInfo } from "../utils/requestAPI";
4+
5+
client.on(Events.GuildCreate, async (guild) => {
6+
try {
7+
await updateGuildInfo(guild.id, guild.name, guild.iconURL() ?? 'https://cdn.discordapp.com/embed/avatars/0.png', guild.memberCount);
8+
console.log(`Joined guild ${guild.name} with ${guild.memberCount} members`);
9+
} catch (e) {
10+
console.error(e);
11+
}
12+
})

0 commit comments

Comments
 (0)