Formatted code

This commit is contained in:
2023-03-05 14:46:25 +07:00
parent 89744dcb10
commit b44e583834
47 changed files with 1240 additions and 1162 deletions
+36 -23
View File
@@ -1,11 +1,16 @@
import { Message, CommandInteraction, Interaction } from "discord.js";
import { I18n } from "i18n";
import { Message, CommandInteraction, Interaction } from 'discord.js';
import { I18n } from 'i18n';
import DiscordMusicPlayer from "../../providers/DiscordMusicPlayer";
import DiscordMusicPlayer from '../../providers/DiscordMusicPlayer';
import DiscordModule, { HybridInteractionMessage } from "../../utils/DiscordModule";
import { makeSuccessEmbed, makeInfoEmbed, makeErrorEmbed, sendHybridInteractionMessageResponse } from "../../utils/DiscordMessage";
import Locale from "../../services/Locale";
import DiscordModule, { HybridInteractionMessage } from '../../utils/DiscordModule';
import {
makeSuccessEmbed,
makeInfoEmbed,
makeErrorEmbed,
sendHybridInteractionMessageResponse
} from '../../utils/DiscordMessage';
import Locale from '../../services/Locale';
const EMBEDS = {
RESUMED: (data: HybridInteractionMessage, locale: I18n) => {
@@ -38,24 +43,22 @@ const EMBEDS = {
user: data.getUser()
});
}
}
};
export default class Resume extends DiscordModule{
public id = "Discord_MusicPlayer_Resume";
public commands = ["resume"];
public commandInteractionName = "resume";
export default class Resume extends DiscordModule {
public id = 'Discord_MusicPlayer_Resume';
public commands = ['resume'];
public commandInteractionName = 'resume';
async GuildOnModuleCommand(args: any, message: Message) {
await this.run(new HybridInteractionMessage(message), args);
}
async GuildModuleCommandInteractionCreate(interaction: CommandInteraction) {
async GuildModuleCommandInteractionCreate(interaction: CommandInteraction) {
await this.run(new HybridInteractionMessage(interaction), interaction.options);
}
async run(data: HybridInteractionMessage, args: any) {
const guild = data.getGuild();
const member = data.getMember();
@@ -66,23 +69,33 @@ export default class Resume extends DiscordModule{
const voiceChannel = member.voice.channel;
if (!voiceChannel)
return await sendHybridInteractionMessageResponse(data, { embeds: [EMBEDS.USER_NOT_IN_VOICECHANNEL(data, locale)] });
return await sendHybridInteractionMessageResponse(data, {
embeds: [EMBEDS.USER_NOT_IN_VOICECHANNEL(data, locale)]
});
const instance = DiscordMusicPlayer.getGuildInstance(guild.id);
if(!instance)
return await sendHybridInteractionMessageResponse(data, { embeds: [EMBEDS.NO_MUSIC_PLAYING(data, locale)] });
if (!instance)
return await sendHybridInteractionMessageResponse(data, {
embeds: [EMBEDS.NO_MUSIC_PLAYING(data, locale)]
});
if(instance.voiceChannel.id !== voiceChannel.id)
return await sendHybridInteractionMessageResponse(data, { embeds: [EMBEDS.USER_NOT_IN_SAME_VOICECHANNEL(data, locale)] }, true);
if (instance.voiceChannel.id !== voiceChannel.id)
return await sendHybridInteractionMessageResponse(
data,
{ embeds: [EMBEDS.USER_NOT_IN_SAME_VOICECHANNEL(data, locale)] },
true
);
if(instance.queue.track.length === 0)
return await sendHybridInteractionMessageResponse(data, { embeds: [EMBEDS.NO_MUSIC_PLAYING(data, locale)] });
if (instance.queue.track.length === 0)
return await sendHybridInteractionMessageResponse(data, {
embeds: [EMBEDS.NO_MUSIC_PLAYING(data, locale)]
});
if(!instance.isPaused())
if (!instance.isPaused())
return await sendHybridInteractionMessageResponse(data, { embeds: [EMBEDS.NOT_PAUSED(data, locale)] });
instance.resumePlayer();
return await sendHybridInteractionMessageResponse(data, { embeds: [EMBEDS.RESUMED(data, locale)] });
}
}
}