Merge pull request #1194 from DEVTomatoCake/fix/update-vanity-url-widget-invite

Fix updating vanity URL & widget.json
This commit is contained in:
Madeline 2024-08-24 07:49:43 +10:00 committed by GitHub
commit 60f22c227c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 14 deletions

View File

@ -108,30 +108,23 @@ router.patch(
}); });
if (!guild.features.includes("ALIASABLE_NAMES")) { if (!guild.features.includes("ALIASABLE_NAMES")) {
await Invite.update( await Invite.delete({ guild_id, vanity_url: true });
{ guild_id },
{
code: code,
},
);
return res.json({ code });
} }
await Invite.create({ await Invite.create({
vanity_url: true, vanity_url: true,
code: code, code,
temporary: false, temporary: false,
uses: 0, uses: 0,
max_uses: 0, max_uses: 0,
max_age: 0, max_age: 0,
created_at: new Date(), created_at: new Date(),
expires_at: new Date(),
guild_id: guild_id, guild_id: guild_id,
channel_id: id, channel_id: id,
flags: 0,
}).save(); }).save();
return res.json({ code: code }); return res.json({ code });
}, },
); );

View File

@ -57,6 +57,10 @@ router.get(
where: { id: guild_id }, where: { id: guild_id },
select: { select: {
channel_ordering: true, channel_ordering: true,
widget_channel_id: true,
widget_enabled: true,
presence_count: true,
name: true,
}, },
}); });
if (!guild.widget_enabled) throw DiscordApiErrors.EMBED_DISABLED; if (!guild.widget_enabled) throw DiscordApiErrors.EMBED_DISABLED;
@ -82,6 +86,7 @@ router.get(
created_at: new Date(), created_at: new Date(),
guild_id, guild_id,
channel_id: guild.widget_channel_id, channel_id: guild.widget_channel_id,
flags: 0,
}).save(); }).save();
} }