mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 22:21:51 +00:00
Made confirms ephemeral and fixed slash command duration options
This commit is contained in:
parent
a49bb81ce1
commit
4d8b6b5cd7
6 changed files with 16 additions and 25 deletions
|
@ -76,7 +76,7 @@ export const CommonPlugin = zeppelinGuildPlugin<CommonPluginType>()({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const replyMethod = context.replied ? "followUp" : "reply";
|
const replyMethod = context.replied ? "editReply" : "reply";
|
||||||
|
|
||||||
return context[replyMethod]({
|
return context[replyMethod]({
|
||||||
content: formattedBody,
|
content: formattedBody,
|
||||||
|
@ -127,7 +127,7 @@ export const CommonPlugin = zeppelinGuildPlugin<CommonPluginType>()({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const replyMethod = context.replied ? "followUp" : "reply";
|
const replyMethod = context.replied ? "editReply" : "reply";
|
||||||
|
|
||||||
return context[replyMethod]({
|
return context[replyMethod]({
|
||||||
content: formattedBody,
|
content: formattedBody,
|
||||||
|
|
|
@ -71,7 +71,7 @@ export const ForceMuteSlashCmd = {
|
||||||
ppId = interaction.user.id;
|
ppId = interaction.user.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
const convertedTime = options.time ? convertDelayStringToMS(options.time) : null;
|
const convertedTime = options.time ? convertDelayStringToMS(options.time) ?? undefined : undefined;
|
||||||
if (options.time && !convertedTime) {
|
if (options.time && !convertedTime) {
|
||||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
||||||
return;
|
return;
|
||||||
|
@ -92,7 +92,7 @@ export const ForceMuteSlashCmd = {
|
||||||
attachments,
|
attachments,
|
||||||
mod,
|
mod,
|
||||||
ppId,
|
ppId,
|
||||||
options.time,
|
convertedTime,
|
||||||
options.reason,
|
options.reason,
|
||||||
contactMethods,
|
contactMethods,
|
||||||
);
|
);
|
||||||
|
|
|
@ -54,12 +54,12 @@ export const ForceUnmuteSlashCmd = {
|
||||||
ppId = interaction.user.id;
|
ppId = interaction.user.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
const convertedTime = options.time ? convertDelayStringToMS(options.time) : null;
|
const convertedTime = options.time ? convertDelayStringToMS(options.time) ?? undefined : undefined;
|
||||||
if (options.time && !convertedTime) {
|
if (options.time && !convertedTime) {
|
||||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
actualUnmuteCmd(pluginData, interaction, options.user, attachments, mod, ppId, options.time, options.reason);
|
actualUnmuteCmd(pluginData, interaction, options.user, attachments, mod, ppId, convertedTime, options.reason);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -45,15 +45,6 @@ export const MuteSlashCmd = {
|
||||||
|
|
||||||
async run({ interaction, options, pluginData }) {
|
async run({ interaction, options, pluginData }) {
|
||||||
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
|
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
|
||||||
|
|
||||||
if ((!options.reason || options.reason.trim() === "") && attachments.length < 1) {
|
|
||||||
pluginData
|
|
||||||
.getPlugin(CommonPlugin)
|
|
||||||
.sendErrorMessage(interaction, "Text or attachment required", undefined, undefined, true);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const memberToMute = await resolveMember(pluginData.client, pluginData.guild, options.user.id);
|
const memberToMute = await resolveMember(pluginData.client, pluginData.guild, options.user.id);
|
||||||
|
|
||||||
if (!memberToMute) {
|
if (!memberToMute) {
|
||||||
|
@ -106,7 +97,7 @@ export const MuteSlashCmd = {
|
||||||
ppId = interaction.user.id;
|
ppId = interaction.user.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
const convertedTime = options.time ? convertDelayStringToMS(options.time) : null;
|
const convertedTime = options.time ? convertDelayStringToMS(options.time) ?? undefined : undefined;
|
||||||
if (options.time && !convertedTime) {
|
if (options.time && !convertedTime) {
|
||||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
||||||
return;
|
return;
|
||||||
|
@ -127,7 +118,7 @@ export const MuteSlashCmd = {
|
||||||
attachments,
|
attachments,
|
||||||
mod,
|
mod,
|
||||||
ppId,
|
ppId,
|
||||||
options.time,
|
convertedTime,
|
||||||
options.reason,
|
options.reason,
|
||||||
contactMethods,
|
contactMethods,
|
||||||
);
|
);
|
||||||
|
|
|
@ -102,12 +102,12 @@ export const UnmuteSlashCmd = {
|
||||||
ppId = interaction.user.id;
|
ppId = interaction.user.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
const convertedTime = options.time ? convertDelayStringToMS(options.time) : null;
|
const convertedTime = options.time ? convertDelayStringToMS(options.time) ?? undefined : undefined;
|
||||||
if (options.time && !convertedTime) {
|
if (options.time && !convertedTime) {
|
||||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
actualUnmuteCmd(pluginData, interaction, options.user, attachments, mod, ppId, options.time, options.reason);
|
actualUnmuteCmd(pluginData, interaction, options.user, attachments, mod, ppId, convertedTime, options.reason);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -36,14 +36,14 @@ export async function waitForButtonConfirm(
|
||||||
const sendMethod = () => {
|
const sendMethod = () => {
|
||||||
return contextIsInteraction
|
return contextIsInteraction
|
||||||
? context.replied
|
? context.replied
|
||||||
? context.followUp.bind(context)
|
? context.editReply.bind(context)
|
||||||
: context.reply.bind(context)
|
: context.reply.bind(context)
|
||||||
: "send" in context
|
: "send" in context
|
||||||
? context.send.bind(context)
|
? context.send.bind(context)
|
||||||
: context.channel.send.bind(context.channel);
|
: context.channel.send.bind(context.channel);
|
||||||
};
|
};
|
||||||
const extraParameters = contextIsInteraction ? { fetchReply: true } : {};
|
const extraParameters = contextIsInteraction ? { fetchReply: true, ephemeral: true } : {};
|
||||||
const message = await sendMethod()({ ...toPost, components: [row], ...extraParameters });
|
const message = (await sendMethod()({ ...toPost, components: [row], ...extraParameters })) as Message;
|
||||||
|
|
||||||
const collector = message.createMessageComponentCollector({ time: 10000 });
|
const collector = message.createMessageComponentCollector({ time: 10000 });
|
||||||
|
|
||||||
|
@ -55,16 +55,16 @@ export async function waitForButtonConfirm(
|
||||||
.catch((err) => console.trace(err.message));
|
.catch((err) => console.trace(err.message));
|
||||||
} else {
|
} else {
|
||||||
if (interaction.customId.startsWith(`confirmButton:${idMod}:`)) {
|
if (interaction.customId.startsWith(`confirmButton:${idMod}:`)) {
|
||||||
message.delete();
|
if (!contextIsInteraction) message.delete();
|
||||||
resolve(true);
|
resolve(true);
|
||||||
} else if (interaction.customId.startsWith(`cancelButton:${idMod}:`)) {
|
} else if (interaction.customId.startsWith(`cancelButton:${idMod}:`)) {
|
||||||
message.delete();
|
if (!contextIsInteraction) message.delete();
|
||||||
resolve(false);
|
resolve(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
collector.on("end", () => {
|
collector.on("end", () => {
|
||||||
if (message.deletable) message.delete().catch(noop);
|
if (!contextIsInteraction && message.deletable) message.delete().catch(noop);
|
||||||
resolve(false);
|
resolve(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue