mirror of
https://github.com/kirameki-cafe/Yumi.git
synced 2026-09-13 18:59:19 +00:00
Add FakeError
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
import { Message, MessageEmbed, Interaction, CommandInteraction, TextChannel } from "discord.js";
|
||||
import { makeInfoEmbed, makeErrorEmbed, makeSuccessEmbed, makeProcessingEmbed, makeWarningEmbed, sendMessageOrInteractionResponse, sendMessage } from "../../utils/DiscordMessage";
|
||||
import DiscordProvider from "../../providers/Discord";
|
||||
import { registerAllGuildsCommands, unregisterAllGuildsCommands } from "../../utils/DiscordInteraction";
|
||||
import DiscordMusicPlayer from "../../providers/DiscordMusicPlayer";
|
||||
import Users from "../../services/Users";
|
||||
|
||||
|
||||
const EMBEDS = {
|
||||
FAKEERROR_INFO: (data: Message | Interaction) => {
|
||||
return makeInfoEmbed({
|
||||
title: 'Fake error',
|
||||
description: `Simulate an error`,
|
||||
fields: [
|
||||
{
|
||||
name: 'Available arguments',
|
||||
value: '``crashMusicPlayer``'
|
||||
}
|
||||
],
|
||||
user: (data instanceof Interaction) ? data.user : data.author
|
||||
});
|
||||
},
|
||||
NOT_DEVELOPER: (data: Message | Interaction) => {
|
||||
return makeErrorEmbed({
|
||||
title: 'Developer only',
|
||||
description: `This command is restricted to the developers only`,
|
||||
user: (data instanceof Interaction) ? data.user : data.author
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
export default class FakeError {
|
||||
|
||||
async onCommand(command: string, args: any, message: Message) {
|
||||
if (command.toLowerCase() !== 'fakeerror') return;
|
||||
await this.process(message, args);
|
||||
}
|
||||
|
||||
async interactionCreate(interaction: CommandInteraction) {
|
||||
if (interaction.isCommand()) {
|
||||
if (typeof interaction.commandName === 'undefined') return;
|
||||
if ((interaction.commandName).toLowerCase() !== 'fakeerror') return;
|
||||
await this.process(interaction, interaction.options);
|
||||
}
|
||||
}
|
||||
|
||||
async process(data: Interaction | Message, args: any) {
|
||||
const isSlashCommand = data instanceof CommandInteraction && data.isCommand();
|
||||
const isMessage = data instanceof Message;
|
||||
|
||||
if (!isSlashCommand && !isMessage) return;
|
||||
|
||||
if (!Users.isDeveloper(data.member?.user.id!))
|
||||
return await sendMessageOrInteractionResponse(data, { embeds: [EMBEDS.NOT_DEVELOPER(data)] });
|
||||
|
||||
if(!data.guildId) return;
|
||||
|
||||
const funct = {
|
||||
crashMusicPlayer: async (data: Message | Interaction) => {
|
||||
const instance = DiscordMusicPlayer.getGuildInstance(data.guildId!);
|
||||
if(!instance) return;
|
||||
|
||||
instance._fake_error_on_player();
|
||||
}
|
||||
}
|
||||
|
||||
let query;
|
||||
|
||||
if (isMessage) {
|
||||
if (data === null || !data.guildId || data.member === null || data.guild === null) return;
|
||||
|
||||
if (args.length === 0) {
|
||||
return await sendMessageOrInteractionResponse(data, { embeds: [EMBEDS.FAKEERROR_INFO(data)] });
|
||||
}
|
||||
query = args[0].toLowerCase();
|
||||
|
||||
}
|
||||
else if (isSlashCommand) {
|
||||
query = args.getSubcommand();
|
||||
}
|
||||
|
||||
switch (query) {
|
||||
case "info":
|
||||
return await sendMessageOrInteractionResponse(data, { embeds: [EMBEDS.FAKEERROR_INFO(data)] });
|
||||
case "crashmusicplayer":
|
||||
return await funct.crashMusicPlayer(data);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,8 @@ import Discord_MusicPlayer_Queue from "../discord/MusicPlayer/Queue";
|
||||
import Discord_MusicPlayer_Search from "../discord/MusicPlayer/Search";
|
||||
import Discord_MusicPlayer_Search_NowPlaying from "../discord/MusicPlayer/NowPlaying";
|
||||
|
||||
import Discord_Developer_ServiceAnnouncement from "../discord/developer/ServiceAnnouncement"
|
||||
import Discord_Developer_ServiceAnnouncement from "../discord/developer/ServiceAnnouncement";
|
||||
import Discord_Developer_FakeError from "../discord/developer/FakeError";
|
||||
|
||||
import Cache from "./Cache";
|
||||
|
||||
@@ -68,6 +69,7 @@ class Discord {
|
||||
this.loaded_module["MembershipScreening"] = new Discord_MembershipScreening();
|
||||
|
||||
this.loaded_module["Discord_Developer_ServiceAnnouncement"] = new Discord_Developer_ServiceAnnouncement();
|
||||
this.loaded_module["Discord_Developer_FakeError"] = new Discord_Developer_FakeError();
|
||||
|
||||
for(const module in this.loaded_module) {
|
||||
let thisModule = this.loaded_module[module];
|
||||
|
||||
Reference in New Issue
Block a user