Admin name sync menu
This commit is contained in:
@@ -11,6 +11,7 @@ export * from './file-utils';
|
||||
export * from './interaction-utils';
|
||||
export * from './message-utils';
|
||||
export * from './ms-to-human';
|
||||
export * from './name-sync';
|
||||
export * from './note-utils';
|
||||
export * from './record-utils';
|
||||
export * from './refresh-commands';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ChatInputCommandInteraction, ContextMenuCommandInteraction, GuildBasedChannel, MessageFlags } from 'discord.js';
|
||||
import { ChatInputCommandInteraction, ContextMenuCommandInteraction, GuildBasedChannel, MessageFlags, ModalSubmitInteraction } from 'discord.js';
|
||||
import { channelIsInStaffCategory } from './channel-utils';
|
||||
|
||||
export async function deferInteraction(interaction: ChatInputCommandInteraction | ContextMenuCommandInteraction) {
|
||||
export async function deferInteraction(interaction: ChatInputCommandInteraction | ContextMenuCommandInteraction | ModalSubmitInteraction) {
|
||||
const isStaffChannel = await channelIsInStaffCategory(interaction.channel as GuildBasedChannel);
|
||||
|
||||
if (isStaffChannel) await interaction.deferReply();
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { E621User } from '../types';
|
||||
import { getE621User } from './e621-utils';
|
||||
import { Database } from '../shared/Database';
|
||||
import { config } from '../config';
|
||||
import { ChatInputCommandInteraction, GuildMember, ModalSubmitInteraction, UserContextMenuCommandInteraction } from 'discord.js';
|
||||
|
||||
export async function syncName(interaction: ChatInputCommandInteraction | UserContextMenuCommandInteraction | ModalSubmitInteraction, member: GuildMember, id: number | null) {
|
||||
if (member.roles.highest.comparePositionTo(member.guild.members.me!.roles.highest) > 0) {
|
||||
return interaction.editReply('I am unable to set your nickname as your role is higher than mine.');
|
||||
}
|
||||
|
||||
const availableIds = await Database.getE621Ids(interaction.user.id);
|
||||
|
||||
let e621User: E621User | null;
|
||||
|
||||
if (!id || !availableIds.includes(id)) {
|
||||
e621User = await getE621User(availableIds[0]);
|
||||
} else {
|
||||
e621User = await getE621User(id);
|
||||
}
|
||||
|
||||
if (!e621User) {
|
||||
return interaction.editReply("Couldn't figure out what your name was. Please contact an administrator.");
|
||||
}
|
||||
|
||||
await member.setNickname(e621User.name);
|
||||
interaction.editReply(`Nickname set to: ${e621User.name}`);
|
||||
}
|
||||
Reference in New Issue
Block a user