Skip to content

Commit f94fccf

Browse files
committed
can be null error on button selectmenu
No reply on button and selectmenu errors, with Button&SelectMenu#nullError = true;
1 parent 545c39c commit f94fccf

File tree

6 files changed

+16
-2
lines changed

6 files changed

+16
-2
lines changed

index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,36 +407,43 @@ client.on("interactionCreate", async (interaction) => {
407407
}
408408

409409
if (uInter.disabled) {
410+
if (uInter.nullError) return interaction.update ? (await interaction.update().catch(() => {})) : null;
410411
config.userErrors.disabled(interaction, uInter, other);
411412
return;
412413
}
413414

414415
if (config.blockedUsers.has(interaction.user.id)) {
416+
if (uInter.nullError) return interaction.update ? (await interaction.update().catch(() => { })) : null;
415417
config.userErrors.blocked(interaction, uInter, other);
416418
return;
417419
}
418420

419421
if (uInter.guildOnly && !interaction.guildId) {
422+
if (uInter.nullError) return interaction.update ? (await interaction.update().catch(() => { })) : null;
420423
config.userErrors.guildOnly(interaction, uInter, other);
421424
return;
422425
}
423426

424427
if (uInter.calculated.developerOnly && !config.developers.has(interaction.user.id)) {
428+
if (uInter.nullError) return interaction.update ? (await interaction.update().catch(() => { })) : null;
425429
config.userErrors.developerOnly(interaction, uInter, other);
426430
return;
427431
}
428432

429433
if (uInter.calculated.guildOwnerOnly && !config.developers.has(interaction.user.id) && interaction.guild.ownerId != interaction.user.id) {
434+
if (uInter.nullError) return interaction.update ? (await interaction.update().catch(() => { })) : null;
430435
config.userErrors.guildOwnerOnly(interaction, uInter, other);
431436
return;
432437
}
433438

434439
if (uInter.guildOnly && uInter.perms.bot.length != 0 && !uInter.perms.bot.every(perm => interaction.guild.me.permissions.has(perm))) {
440+
if (uInter.nullError) return interaction.update ? (await interaction.update().catch(() => { })) : null;
435441
config.userErrors.botPermsRequired(interaction, uInter, uInter.perms.bot, other);
436442
return;
437443
}
438444

439445
if (uInter.guildOnly && (!config.developers.has(interaction.user.id)) && uInter.perms.user.length != 0 && !uInter.perms.user.every(perm => interaction.member.permissions.has(perm))) {
446+
if (uInter.nullError) return interaction.update ? (await interaction.update().catch(() => { })) : null;
440447
config.userErrors.userPermsRequired(interaction, uInter, uInter.perms.user, other);
441448
return;
442449
}

interactions/eval.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module.exports = new Underline.SlashCommand({
3030
}
3131
},
3232
perms: {
33-
user: ["DEVELOPER"]
33+
user: ["DEVELOPER"],
3434
},
3535
options: [
3636
{

interactions/paylaşılmayanlar/basBana.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module.exports = new Underline.Button({
22
id: "basBana",
33
name: "basBana",
4+
nullError: true,
5+
// nullError: false,
46
description: "...",
57
onInteraction(inter, other) {
68
inter.reply("Evet")

interactions/paylaşılmayanlar/secBeni.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = new Underline.SelectMenu({
22
id: "secBeni",
33
name: "secBeni",
4+
nullError: false,
45
description: "...",
56
onInteraction(inter, other) {
67
inter.reply({

types/Interaction.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export class BaseInteraction {
6666
defaultPermission?: boolean;
6767
actionType?: ApplicationCommandType | "SELECT_MENU" | "BUTTON";
6868
autoDefer?: "off" | "on" | "ephemeral";
69+
nullError?: undefined;
6970
calculated?: { [key: string | number]: any };
7071
isSelectMenu(): this is import("./SelectMenu");
7172
isButton(): this is import("./Button");
@@ -75,7 +76,7 @@ export class BaseInteraction {
7576
constructor(arg: TInteractionConstructor);
7677
}
7778

78-
export type TOmittedInteraction = Omit<BaseInteraction, "_type" | "coolDowns" | "name" | "onInteraction" | "actionType" | "options" | "toJSON" | "calculated">;
79+
export type TOmittedInteraction = Omit<BaseInteraction, "_type" | "coolDowns" | "name" | "onInteraction" | "actionType" | "options" | "toJSON" | "calculated" | "nullError">;
7980
export type TInteractionConstructor = TOmittedInteraction & ((ActionChatCommand | ActionRightClickCommand | SelectMenu | Button));
8081
type cooldownType = "user" | "member" | "channel" | "guild" | "message" | "any";
8182
export interface IOther {
@@ -106,6 +107,7 @@ export interface SelectMenu {
106107
onInteraction(interaction: SelectMenuInteraction, other: IOther): void;
107108
options?: CustomSelectMenuOptions;
108109
toJSON(): MessageSelectMenu;
110+
nullError?: Boolean;
109111
}
110112

111113
export interface Button {
@@ -114,6 +116,7 @@ export interface Button {
114116
onInteraction(interaction: ButtonInteraction, other: IOther): void;
115117
options?: CustomButtonOptions;
116118
toJSON(): MessageButton;
119+
nullError?: Boolean;
117120
}
118121

119122
export = BaseInteraction;

types/Interaction.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class Interaction {
4747

4848
this.id = arg.id || `${this.actionType}_${this.name.join("_")}`.toLowerCase();
4949
this._type = arg._type ?? this._type;
50+
this.nullError = (this._type === "noDeployInteraction") ? (arg.nullError ?? false) : false;
5051
this.perms.bot = Array.isArray(arg.perms?.bot) && arg.perms.bot.length != 0 ? arg.perms.bot : Underline.config.interactionDefaults.perms.bot;
5152
this.perms.user = Array.isArray(arg.perms?.user) && arg.perms.user.length != 0 ? arg.perms.user : Underline.config.interactionDefaults.perms.user;
5253
this.onInteraction = arg.onInteraction;

0 commit comments

Comments
 (0)