Make whois ephemeral outside staff channels
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { ApplicationIntegrationType, Client, InteractionContextType, MessageFlags, PermissionFlagsBits, ContextMenuCommandBuilder, ApplicationCommandType, ContextMenuCommandInteraction, UserContextMenuCommandInteraction } from 'discord.js';
|
import { ApplicationIntegrationType, Client, InteractionContextType, PermissionFlagsBits, ContextMenuCommandBuilder, ApplicationCommandType, UserContextMenuCommandInteraction, GuildBasedChannel } from 'discord.js';
|
||||||
import { handleWhoIsInteraction } from '../utils';
|
import { channelIsInStaffCategory, handleWhoIsInteraction } from '../utils';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'whois',
|
name: 'whois',
|
||||||
@@ -12,6 +12,6 @@ export default {
|
|||||||
handler: async function (client: Client, interaction: UserContextMenuCommandInteraction) {
|
handler: async function (client: Client, interaction: UserContextMenuCommandInteraction) {
|
||||||
const idToUse = interaction.targetUser.id;
|
const idToUse = interaction.targetUser.id;
|
||||||
|
|
||||||
handleWhoIsInteraction(interaction, idToUse, true);
|
handleWhoIsInteraction(interaction, idToUse, !(await channelIsInStaffCategory(interaction.channel as GuildBasedChannel)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { ApplicationIntegrationType, ChatInputCommandInteraction, Client, InteractionContextType, MessageFlags, PermissionFlagsBits, SlashCommandBuilder } from 'discord.js';
|
import { ApplicationIntegrationType, BitFieldResolvable, ChatInputCommandInteraction, Client, GuildBasedChannel, InteractionContextType, MessageFlags, PermissionFlagsBits, SlashCommandBuilder } from 'discord.js';
|
||||||
import { handleWhoIsInteraction } from '../utils';
|
import { channelIsInStaffCategory, handleWhoIsInteraction } from '../utils';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'whois',
|
name: 'whois',
|
||||||
@@ -31,6 +31,6 @@ export default {
|
|||||||
|
|
||||||
const idToUse = (user?.id ?? id) as string;
|
const idToUse = (user?.id ?? id) as string;
|
||||||
|
|
||||||
handleWhoIsInteraction(interaction, idToUse);
|
handleWhoIsInteraction(interaction, idToUse, !(await channelIsInStaffCategory(interaction.channel as GuildBasedChannel)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
+5
-4
@@ -3,6 +3,9 @@ import { config } from '../config';
|
|||||||
import { Database } from '../shared/Database';
|
import { Database } from '../shared/Database';
|
||||||
|
|
||||||
export async function handleWhoIsInteraction(interaction: CommandInteraction, idToUse: string, ephemeral = false) {
|
export async function handleWhoIsInteraction(interaction: CommandInteraction, idToUse: string, ephemeral = false) {
|
||||||
|
if (ephemeral) await interaction.deferReply({ flags: [MessageFlags.Ephemeral] });
|
||||||
|
else await interaction.deferReply();
|
||||||
|
|
||||||
const results = await Database.getE621Ids(idToUse);
|
const results = await Database.getE621Ids(idToUse);
|
||||||
|
|
||||||
if (results.length > 0) {
|
if (results.length > 0) {
|
||||||
@@ -25,10 +28,8 @@ export async function handleWhoIsInteraction(interaction: CommandInteraction, id
|
|||||||
content += `\n\nDiscord alts found:\n${mappedAlts}`;
|
content += `\n\nDiscord alts found:\n${mappedAlts}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ephemeral) interaction.reply({ content, flags: [MessageFlags.Ephemeral] });
|
interaction.editReply(content);
|
||||||
else interaction.reply(content);
|
|
||||||
} else {
|
} else {
|
||||||
if (ephemeral) interaction.reply({ content: 'No e621 accounts found for this user', flags: [MessageFlags.Ephemeral] });
|
interaction.editReply('No e621 accounts found for this user');
|
||||||
else interaction.reply('No e621 accounts found for this user');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user