Skip to content

Commit

Permalink
[PATCH] proper filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
Larsundso committed Dec 26, 2023
1 parent 524d02e commit cb8eb9c
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/Commands/ButtonCommands/rp/toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ const deleteAll = async (cmd: Discord.ButtonInteraction<'cached'>) => {
[...(ch.cache.commands.cache.get(cmd.guild.id)?.values() ?? [])] ??
cmd.guild.commands.cache.map((c) => c)
)
.filter((c) => !!c.guildId)
.map((c) => c.toJSON() as Discord.APIApplicationCommand)
.filter((c) => !ch.constants.commands.interactions.find((i) => i.name === c.name)),
.filter((c) => !ch.constants.commands.interactions.find((i) => i.name === c.name) && !!c.guildId)
.map((c) => c.toJSON() as Discord.APIApplicationCommand),
);
};

Expand Down Expand Up @@ -103,12 +102,14 @@ export const create = async (guild: Discord.Guild) => {

await ch.request.commands.bulkOverwriteGuildCommands(guild, [
...registerCommands.map((c) => c.toJSON()),
...(
[...(ch.cache.commands.cache.get(guild.id)?.values() ?? [])] ??
guild.commands.cache.map((c) => c)
)
.map((c) => c.toJSON() as Discord.APIApplicationCommand)
.filter((c) => !ch.constants.commands.interactions.find((i) => i.name === c.name)),
...[...(ch.cache.commands.cache.get(guild.id)?.values() ?? guild.commands.cache.map((c) => c))]
.filter(
(c) =>
!ch.constants.commands.interactions.find((i) => i.name === c.name) &&
!!c.guildId &&
!registerCommands.find((r) => r.name === c.name),
)
.map((c) => c.toJSON() as Discord.APIApplicationCommand),
]);

await ch.DataBase.guildsettings.update({
Expand Down

0 comments on commit cb8eb9c

Please sign in to comment.