Added Unload Global

This commit is contained in:
2023-04-23 13:41:09 +07:00
parent 503278de44
commit 7c648c1f55
+33 -1
View File
@@ -25,7 +25,7 @@ const EMBEDS = {
fields: [
{
name: 'Available arguments',
value: '``reloadAll`` ``unloadAll`` ``reloadglobal``'
value: '``reloadAll`` ``unloadAll`` ``reloadGlobal`` ``unloadGlobal``'
}
],
user: data.getUser()
@@ -126,6 +126,36 @@ export default class InteractionManager extends DiscordModule {
);
}
},
unloadGlobal: async (data: HybridInteractionMessage) => {
let placeholder: HybridInteractionMessage | undefined;
let _placeholder = await sendHybridInteractionMessageResponse(data, {
embeds: [EMBEDS.PROCESSING(data)]
});
if (_placeholder) placeholder = new HybridInteractionMessage(_placeholder);
try {
await unregisterAllGlobalCommands();
if (data && data.isMessage() && placeholder && placeholder.isMessage())
return placeholder.getMessage().edit({ embeds: [EMBEDS.UNLOADALL_SUCCESS(data)] });
else if (data.isApplicationCommand())
return await sendHybridInteractionMessageResponse(
data,
{ embeds: [EMBEDS.UNLOADALL_SUCCESS(data)] },
true
);
} catch (err) {
if (data && data.isMessage() && placeholder && placeholder.isMessage())
return placeholder.getMessage().edit({ embeds: [EMBEDS.UNLOADALL_ERROR(data, err)] });
else if (data.isApplicationCommand())
return await sendHybridInteractionMessageResponse(
data,
{ embeds: [EMBEDS.UNLOADALL_ERROR(data, err)] },
true
);
}
},
reloadGlobal: async (data: HybridInteractionMessage) => {
let placeholder: HybridInteractionMessage | undefined;
@@ -214,6 +244,8 @@ export default class InteractionManager extends DiscordModule {
return await funct.reloadGlobal(data);
case 'unloadall':
return await funct.unloadAll(data);
case 'unloadglobal':
return await funct.unloadGlobal(data);
}
}
}