fix: occasional crash in context menus
Co-authored-by: metal <metal@i0.tf>
This commit is contained in:
parent
3064a05b4d
commit
dd2eebd4a5
3 changed files with 8 additions and 8 deletions
|
@ -10,7 +10,7 @@ export async function cleanAction(
|
||||||
amount: number,
|
amount: number,
|
||||||
interaction: ContextMenuCommandInteraction,
|
interaction: ContextMenuCommandInteraction,
|
||||||
) {
|
) {
|
||||||
interaction.deferReply({ ephemeral: true });
|
await interaction.deferReply({ ephemeral: true });
|
||||||
const executingMember = await pluginData.guild.members.fetch(interaction.user.id);
|
const executingMember = await pluginData.guild.members.fetch(interaction.user.id);
|
||||||
const userCfg = await pluginData.config.getMatchingConfig({
|
const userCfg = await pluginData.config.getMatchingConfig({
|
||||||
channelId: interaction.channelId,
|
channelId: interaction.channelId,
|
||||||
|
@ -34,10 +34,10 @@ export async function cleanAction(
|
||||||
const user = undefined;
|
const user = undefined;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
interaction.followUp(`Cleaning... Amount: ${amount}, User Only: ${targetUserOnly}, Pins: ${deletePins}`);
|
await interaction.followUp(`Cleaning... Amount: ${amount}, User Only: ${targetUserOnly}, Pins: ${deletePins}`);
|
||||||
utility.clean({ count: amount, user, channel: targetMessage.channel.id, "delete-pins": deletePins }, targetMessage);
|
utility.clean({ count: amount, user, channel: targetMessage.channel.id, "delete-pins": deletePins }, targetMessage);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
interaction.followUp({ ephemeral: true, content: "Plugin error, please check your BOT_ALERTs" });
|
await interaction.followUp({ ephemeral: true, content: "Plugin error, please check your BOT_ALERTs" });
|
||||||
|
|
||||||
if (e instanceof RecoverablePluginError && e.code === ERRORS.NO_MUTE_ROLE_IN_CONFIG) {
|
if (e instanceof RecoverablePluginError && e.code === ERRORS.NO_MUTE_ROLE_IN_CONFIG) {
|
||||||
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
||||||
|
|
|
@ -15,7 +15,7 @@ export async function muteAction(
|
||||||
duration: string | undefined,
|
duration: string | undefined,
|
||||||
interaction: ContextMenuCommandInteraction,
|
interaction: ContextMenuCommandInteraction,
|
||||||
) {
|
) {
|
||||||
interaction.deferReply({ ephemeral: true });
|
await interaction.deferReply({ ephemeral: true });
|
||||||
const executingMember = await pluginData.guild.members.fetch(interaction.user.id);
|
const executingMember = await pluginData.guild.members.fetch(interaction.user.id);
|
||||||
const userCfg = await pluginData.config.getMatchingConfig({
|
const userCfg = await pluginData.config.getMatchingConfig({
|
||||||
channelId: interaction.channelId,
|
channelId: interaction.channelId,
|
||||||
|
@ -34,7 +34,7 @@ export async function muteAction(
|
||||||
const targetMember = await pluginData.guild.members.fetch(interaction.targetId);
|
const targetMember = await pluginData.guild.members.fetch(interaction.targetId);
|
||||||
|
|
||||||
if (!canActOn(pluginData, executingMember, targetMember)) {
|
if (!canActOn(pluginData, executingMember, targetMember)) {
|
||||||
interaction.followUp({ ephemeral: true, content: "Cannot mute: insufficient permissions" });
|
await interaction.followUp({ ephemeral: true, content: "Cannot mute: insufficient permissions" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,9 +51,9 @@ export async function muteAction(
|
||||||
result.notifyResult.method ?? "dm"
|
result.notifyResult.method ?? "dm"
|
||||||
})\nPlease update the new case with the \`update\` command`;
|
})\nPlease update the new case with the \`update\` command`;
|
||||||
|
|
||||||
interaction.followUp({ ephemeral: true, content: muteMessage });
|
await interaction.followUp({ ephemeral: true, content: muteMessage });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
interaction.followUp({ ephemeral: true, content: "Plugin error, please check your BOT_ALERTs" });
|
await interaction.followUp({ ephemeral: true, content: "Plugin error, please check your BOT_ALERTs" });
|
||||||
|
|
||||||
if (e instanceof RecoverablePluginError && e.code === ERRORS.NO_MUTE_ROLE_IN_CONFIG) {
|
if (e instanceof RecoverablePluginError && e.code === ERRORS.NO_MUTE_ROLE_IN_CONFIG) {
|
||||||
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
||||||
|
|
|
@ -7,7 +7,7 @@ export async function userInfoAction(
|
||||||
pluginData: GuildPluginData<ContextMenuPluginType>,
|
pluginData: GuildPluginData<ContextMenuPluginType>,
|
||||||
interaction: ContextMenuCommandInteraction,
|
interaction: ContextMenuCommandInteraction,
|
||||||
) {
|
) {
|
||||||
interaction.deferReply({ ephemeral: true });
|
await interaction.deferReply({ ephemeral: true });
|
||||||
const executingMember = await pluginData.guild.members.fetch(interaction.user.id);
|
const executingMember = await pluginData.guild.members.fetch(interaction.user.id);
|
||||||
const userCfg = await pluginData.config.getMatchingConfig({
|
const userCfg = await pluginData.config.getMatchingConfig({
|
||||||
channelId: interaction.channelId,
|
channelId: interaction.channelId,
|
||||||
|
|
Loading…
Add table
Reference in a new issue