mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 14:38:49 +00:00
61 files changed
+472
-674
No files matched your search
+77
-24
@@ -1,12 +1,16 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
|
import { GuildQueue } from 'discord-player';
|
||||||
import {
|
import {
|
||||||
ApplicationCommandOptionChoiceData,
|
ApplicationCommandOptionChoiceData,
|
||||||
AutocompleteInteraction,
|
AutocompleteInteraction,
|
||||||
ChatInputCommandInteraction,
|
ChatInputCommandInteraction,
|
||||||
|
EmbedAuthorOptions,
|
||||||
|
GuildMember,
|
||||||
Interaction,
|
Interaction,
|
||||||
Message,
|
Message,
|
||||||
MessageComponentInteraction,
|
MessageComponentInteraction,
|
||||||
SlashCommandBuilder
|
SlashCommandBuilder,
|
||||||
|
SlashCommandSubcommandsOnlyBuilder
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
import { Logger } from 'pino';
|
import { Logger } from 'pino';
|
||||||
import loggerModule from '../services/logger';
|
import loggerModule from '../services/logger';
|
||||||
@@ -20,6 +24,7 @@ import {
|
|||||||
BaseSlashCommandParams,
|
BaseSlashCommandParams,
|
||||||
BaseSlashCommandReturnType
|
BaseSlashCommandReturnType
|
||||||
} from '../types/interactionTypes';
|
} from '../types/interactionTypes';
|
||||||
|
import { Validator, ValidatorParams } from '../types/utilTypes';
|
||||||
|
|
||||||
abstract class BaseInteraction {
|
abstract class BaseInteraction {
|
||||||
protected getLoggerBase(
|
protected getLoggerBase(
|
||||||
@@ -37,22 +42,65 @@ abstract class BaseInteraction {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected validators: Validator[] = [];
|
||||||
|
|
||||||
|
protected async runValidators(args: ValidatorParams, validators?: Validator[]): Promise<void> {
|
||||||
|
for (const validator of validators ? validators : this.validators) {
|
||||||
|
await validator(args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
abstract execute(
|
abstract execute(
|
||||||
params: BaseInteractionParams
|
params: BaseInteractionParams
|
||||||
): Promise<Message<boolean> | ApplicationCommandOptionChoiceData | void>;
|
): Promise<Message<boolean> | ApplicationCommandOptionChoiceData | void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export abstract class BaseSlashCommandInteraction extends BaseInteraction {
|
abstract class BaseInteractionWithEmbedResponse extends BaseInteraction {
|
||||||
data: Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>;
|
embedOptions: EmbedOptions;
|
||||||
|
botOptions: BotOptions;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.embedOptions = config.get('embedOptions');
|
||||||
|
this.botOptions = config.get('botOptions');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async getEmbedUserAuthor(
|
||||||
|
interaction: MessageComponentInteraction | ChatInputCommandInteraction
|
||||||
|
): Promise<EmbedAuthorOptions> {
|
||||||
|
let authorName: string = '';
|
||||||
|
if (interaction.member instanceof GuildMember) {
|
||||||
|
authorName = interaction.member.nickname || interaction.user.username;
|
||||||
|
} else {
|
||||||
|
authorName = interaction.user.username;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: authorName,
|
||||||
|
iconURL: interaction.user.avatarURL() || this.embedOptions.info.fallbackIconUrl
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async getEmbedQueueAuthor(
|
||||||
|
interaction: MessageComponentInteraction | ChatInputCommandInteraction,
|
||||||
|
queue: GuildQueue
|
||||||
|
): Promise<EmbedAuthorOptions> {
|
||||||
|
return {
|
||||||
|
name: `Channel: ${queue.channel!.name} (${queue.channel!.bitrate / 1000}kbps)`,
|
||||||
|
iconURL: interaction.guild!.iconURL() || this.embedOptions.info.fallbackIconUrl
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export abstract class BaseSlashCommandInteraction extends BaseInteractionWithEmbedResponse {
|
||||||
|
data: Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'> | SlashCommandSubcommandsOnlyBuilder;
|
||||||
isSystemCommand: boolean;
|
isSystemCommand: boolean;
|
||||||
isNew: boolean;
|
isNew: boolean;
|
||||||
isBeta: boolean;
|
isBeta: boolean;
|
||||||
embedOptions: EmbedOptions;
|
|
||||||
botOptions: BotOptions;
|
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
data: Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>,
|
data: Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'> | SlashCommandSubcommandsOnlyBuilder,
|
||||||
isSystemCommand: boolean = false,
|
isSystemCommand: boolean = false,
|
||||||
isNew: boolean = false,
|
isNew: boolean = false,
|
||||||
isBeta: boolean = false
|
isBeta: boolean = false
|
||||||
@@ -62,8 +110,6 @@ export abstract class BaseSlashCommandInteraction extends BaseInteraction {
|
|||||||
this.isSystemCommand = isSystemCommand;
|
this.isSystemCommand = isSystemCommand;
|
||||||
this.isNew = isNew;
|
this.isNew = isNew;
|
||||||
this.isBeta = isBeta;
|
this.isBeta = isBeta;
|
||||||
this.embedOptions = config.get('embedOptions');
|
|
||||||
this.botOptions = config.get('botOptions');
|
|
||||||
this.name = data.name;
|
this.name = data.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,22 +120,7 @@ export abstract class BaseSlashCommandInteraction extends BaseInteraction {
|
|||||||
abstract execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType;
|
abstract execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export abstract class BaseAutocompleteInteraction extends BaseInteraction {
|
export abstract class BaseComponentInteraction extends BaseInteractionWithEmbedResponse {
|
||||||
name: string;
|
|
||||||
|
|
||||||
constructor(name: string) {
|
|
||||||
super();
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected getLogger(name: string, executionId: string, interaction: AutocompleteInteraction): Logger {
|
|
||||||
return super.getLoggerBase('autocompleteInteraction', name, executionId, interaction);
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract execute(params: BaseAutocompleteParams): BaseAutocompleteReturnType;
|
|
||||||
}
|
|
||||||
|
|
||||||
export abstract class BaseComponentInteraction extends BaseInteraction {
|
|
||||||
embedOptions: EmbedOptions;
|
embedOptions: EmbedOptions;
|
||||||
botOptions: BotOptions;
|
botOptions: BotOptions;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -108,7 +139,29 @@ export abstract class BaseComponentInteraction extends BaseInteraction {
|
|||||||
abstract execute(params: BaseComponentParams): BaseComponentReturnType;
|
abstract execute(params: BaseComponentParams): BaseComponentReturnType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export abstract class BaseAutocompleteInteraction extends BaseInteraction {
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
constructor(name: string) {
|
||||||
|
super();
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected getLogger(name: string, executionId: string, interaction: AutocompleteInteraction): Logger {
|
||||||
|
return super.getLoggerBase('autocompleteInteraction', name, executionId, interaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract execute(params: BaseAutocompleteParams): BaseAutocompleteReturnType;
|
||||||
|
}
|
||||||
|
|
||||||
export class CustomError extends Error {
|
export class CustomError extends Error {
|
||||||
type?: string;
|
type?: string;
|
||||||
code?: string;
|
code?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class InteractionValidationError extends Error {
|
||||||
|
constructor(message?: string) {
|
||||||
|
super(message);
|
||||||
|
this.name = 'InteractionValidationError';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
import { Events } from 'discord.js';
|
import { Events } from 'discord.js';
|
||||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||||
|
|
||||||
import loggerModule from '../../services/logger';
|
|
||||||
import { Logger } from 'pino';
|
import { Logger } from 'pino';
|
||||||
|
import loggerModule from '../../services/logger';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: Events.Debug,
|
name: Events.Debug,
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { BaseGuildTextChannel, EmbedBuilder } from 'discord.js';
|
import { BaseGuildTextChannel, EmbedBuilder } from 'discord.js';
|
||||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||||
|
import { Logger } from 'pino';
|
||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
import { ExtendedClient } from '../../types/clientTypes';
|
import { ExtendedClient } from '../../types/clientTypes';
|
||||||
import { EmbedOptions, SystemOptions } from '../../types/configTypes';
|
import { EmbedOptions, SystemOptions } from '../../types/configTypes';
|
||||||
import { Logger } from 'pino';
|
|
||||||
|
|
||||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||||
const systemOptions: SystemOptions = config.get('systemOptions');
|
const systemOptions: SystemOptions = config.get('systemOptions');
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import { Events } from 'discord.js';
|
import { Events } from 'discord.js';
|
||||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||||
|
|
||||||
import loggerModule from '../../services/logger';
|
|
||||||
import { Logger } from 'pino';
|
import { Logger } from 'pino';
|
||||||
|
import loggerModule from '../../services/logger';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: Events.Error,
|
name: Events.Error,
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import { Events, Guild } from 'discord.js';
|
import { Events, Guild } from 'discord.js';
|
||||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||||
|
|
||||||
import loggerModule from '../../services/logger';
|
|
||||||
import { Logger } from 'pino';
|
import { Logger } from 'pino';
|
||||||
|
import loggerModule from '../../services/logger';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: Events.GuildCreate,
|
name: Events.GuildCreate,
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import { Events, Guild } from 'discord.js';
|
import { Events, Guild } from 'discord.js';
|
||||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||||
|
|
||||||
import loggerModule from '../../services/logger';
|
|
||||||
import { Logger } from 'pino';
|
import { Logger } from 'pino';
|
||||||
|
import loggerModule from '../../services/logger';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: Events.GuildDelete,
|
name: Events.GuildDelete,
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { BaseGuildTextChannel, EmbedBuilder, Events, PresenceData } from 'discord.js';
|
import { BaseGuildTextChannel, EmbedBuilder, Events, PresenceData } from 'discord.js';
|
||||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||||
|
|
||||||
import { Logger } from 'pino';
|
import { Logger } from 'pino';
|
||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
import { ExtendedClient } from '../../types/clientTypes';
|
import { ExtendedClient } from '../../types/clientTypes';
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { BaseGuildTextChannel, EmbedBuilder } from 'discord.js';
|
import { BaseGuildTextChannel, EmbedBuilder } from 'discord.js';
|
||||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||||
|
|
||||||
import { Logger } from 'pino';
|
import { Logger } from 'pino';
|
||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
import { ExtendedClient } from '../../types/clientTypes';
|
import { ExtendedClient } from '../../types/clientTypes';
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Events } from 'discord.js';
|
import { Events } from 'discord.js';
|
||||||
import { Logger } from 'pino';
|
|
||||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||||
|
import { Logger } from 'pino';
|
||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@@ -6,15 +6,15 @@ import {
|
|||||||
InteractionType,
|
InteractionType,
|
||||||
MessageComponentInteraction
|
MessageComponentInteraction
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
import { Logger } from 'pino';
|
|
||||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||||
|
import { Logger } from 'pino';
|
||||||
|
import { CustomError } from '../../classes/interactions';
|
||||||
import { handleAutocomplete } from '../../handlers/interactionAutocompleteHandler';
|
import { handleAutocomplete } from '../../handlers/interactionAutocompleteHandler';
|
||||||
import { handleCommand } from '../../handlers/interactionCommandHandler';
|
import { handleCommand } from '../../handlers/interactionCommandHandler';
|
||||||
import { handleComponent } from '../../handlers/interactionComponentHandler';
|
import { handleComponent } from '../../handlers/interactionComponentHandler';
|
||||||
import { handleError } from '../../handlers/interactionErrorHandler';
|
import { handleError } from '../../handlers/interactionErrorHandler';
|
||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
import { ExtendedClient } from '../../types/clientTypes';
|
import { ExtendedClient } from '../../types/clientTypes';
|
||||||
import { CustomError } from '../../classes/interactions';
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: Events.InteractionCreate,
|
name: Events.InteractionCreate,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Logger } from 'pino';
|
|
||||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||||
|
import { Logger } from 'pino';
|
||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { BaseGuildTextChannel, EmbedBuilder } from 'discord.js';
|
import { BaseGuildTextChannel, EmbedBuilder } from 'discord.js';
|
||||||
import { Logger } from 'pino';
|
|
||||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||||
|
import { Logger } from 'pino';
|
||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
import { BotOptions, EmbedOptions, SystemOptions } from '../../types/configTypes';
|
import { BotOptions, EmbedOptions, SystemOptions } from '../../types/configTypes';
|
||||||
import { ExtendedGuildQueuePlayerNode } from '../../types/eventTypes';
|
import { ExtendedGuildQueuePlayerNode } from '../../types/eventTypes';
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Logger } from 'pino';
|
|
||||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||||
|
import { Logger } from 'pino';
|
||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { BaseGuildTextChannel, EmbedBuilder } from 'discord.js';
|
import { BaseGuildTextChannel, EmbedBuilder } from 'discord.js';
|
||||||
import { Logger } from 'pino';
|
|
||||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||||
|
import { Logger } from 'pino';
|
||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
import { BotOptions, EmbedOptions, SystemOptions } from '../../types/configTypes';
|
import { BotOptions, EmbedOptions, SystemOptions } from '../../types/configTypes';
|
||||||
import { ExtendedGuildQueuePlayerNode } from '../../types/eventTypes';
|
import { ExtendedGuildQueuePlayerNode } from '../../types/eventTypes';
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { Track } from 'discord-player';
|
import { Track } from 'discord-player';
|
||||||
import { BaseGuildTextChannel, EmbedBuilder } from 'discord.js';
|
import { BaseGuildTextChannel, EmbedBuilder } from 'discord.js';
|
||||||
import { Logger } from 'pino';
|
|
||||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||||
|
import { Logger } from 'pino';
|
||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
import { BotOptions, EmbedOptions, SystemOptions } from '../../types/configTypes';
|
import { BotOptions, EmbedOptions, SystemOptions } from '../../types/configTypes';
|
||||||
import { ExtendedGuildQueuePlayerNode } from '../../types/eventTypes';
|
import { ExtendedGuildQueuePlayerNode } from '../../types/eventTypes';
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Track } from 'discord-player';
|
import { Track } from 'discord-player';
|
||||||
import { Logger } from 'pino';
|
|
||||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||||
|
import { Logger } from 'pino';
|
||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
import { ExtendedGuildQueuePlayerNode } from '../../types/eventTypes';
|
import { ExtendedGuildQueuePlayerNode } from '../../types/eventTypes';
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Logger } from 'pino';
|
|
||||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||||
|
import { Logger } from 'pino';
|
||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Logger } from 'pino';
|
|
||||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||||
|
import { Logger } from 'pino';
|
||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { AutocompleteInteraction } from 'discord.js';
|
import { AutocompleteInteraction } from 'discord.js';
|
||||||
import { Logger } from 'pino';
|
import { Logger } from 'pino';
|
||||||
|
import { BaseAutocompleteInteraction } from '../classes/interactions';
|
||||||
import loggerModule from '../services/logger';
|
import loggerModule from '../services/logger';
|
||||||
import { ExtendedClient } from '../types/clientTypes';
|
import { ExtendedClient } from '../types/clientTypes';
|
||||||
import { BaseAutocompleteInteraction } from '../classes/interactions';
|
|
||||||
|
|
||||||
export const handleAutocomplete = async (
|
export const handleAutocomplete = async (
|
||||||
interaction: AutocompleteInteraction,
|
interaction: AutocompleteInteraction,
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { ChatInputCommandInteraction } from 'discord.js';
|
import { ChatInputCommandInteraction } from 'discord.js';
|
||||||
import { Logger } from 'pino';
|
import { Logger } from 'pino';
|
||||||
|
import { BaseSlashCommandInteraction } from '../classes/interactions';
|
||||||
import loggerModule from '../services/logger';
|
import loggerModule from '../services/logger';
|
||||||
import { ExtendedClient } from '../types/clientTypes';
|
import { ExtendedClient } from '../types/clientTypes';
|
||||||
import { BaseSlashCommandInteraction } from '../classes/interactions';
|
import { checkChannelPermissionViewable } from '../utils/validation/permissionValidator';
|
||||||
import { cannotSendMessageInChannel } from '../utils/validation/permissionValidator';
|
|
||||||
|
|
||||||
export const handleCommand = async (
|
export const handleCommand = async (
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
@@ -20,9 +20,7 @@ export const handleCommand = async (
|
|||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
logger.debug('Interaction deferred.');
|
logger.debug('Interaction deferred.');
|
||||||
|
|
||||||
if (await cannotSendMessageInChannel({ interaction, executionId })) {
|
await checkChannelPermissionViewable({ interaction, executionId });
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const slashCommand: BaseSlashCommandInteraction = client.slashCommandInteractions!.get(
|
const slashCommand: BaseSlashCommandInteraction = client.slashCommandInteractions!.get(
|
||||||
interactionIdentifier
|
interactionIdentifier
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { MessageComponentInteraction } from 'discord.js';
|
import { MessageComponentInteraction } from 'discord.js';
|
||||||
import { Logger } from 'pino';
|
import { Logger } from 'pino';
|
||||||
|
import { BaseComponentInteraction } from '../classes/interactions';
|
||||||
import loggerModule from '../services/logger';
|
import loggerModule from '../services/logger';
|
||||||
import { ExtendedClient } from '../types/clientTypes';
|
import { ExtendedClient } from '../types/clientTypes';
|
||||||
import { BaseComponentInteraction } from '../classes/interactions';
|
import { checkChannelPermissionViewable } from '../utils/validation/permissionValidator';
|
||||||
import { cannotSendMessageInChannel } from '../utils/validation/permissionValidator';
|
|
||||||
|
|
||||||
export const handleComponent = async (
|
export const handleComponent = async (
|
||||||
interaction: MessageComponentInteraction,
|
interaction: MessageComponentInteraction,
|
||||||
@@ -25,9 +25,7 @@ export const handleComponent = async (
|
|||||||
|
|
||||||
logger.debug(`Parsed componentId '${componentId}' from identifier '${interactionIdentifier}'.`);
|
logger.debug(`Parsed componentId '${componentId}' from identifier '${interactionIdentifier}'.`);
|
||||||
|
|
||||||
if (await cannotSendMessageInChannel({ interaction, executionId })) {
|
await checkChannelPermissionViewable({ interaction, executionId });
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const component: BaseComponentInteraction = client.componentInteractions!.get(
|
const component: BaseComponentInteraction = client.componentInteractions!.get(
|
||||||
componentId
|
componentId
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ import {
|
|||||||
MessageComponentInteraction
|
MessageComponentInteraction
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
import { Logger } from 'pino';
|
import { Logger } from 'pino';
|
||||||
|
import { CustomError, InteractionValidationError } from '../classes/interactions';
|
||||||
import loggerModule from '../services/logger';
|
import loggerModule from '../services/logger';
|
||||||
import { BotOptions, EmbedOptions } from '../types/configTypes';
|
import { BotOptions, EmbedOptions } from '../types/configTypes';
|
||||||
import { CustomError } from '../classes/interactions';
|
|
||||||
|
|
||||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||||
const botOptions: BotOptions = config.get('botOptions');
|
const botOptions: BotOptions = config.get('botOptions');
|
||||||
@@ -28,6 +28,13 @@ export const handleError = async (
|
|||||||
executionId: executionId
|
executionId: executionId
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (error instanceof InteractionValidationError) {
|
||||||
|
logger.debug(
|
||||||
|
`Interaction validation error '${error.message}' while handling interaction '${interactionIdentifier}'.`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Extract replies for embeds
|
// TODO: Extract replies for embeds
|
||||||
const errorReply: InteractionReplyOptions = {
|
const errorReply: InteractionReplyOptions = {
|
||||||
embeds: [
|
embeds: [
|
||||||
|
|||||||
+1
-3
@@ -1,9 +1,7 @@
|
|||||||
import 'dotenv/config';
|
|
||||||
|
|
||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { Client, Shard, ShardEvents, ShardingManager, ShardingManagerOptions } from 'discord.js';
|
import { Client, Shard, ShardEvents, ShardingManager, ShardingManagerOptions } from 'discord.js';
|
||||||
|
import 'dotenv/config';
|
||||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||||
|
|
||||||
import { Logger } from 'pino';
|
import { Logger } from 'pino';
|
||||||
import loggerModule from './services/logger';
|
import loggerModule from './services/logger';
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { LyricsData, lyricsExtractor } from '@discord-player/extractor';
|
import { LyricsData, lyricsExtractor } from '@discord-player/extractor';
|
||||||
import { Player, SearchResult, useMainPlayer } from 'discord-player';
|
import { Player, SearchResult, useMainPlayer } from 'discord-player';
|
||||||
import { ApplicationCommandOptionChoiceData } from 'discord.js';
|
import { ApplicationCommandOptionChoiceData } from 'discord.js';
|
||||||
import { BaseAutocompleteParams, BaseAutocompleteReturnType } from '../../types/interactionTypes';
|
|
||||||
import { BaseAutocompleteInteraction } from '../../classes/interactions';
|
import { BaseAutocompleteInteraction } from '../../classes/interactions';
|
||||||
|
import { BaseAutocompleteParams, BaseAutocompleteReturnType } from '../../types/interactionTypes';
|
||||||
|
|
||||||
// TODO: create type for recent query object
|
// TODO: create type for recent query object
|
||||||
const recentQueries = new Map();
|
const recentQueries = new Map();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Player, SearchResult, useMainPlayer } from 'discord-player';
|
import { Player, SearchResult, useMainPlayer } from 'discord-player';
|
||||||
import { ApplicationCommandOptionChoiceData } from 'discord.js';
|
import { ApplicationCommandOptionChoiceData } from 'discord.js';
|
||||||
import { BaseAutocompleteParams, BaseAutocompleteReturnType } from '../../types/interactionTypes';
|
|
||||||
import { BaseAutocompleteInteraction } from '../../classes/interactions';
|
import { BaseAutocompleteInteraction } from '../../classes/interactions';
|
||||||
|
import { BaseAutocompleteParams, BaseAutocompleteReturnType } from '../../types/interactionTypes';
|
||||||
|
|
||||||
// TODO: create type for recent query object
|
// TODO: create type for recent query object
|
||||||
const recentQueries = new Map();
|
const recentQueries = new Map();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { EmbedBuilder, SlashCommandBuilder, SlashCommandNumberOption, SlashCommandStringOption } from 'discord.js';
|
import { EmbedBuilder, SlashCommandBuilder, SlashCommandNumberOption, SlashCommandStringOption } from 'discord.js';
|
||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
|
||||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||||
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
|
|
||||||
class HelpCommand extends BaseSlashCommandInteraction {
|
class HelpCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import { EmbedBuilder, Guild, SlashCommandBuilder } from 'discord.js';
|
|||||||
import osu from 'node-os-utils';
|
import osu from 'node-os-utils';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { version } from '../../../../package.json';
|
import { version } from '../../../../package.json';
|
||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
|
||||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||||
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { getUptimeFormatted } from '../../../utils/system/getUptimeFormatted';
|
import { getUptimeFormatted } from '../../../utils/system/getUptimeFormatted';
|
||||||
|
|
||||||
class StatusCommand extends BaseSlashCommandInteraction {
|
class StatusCommand extends BaseSlashCommandInteraction {
|
||||||
|
|||||||
@@ -7,24 +7,47 @@ import {
|
|||||||
APIStringSelectComponent,
|
APIStringSelectComponent,
|
||||||
ButtonBuilder,
|
ButtonBuilder,
|
||||||
ButtonStyle,
|
ButtonStyle,
|
||||||
|
ChatInputCommandInteraction,
|
||||||
ComponentType,
|
ComponentType,
|
||||||
EmbedBuilder,
|
EmbedBuilder,
|
||||||
SlashCommandBuilder,
|
SlashCommandBuilder,
|
||||||
StringSelectMenuBuilder,
|
StringSelectMenuBuilder,
|
||||||
StringSelectMenuOptionBuilder
|
StringSelectMenuOptionBuilder
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
|
import { Logger } from 'pino';
|
||||||
|
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||||
import { FFmpegFilterOption, FFmpegFilterOptions } from '../../../types/configTypes';
|
import { FFmpegFilterOption, FFmpegFilterOptions } from '../../../types/configTypes';
|
||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
import { queueDoesNotExist, queueNoCurrentTrack } from '../../../utils/validation/queueValidator';
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
|
||||||
|
|
||||||
const ffmpegFilterOptions: FFmpegFilterOptions = config.get('ffmpegFilterOptions');
|
const ffmpegFilterOptions: FFmpegFilterOptions = config.get('ffmpegFilterOptions');
|
||||||
|
|
||||||
class FiltersCommand extends BaseSlashCommandInteraction {
|
class FiltersCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
const data = new SlashCommandBuilder().setName('filters').setDescription('Toggle various audio filters.');
|
const data = new SlashCommandBuilder()
|
||||||
|
.setName('filters')
|
||||||
|
.setDescription('Toggle various audio filters.')
|
||||||
|
.addStringOption((option) =>
|
||||||
|
option
|
||||||
|
.setName('type')
|
||||||
|
.setDescription('Audio filtering type to use.')
|
||||||
|
.setRequired(false)
|
||||||
|
.addChoices(
|
||||||
|
{ name: 'FFmpeg', value: 'FFmpeg' },
|
||||||
|
{ name: 'Biquad', value: 'Biquad' },
|
||||||
|
{ name: 'Equalizer', value: 'Equalizer' },
|
||||||
|
{ name: 'Disable', value: 'Disable' }
|
||||||
|
)
|
||||||
|
);
|
||||||
super(data);
|
super(data);
|
||||||
|
|
||||||
|
this.validators = [
|
||||||
|
(args) => checkInVoiceChannel(args),
|
||||||
|
(args) => checkSameVoiceChannel(args),
|
||||||
|
(args) => checkQueueExists(args),
|
||||||
|
(args) => checkQueueCurrentTrack(args)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
@@ -33,19 +56,35 @@ class FiltersCommand extends BaseSlashCommandInteraction {
|
|||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
const validators = [
|
await this.runValidators({ interaction, queue, executionId });
|
||||||
() => notInVoiceChannel({ interaction, executionId }),
|
|
||||||
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
|
||||||
() => queueDoesNotExist({ interaction, queue, executionId }),
|
|
||||||
() => queueNoCurrentTrack({ interaction, queue, executionId })
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const validator of validators) {
|
const filterProvider: string = interaction.options.getString('type') || 'FFmpeg';
|
||||||
if (await validator()) {
|
|
||||||
return;
|
switch (filterProvider) {
|
||||||
}
|
case 'ffmpeg':
|
||||||
|
logger.info('Handling ffmpeg filters.');
|
||||||
|
return await this.handleFfmpegFilters(queue, logger, interaction);
|
||||||
|
case 'biquad':
|
||||||
|
logger.info('Biquad filters are not yet implemented.');
|
||||||
|
break;
|
||||||
|
case 'equalizer':
|
||||||
|
logger.info('Equalizer filters are not yet implemented.');
|
||||||
|
break;
|
||||||
|
case 'disable':
|
||||||
|
logger.info('Disabling filters.');
|
||||||
|
if (queue.filters.ffmpeg.filters.length > 0) {
|
||||||
|
queue.filters.ffmpeg.setFilters(false);
|
||||||
|
logger.debug('Reset queue filters.');
|
||||||
|
}
|
||||||
|
logger.info('Response not yet implemented.');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async handleFfmpegFilters(
|
||||||
|
queue: GuildQueue<unknown>,
|
||||||
|
logger: Logger,
|
||||||
|
interaction: ChatInputCommandInteraction
|
||||||
|
) {
|
||||||
const filterOptions: StringSelectMenuOptionBuilder[] = [];
|
const filterOptions: StringSelectMenuOptionBuilder[] = [];
|
||||||
|
|
||||||
ffmpegFilterOptions.availableFilters.forEach((filter: FFmpegFilterOption) => {
|
ffmpegFilterOptions.availableFilters.forEach((filter: FFmpegFilterOption) => {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { GuildQueue, useQueue } from 'discord-player';
|
import { GuildQueue, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
|
||||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||||
import { queueDoesNotExist } from '../../../utils/validation/queueValidator';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
|
|
||||||
class LeaveCommand extends BaseSlashCommandInteraction {
|
class LeaveCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -11,6 +11,12 @@ class LeaveCommand extends BaseSlashCommandInteraction {
|
|||||||
.setName('leave')
|
.setName('leave')
|
||||||
.setDescription('Clear the queue and remove bot from voice channel.');
|
.setDescription('Clear the queue and remove bot from voice channel.');
|
||||||
super(data);
|
super(data);
|
||||||
|
|
||||||
|
this.validators = [
|
||||||
|
(args) => checkInVoiceChannel(args),
|
||||||
|
(args) => checkSameVoiceChannel(args),
|
||||||
|
(args) => checkQueueExists(args)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
@@ -19,39 +25,18 @@ class LeaveCommand extends BaseSlashCommandInteraction {
|
|||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
const validators = [
|
await this.runValidators({ interaction, queue, executionId });
|
||||||
() => notInVoiceChannel({ interaction, executionId }),
|
|
||||||
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
|
||||||
() => queueDoesNotExist({ interaction, queue, executionId })
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const validator of validators) {
|
logger.info('Validators passed, clearing queue.');
|
||||||
if (await validator()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!queue.deleted) {
|
logger.debug('Deleting queue.');
|
||||||
queue.delete();
|
await this.deleteQueue(queue);
|
||||||
logger.debug('Deleted the queue.');
|
|
||||||
}
|
|
||||||
|
|
||||||
let authorName: string;
|
|
||||||
|
|
||||||
if (interaction.member instanceof GuildMember) {
|
|
||||||
authorName = interaction.member.nickname || interaction.user.username;
|
|
||||||
} else {
|
|
||||||
authorName = interaction.user.username;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor(await this.getEmbedUserAuthor(interaction))
|
||||||
name: authorName,
|
|
||||||
iconURL: interaction.user.avatarURL() || this.embedOptions.info.fallbackIconUrl
|
|
||||||
})
|
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.success} Leaving channel**\nCleared the track queue and left voice channel.\n\nTo play more music, use the **\`/play\`** command!`
|
`**${this.embedOptions.icons.success} Leaving channel**\nCleared the track queue and left voice channel.\n\nTo play more music, use the **\`/play\`** command!`
|
||||||
)
|
)
|
||||||
@@ -59,6 +44,12 @@ class LeaveCommand extends BaseSlashCommandInteraction {
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected async deleteQueue(queue: GuildQueue): Promise<void> {
|
||||||
|
if (!queue.deleted) {
|
||||||
|
queue.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new LeaveCommand();
|
export default new LeaveCommand();
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import { GuildQueue, QueueRepeatMode, useQueue } from 'discord-player';
|
import { GuildQueue, QueueRepeatMode, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder, SlashCommandStringOption } from 'discord.js';
|
import { EmbedBuilder, SlashCommandBuilder, SlashCommandStringOption } from 'discord.js';
|
||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
|
||||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||||
import { queueDoesNotExist } from '../../../utils/validation/queueValidator';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
|
|
||||||
class LoopCommand extends BaseSlashCommandInteraction {
|
class LoopCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -23,6 +23,12 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
super(data);
|
super(data);
|
||||||
|
|
||||||
|
this.validators = [
|
||||||
|
(args) => checkInVoiceChannel(args),
|
||||||
|
(args) => checkSameVoiceChannel(args),
|
||||||
|
(args) => checkQueueExists(args)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
@@ -31,17 +37,7 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
|||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
const validators = [
|
await this.runValidators({ interaction, queue, executionId });
|
||||||
() => notInVoiceChannel({ interaction, executionId }),
|
|
||||||
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
|
||||||
() => queueDoesNotExist({ interaction, queue, executionId })
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const validator of validators) {
|
|
||||||
if (await validator()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: create type for loop modes formatted
|
// TODO: create type for loop modes formatted
|
||||||
const loopModesFormatted: Map<number, string> = new Map([
|
const loopModesFormatted: Map<number, string> = new Map([
|
||||||
@@ -110,14 +106,6 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let authorName: string;
|
|
||||||
|
|
||||||
if (interaction.member instanceof GuildMember) {
|
|
||||||
authorName = interaction.member.nickname || interaction.user.username;
|
|
||||||
} else {
|
|
||||||
authorName = interaction.user.username;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (queue.repeatMode === 0) {
|
if (queue.repeatMode === 0) {
|
||||||
logger.debug('Disabled loop mode.');
|
logger.debug('Disabled loop mode.');
|
||||||
|
|
||||||
@@ -126,10 +114,7 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
|||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor(await this.getEmbedUserAuthor(interaction))
|
||||||
name: authorName,
|
|
||||||
iconURL: interaction.user.avatarURL() || this.embedOptions.info.fallbackIconUrl
|
|
||||||
})
|
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.success} Loop mode disabled**\nChanging loop mode from **\`${currentModeUserString}\`** to **\`${modeUserString}\`**.\n\nThe ${currentModeUserString} will no longer play on repeat!`
|
`**${this.embedOptions.icons.success} Loop mode disabled**\nChanging loop mode from **\`${currentModeUserString}\`** to **\`${modeUserString}\`**.\n\nThe ${currentModeUserString} will no longer play on repeat!`
|
||||||
)
|
)
|
||||||
@@ -145,10 +130,7 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
|||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor(await this.getEmbedUserAuthor(interaction))
|
||||||
name: authorName,
|
|
||||||
iconURL: interaction.user.avatarURL() || this.embedOptions.info.fallbackIconUrl
|
|
||||||
})
|
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.autoplaying} Loop mode changed**\nChanging loop mode from **\`${currentModeUserString}\`** to **\`${modeUserString}\`**.\n\nWhen the queue is empty, similar tracks will start playing!`
|
`**${this.embedOptions.icons.autoplaying} Loop mode changed**\nChanging loop mode from **\`${currentModeUserString}\`** to **\`${modeUserString}\`**.\n\nWhen the queue is empty, similar tracks will start playing!`
|
||||||
)
|
)
|
||||||
@@ -163,10 +145,7 @@ class LoopCommand extends BaseSlashCommandInteraction {
|
|||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor(await this.getEmbedUserAuthor(interaction))
|
||||||
name: authorName,
|
|
||||||
iconURL: interaction.user.avatarURL() || this.embedOptions.info.fallbackIconUrl
|
|
||||||
})
|
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.looping} Loop mode changed**\nChanging loop mode from **\`${currentModeUserString}\`** to **\`${modeUserString}\`**.\n\nThe ${modeUserString} will now play on repeat!`
|
`**${this.embedOptions.icons.looping} Loop mode changed**\nChanging loop mode from **\`${currentModeUserString}\`** to **\`${modeUserString}\`**.\n\nThe ${modeUserString} will now play on repeat!`
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { LyricsData, lyricsExtractor } from '@discord-player/extractor';
|
import { LyricsData, lyricsExtractor } from '@discord-player/extractor';
|
||||||
import { GuildQueue, Player, QueryType, useMainPlayer, useQueue } from 'discord-player';
|
import { GuildQueue, Player, QueryType, useMainPlayer, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
|
||||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||||
import { queueDoesNotExist, queueNoCurrentTrack } from '../../../utils/validation/queueValidator';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
|
|
||||||
class LyricsCommand extends BaseSlashCommandInteraction {
|
class LyricsCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -21,29 +21,26 @@ class LyricsCommand extends BaseSlashCommandInteraction {
|
|||||||
.setAutocomplete(true)
|
.setAutocomplete(true)
|
||||||
);
|
);
|
||||||
super(data);
|
super(data);
|
||||||
|
|
||||||
|
this.validators = [
|
||||||
|
(args) => checkInVoiceChannel(args),
|
||||||
|
(args) => checkSameVoiceChannel(args),
|
||||||
|
(args) => checkQueueExists(args),
|
||||||
|
(args) => checkQueueCurrentTrack(args)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
const query: string = interaction.options.getString('query')!;
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
|
const query: string = interaction.options.getString('query')!;
|
||||||
let geniusSearchQuery: string = '';
|
let geniusSearchQuery: string = '';
|
||||||
|
|
||||||
if (!query) {
|
if (!query) {
|
||||||
const validators = [
|
await this.runValidators({ interaction, queue, executionId });
|
||||||
() => notInVoiceChannel({ interaction, executionId }),
|
|
||||||
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
|
||||||
() => queueDoesNotExist({ interaction, queue, executionId }),
|
|
||||||
() => queueNoCurrentTrack({ interaction, queue, executionId })
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const validator of validators) {
|
|
||||||
if (await validator()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
geniusSearchQuery = queue.currentTrack!.title.slice(0, 50);
|
geniusSearchQuery = queue.currentTrack!.title.slice(0, 50);
|
||||||
|
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ import {
|
|||||||
EmbedBuilder,
|
EmbedBuilder,
|
||||||
SlashCommandBuilder
|
SlashCommandBuilder
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
|
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||||
import { PlayerOptions } from '../../../types/configTypes';
|
import { PlayerOptions } from '../../../types/configTypes';
|
||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType, TrackMetadata } from '../../../types/interactionTypes';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType, TrackMetadata } from '../../../types/interactionTypes';
|
||||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
import { queueDoesNotExist, queueNoCurrentTrack } from '../../../utils/validation/queueValidator';
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
|
||||||
|
|
||||||
const playerOptions: PlayerOptions = config.get('playerOptions');
|
const playerOptions: PlayerOptions = config.get('playerOptions');
|
||||||
|
|
||||||
@@ -24,6 +24,13 @@ class NowPlayingCommand extends BaseSlashCommandInteraction {
|
|||||||
.setName('nowplaying')
|
.setName('nowplaying')
|
||||||
.setDescription('Show information about the current track.');
|
.setDescription('Show information about the current track.');
|
||||||
super(data);
|
super(data);
|
||||||
|
|
||||||
|
this.validators = [
|
||||||
|
(args) => checkInVoiceChannel(args),
|
||||||
|
(args) => checkSameVoiceChannel(args),
|
||||||
|
(args) => checkQueueExists(args),
|
||||||
|
(args) => checkQueueCurrentTrack(args)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
@@ -32,19 +39,7 @@ class NowPlayingCommand extends BaseSlashCommandInteraction {
|
|||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
// TODO: define TS type for validators
|
await this.runValidators({ interaction, queue, executionId });
|
||||||
const validators = [
|
|
||||||
() => notInVoiceChannel({ interaction, executionId }),
|
|
||||||
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
|
||||||
() => queueDoesNotExist({ interaction, queue, executionId }),
|
|
||||||
() => queueNoCurrentTrack({ interaction, queue, executionId })
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const validator of validators) {
|
|
||||||
if (await validator()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const sourceStringsFormatted: Map<string, string> = new Map([
|
const sourceStringsFormatted: Map<string, string> = new Map([
|
||||||
['youtube', 'YouTube'],
|
['youtube', 'YouTube'],
|
||||||
@@ -137,10 +132,7 @@ class NowPlayingCommand extends BaseSlashCommandInteraction {
|
|||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor(await this.getEmbedQueueAuthor(interaction, queue))
|
||||||
name: `Channel: ${queue.channel!.name} (${queue.channel!.bitrate / 1000}kbps)`,
|
|
||||||
iconURL: interaction.guild!.iconURL() || this.embedOptions.info.fallbackIconUrl
|
|
||||||
})
|
|
||||||
.setDescription(
|
.setDescription(
|
||||||
(queue.node.isPaused()
|
(queue.node.isPaused()
|
||||||
? '**Currently Paused**\n'
|
? '**Currently Paused**\n'
|
||||||
|
|||||||
@@ -1,15 +1,21 @@
|
|||||||
import { GuildQueue, Track, useQueue } from 'discord-player';
|
import { GuildQueue, Track, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
|
|
||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
|
||||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||||
import { queueDoesNotExist, queueNoCurrentTrack } from '../../../utils/validation/queueValidator';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
|
|
||||||
class PauseCommand extends BaseSlashCommandInteraction {
|
class PauseCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
const data = new SlashCommandBuilder().setName('pause').setDescription('Toggle pause for the current track.');
|
const data = new SlashCommandBuilder().setName('pause').setDescription('Toggle pause for the current track.');
|
||||||
super(data);
|
super(data);
|
||||||
|
|
||||||
|
this.validators = [
|
||||||
|
(args) => checkInVoiceChannel(args),
|
||||||
|
(args) => checkSameVoiceChannel(args),
|
||||||
|
(args) => checkQueueExists(args),
|
||||||
|
(args) => checkQueueCurrentTrack(args)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
@@ -18,18 +24,7 @@ class PauseCommand extends BaseSlashCommandInteraction {
|
|||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
const validators = [
|
await this.runValidators({ interaction, queue, executionId });
|
||||||
() => notInVoiceChannel({ interaction, executionId }),
|
|
||||||
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
|
||||||
() => queueDoesNotExist({ interaction, queue, executionId }),
|
|
||||||
() => queueNoCurrentTrack({ interaction, queue, executionId })
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const validator of validators) {
|
|
||||||
if (await validator()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const currentTrack: Track = queue.currentTrack!;
|
const currentTrack: Track = queue.currentTrack!;
|
||||||
|
|
||||||
@@ -46,22 +41,11 @@ class PauseCommand extends BaseSlashCommandInteraction {
|
|||||||
queue.node.setPaused(!queue.node.isPaused());
|
queue.node.setPaused(!queue.node.isPaused());
|
||||||
logger.debug(`Set paused state to ${queue.node.isPaused()}.`);
|
logger.debug(`Set paused state to ${queue.node.isPaused()}.`);
|
||||||
|
|
||||||
let authorName: string;
|
|
||||||
|
|
||||||
if (interaction.member instanceof GuildMember) {
|
|
||||||
authorName = interaction.member.nickname || interaction.user.username;
|
|
||||||
} else {
|
|
||||||
authorName = interaction.user.username;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor(await this.getEmbedUserAuthor(interaction))
|
||||||
name: authorName,
|
|
||||||
iconURL: interaction.user.avatarURL() || this.embedOptions.info.fallbackIconUrl
|
|
||||||
})
|
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.pauseResumed} ${
|
`**${this.embedOptions.icons.pauseResumed} ${
|
||||||
queue.node.isPaused() ? 'Paused Track' : 'Resumed track'
|
queue.node.isPaused() ? 'Paused Track' : 'Resumed track'
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
|||||||
import { BaseSlashCommandInteraction, CustomError } from '../../../classes/interactions';
|
import { BaseSlashCommandInteraction, CustomError } from '../../../classes/interactions';
|
||||||
import { PlayerOptions } from '../../../types/configTypes';
|
import { PlayerOptions } from '../../../types/configTypes';
|
||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { cannotJoinVoiceOrTalk } from '../../../utils/validation/permissionValidator';
|
import { checkVoicePermissionJoinAndTalk } from '../../../utils/validation/permissionValidator';
|
||||||
import { transformQuery } from '../../../utils/validation/searchQueryValidator';
|
import { transformQuery } from '../../../utils/validation/searchQueryValidator';
|
||||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
import { checkSameVoiceChannel, checkInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
|
|
||||||
const playerOptions: PlayerOptions = config.get('playerOptions');
|
const playerOptions: PlayerOptions = config.get('playerOptions');
|
||||||
|
|
||||||
@@ -25,26 +25,21 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
|||||||
.setAutocomplete(true)
|
.setAutocomplete(true)
|
||||||
);
|
);
|
||||||
super(data);
|
super(data);
|
||||||
|
|
||||||
|
this.validators = [(args) => checkInVoiceChannel(args)];
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction } = params;
|
const { executionId, interaction } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
|
await this.runValidators({ interaction, executionId });
|
||||||
|
|
||||||
let queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
let queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
if (queue && (await notInSameVoiceChannel({ interaction, queue, executionId }))) {
|
if (queue) {
|
||||||
return;
|
await this.runValidators({ interaction, queue, executionId }, [checkSameVoiceChannel]);
|
||||||
}
|
} else {
|
||||||
|
await this.runValidators({ interaction, executionId }, [checkVoicePermissionJoinAndTalk]);
|
||||||
const validators = [
|
|
||||||
() => notInVoiceChannel({ interaction, executionId }),
|
|
||||||
() => cannotJoinVoiceOrTalk({ interaction, executionId })
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const validator of validators) {
|
|
||||||
if (await validator()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const player = useMainPlayer()!;
|
const player = useMainPlayer()!;
|
||||||
@@ -243,22 +238,11 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
|||||||
if (searchResult.playlist && searchResult.tracks.length > 1) {
|
if (searchResult.playlist && searchResult.tracks.length > 1) {
|
||||||
logger.debug(`Playlist found and added with player.play(). Query: '${query}'`);
|
logger.debug(`Playlist found and added with player.play(). Query: '${query}'`);
|
||||||
|
|
||||||
let authorName: string;
|
|
||||||
|
|
||||||
if (interaction.member instanceof GuildMember) {
|
|
||||||
authorName = interaction.member.nickname || interaction.user.username;
|
|
||||||
} else {
|
|
||||||
authorName = interaction.user.username;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor(await this.getEmbedUserAuthor(interaction))
|
||||||
name: authorName,
|
|
||||||
iconURL: interaction.user.avatarURL() || this.embedOptions.info.fallbackIconUrl
|
|
||||||
})
|
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.success} Added playlist to queue**\n**${durationFormat} [${
|
`**${this.embedOptions.icons.success} Added playlist to queue**\n**${durationFormat} [${
|
||||||
track.title
|
track.title
|
||||||
@@ -275,22 +259,11 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
|||||||
if (queue && queue.currentTrack === track && queue.tracks.data.length === 0) {
|
if (queue && queue.currentTrack === track && queue.tracks.data.length === 0) {
|
||||||
logger.debug(`Track found and added with player.play(), started playing. Query: '${query}'.`);
|
logger.debug(`Track found and added with player.play(), started playing. Query: '${query}'.`);
|
||||||
|
|
||||||
let authorName: string;
|
|
||||||
|
|
||||||
if (interaction.member instanceof GuildMember) {
|
|
||||||
authorName = interaction.member.nickname || interaction.user.username;
|
|
||||||
} else {
|
|
||||||
authorName = interaction.user.username;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor(await this.getEmbedUserAuthor(interaction))
|
||||||
name: authorName,
|
|
||||||
iconURL: interaction.user.avatarURL() || this.embedOptions.info.fallbackIconUrl
|
|
||||||
})
|
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.audioStartedPlaying} Started playing**\n**${durationFormat} [${
|
`**${this.embedOptions.icons.audioStartedPlaying} Started playing**\n**${durationFormat} [${
|
||||||
track.title
|
track.title
|
||||||
@@ -304,22 +277,11 @@ class PlayCommand extends BaseSlashCommandInteraction {
|
|||||||
|
|
||||||
logger.debug(`Track found and added with player.play(), added to queue. Query: '${query}'.`);
|
logger.debug(`Track found and added with player.play(), added to queue. Query: '${query}'.`);
|
||||||
|
|
||||||
let authorName: string;
|
|
||||||
|
|
||||||
if (interaction.member instanceof GuildMember) {
|
|
||||||
authorName = interaction.member.nickname || interaction.user.username;
|
|
||||||
} else {
|
|
||||||
authorName = interaction.user.username;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor(await this.getEmbedUserAuthor(interaction))
|
||||||
name: authorName,
|
|
||||||
iconURL: interaction.user.avatarURL() || this.embedOptions.info.fallbackIconUrl
|
|
||||||
})
|
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`${this.embedOptions.icons.success} **Added to queue**\n**${durationFormat} [${track.title}](${
|
`${this.embedOptions.icons.success} **Added to queue**\n**${durationFormat} [${track.title}](${
|
||||||
track.raw.url ?? track.url
|
track.raw.url ?? track.url
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { GuildQueue, PlayerTimestamp, Track, useQueue } from 'discord-player';
|
import { GuildQueue, PlayerTimestamp, Track, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
|
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||||
import { PlayerOptions } from '../../../types/configTypes';
|
import { PlayerOptions } from '../../../types/configTypes';
|
||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
import { queueDoesNotExist } from '../../../utils/validation/queueValidator';
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
|
||||||
|
|
||||||
const playerOptions: PlayerOptions = config.get('playerOptions');
|
const playerOptions: PlayerOptions = config.get('playerOptions');
|
||||||
|
|
||||||
@@ -18,6 +18,12 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
|||||||
option.setName('page').setDescription('Page number to display for the queue').setMinValue(1)
|
option.setName('page').setDescription('Page number to display for the queue').setMinValue(1)
|
||||||
);
|
);
|
||||||
super(data);
|
super(data);
|
||||||
|
|
||||||
|
this.validators = [
|
||||||
|
(args) => checkInVoiceChannel(args),
|
||||||
|
(args) => checkSameVoiceChannel(args),
|
||||||
|
(args) => checkQueueExists(args)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
@@ -26,17 +32,7 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
|||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
const validators = [
|
await this.runValidators({ interaction, queue, executionId });
|
||||||
() => notInVoiceChannel({ interaction, executionId }),
|
|
||||||
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
|
||||||
() => queueDoesNotExist({ interaction, queue, executionId })
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const validator of validators) {
|
|
||||||
if (await validator()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const pageIndex: number = (interaction.options.getNumber('page') || 1) - 1;
|
const pageIndex: number = (interaction.options.getNumber('page') || 1) - 1;
|
||||||
let queueString: string = '';
|
let queueString: string = '';
|
||||||
@@ -107,10 +103,7 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
|||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor(await this.getEmbedQueueAuthor(interaction, queue))
|
||||||
name: `Channel: ${queue.channel!.name} (${queue.channel!.bitrate / 1000}kbps)`,
|
|
||||||
iconURL: interaction.guild!.iconURL() || this.embedOptions.info.fallbackIconUrl
|
|
||||||
})
|
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`${repeatModeString}` +
|
`${repeatModeString}` +
|
||||||
`**${this.embedOptions.icons.queue} Tracks in queue**\n${queueString}`
|
`**${this.embedOptions.icons.queue} Tracks in queue**\n${queueString}`
|
||||||
@@ -145,10 +138,7 @@ class QueueCommand extends BaseSlashCommandInteraction {
|
|||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor(await this.getEmbedQueueAuthor(interaction, queue))
|
||||||
name: `Channel: ${queue.channel!.name} (${queue.channel!.bitrate / 1000}kbps)`,
|
|
||||||
iconURL: interaction.guild!.iconURL() || this.embedOptions.info.fallbackIconUrl
|
|
||||||
})
|
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.audioPlaying} Now playing**\n` +
|
`**${this.embedOptions.icons.audioPlaying} Now playing**\n` +
|
||||||
(currentTrack
|
(currentTrack
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { GuildQueue, Track, useQueue } from 'discord-player';
|
import { GuildQueue, Track, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
|
||||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||||
import { queueDoesNotExist } from '../../../utils/validation/queueValidator';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
|
|
||||||
class RemoveCommand extends BaseSlashCommandInteraction {
|
class RemoveCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -18,6 +18,12 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
|||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
);
|
);
|
||||||
super(data);
|
super(data);
|
||||||
|
|
||||||
|
this.validators = [
|
||||||
|
(args) => checkInVoiceChannel(args),
|
||||||
|
(args) => checkSameVoiceChannel(args),
|
||||||
|
(args) => checkQueueExists(args)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
@@ -26,17 +32,7 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
|||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
const validators = [
|
await this.runValidators({ interaction, queue, executionId });
|
||||||
() => notInVoiceChannel({ interaction, executionId }),
|
|
||||||
() => queueDoesNotExist({ interaction, queue, executionId }),
|
|
||||||
() => notInSameVoiceChannel({ interaction, queue, executionId })
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const validator of validators) {
|
|
||||||
if (await validator()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const removeTrackNumber: number = interaction.options.getNumber('tracknumber')!;
|
const removeTrackNumber: number = interaction.options.getNumber('tracknumber')!;
|
||||||
|
|
||||||
@@ -67,22 +63,11 @@ class RemoveCommand extends BaseSlashCommandInteraction {
|
|||||||
durationFormat = `${this.embedOptions.icons.liveTrack} \`LIVE\``;
|
durationFormat = `${this.embedOptions.icons.liveTrack} \`LIVE\``;
|
||||||
}
|
}
|
||||||
|
|
||||||
let authorName: string;
|
|
||||||
|
|
||||||
if (interaction.member instanceof GuildMember) {
|
|
||||||
authorName = interaction.member.nickname || interaction.user.username;
|
|
||||||
} else {
|
|
||||||
authorName = interaction.user.username;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor(await this.getEmbedUserAuthor(interaction))
|
||||||
name: authorName,
|
|
||||||
iconURL: interaction.user.avatarURL() || this.embedOptions.info.fallbackIconUrl
|
|
||||||
})
|
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.success} Removed track**\n**${durationFormat} [${
|
`**${this.embedOptions.icons.success} Removed track**\n**${durationFormat} [${
|
||||||
removedTrack.title
|
removedTrack.title
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { GuildQueue, useQueue } from 'discord-player';
|
import { GuildQueue, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
|
||||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||||
import { queueDoesNotExist, queueNoCurrentTrack } from '../../../utils/validation/queueValidator';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
|
|
||||||
class SeekCommand extends BaseSlashCommandInteraction {
|
class SeekCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -14,6 +14,13 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
|||||||
option.setName('duration').setDescription('Duration in format 00:00:00 (HH:mm:ss).').setRequired(true)
|
option.setName('duration').setDescription('Duration in format 00:00:00 (HH:mm:ss).').setRequired(true)
|
||||||
);
|
);
|
||||||
super(data);
|
super(data);
|
||||||
|
|
||||||
|
this.validators = [
|
||||||
|
(args) => checkInVoiceChannel(args),
|
||||||
|
(args) => checkSameVoiceChannel(args),
|
||||||
|
(args) => checkQueueExists(args),
|
||||||
|
(args) => checkQueueCurrentTrack(args)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
@@ -22,18 +29,7 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
|||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
const validators = [
|
await this.runValidators({ interaction, queue, executionId });
|
||||||
() => notInVoiceChannel({ interaction, executionId }),
|
|
||||||
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
|
||||||
() => queueDoesNotExist({ interaction, queue, executionId }),
|
|
||||||
() => queueNoCurrentTrack({ interaction, queue, executionId })
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const validator of validators) {
|
|
||||||
if (await validator()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const durationInput: string = interaction.options.getString('duration')!;
|
const durationInput: string = interaction.options.getString('duration')!;
|
||||||
|
|
||||||
@@ -145,22 +141,11 @@ class SeekCommand extends BaseSlashCommandInteraction {
|
|||||||
queue.node.seek(durationInMilliseconds);
|
queue.node.seek(durationInMilliseconds);
|
||||||
logger.debug(`Seeked to '${durationString}' in current track.`);
|
logger.debug(`Seeked to '${durationString}' in current track.`);
|
||||||
|
|
||||||
let authorName: string;
|
|
||||||
|
|
||||||
if (interaction.member instanceof GuildMember) {
|
|
||||||
authorName = interaction.member.nickname || interaction.user.username;
|
|
||||||
} else {
|
|
||||||
authorName = interaction.user.username;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor(await this.getEmbedUserAuthor(interaction))
|
||||||
name: authorName,
|
|
||||||
iconURL: interaction.user.avatarURL() || this.embedOptions.info.fallbackIconUrl
|
|
||||||
})
|
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.success} Seeking to duration**\nSeeking to **\`${durationString}\`** in current track.`
|
`**${this.embedOptions.icons.success} Seeking to duration**\nSeeking to **\`${durationString}\`** in current track.`
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { GuildQueue, useQueue } from 'discord-player';
|
import { GuildQueue, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
|
||||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||||
import { queueDoesNotExist, queueIsEmpty } from '../../../utils/validation/queueValidator';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
import { checkQueueEmpty, checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
|
|
||||||
class ShuffleCommand extends BaseSlashCommandInteraction {
|
class ShuffleCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -11,6 +11,13 @@ class ShuffleCommand extends BaseSlashCommandInteraction {
|
|||||||
.setName('shuffle')
|
.setName('shuffle')
|
||||||
.setDescription('Randomly shuffle all tracks in the queue.');
|
.setDescription('Randomly shuffle all tracks in the queue.');
|
||||||
super(data);
|
super(data);
|
||||||
|
|
||||||
|
this.validators = [
|
||||||
|
(args) => checkInVoiceChannel(args),
|
||||||
|
(args) => checkSameVoiceChannel(args),
|
||||||
|
(args) => checkQueueExists(args),
|
||||||
|
(args) => checkQueueEmpty(args)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
@@ -19,38 +26,16 @@ class ShuffleCommand extends BaseSlashCommandInteraction {
|
|||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
const validators = [
|
await this.runValidators({ interaction, queue, executionId });
|
||||||
() => notInVoiceChannel({ interaction, executionId }),
|
|
||||||
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
|
||||||
() => queueDoesNotExist({ interaction, queue, executionId }),
|
|
||||||
() => queueIsEmpty({ interaction, queue, executionId })
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const validator of validators) {
|
|
||||||
if (await validator()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
queue.tracks.shuffle();
|
queue.tracks.shuffle();
|
||||||
logger.debug('Shuffled queue tracks.');
|
logger.debug('Shuffled queue tracks.');
|
||||||
|
|
||||||
let authorName: string;
|
|
||||||
|
|
||||||
if (interaction.member instanceof GuildMember) {
|
|
||||||
authorName = interaction.member.nickname || interaction.user.username;
|
|
||||||
} else {
|
|
||||||
authorName = interaction.user.username;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor(await this.getEmbedUserAuthor(interaction))
|
||||||
name: authorName,
|
|
||||||
iconURL: interaction.user.avatarURL() || this.embedOptions.info.fallbackIconUrl
|
|
||||||
})
|
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.shuffled} Shuffled queue tracks**\nThe **${queue.tracks.data.length}** tracks in the queue has been shuffled.\n\nView the new queue order with **\`/queue\`**.`
|
`**${this.embedOptions.icons.shuffled} Shuffled queue tracks**\nThe **${queue.tracks.data.length}** tracks in the queue has been shuffled.\n\nView the new queue order with **\`/queue\`**.`
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { GuildQueue, Track, useQueue } from 'discord-player';
|
import { GuildQueue, Track, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
|
||||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||||
import { queueDoesNotExist, queueNoCurrentTrack } from '../../../utils/validation/queueValidator';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
import { checkQueueCurrentTrack, checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
|
|
||||||
class SkipCommand extends BaseSlashCommandInteraction {
|
class SkipCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -14,6 +14,13 @@ class SkipCommand extends BaseSlashCommandInteraction {
|
|||||||
option.setName('tracknumber').setDescription('The position in queue to skip to.').setMinValue(1)
|
option.setName('tracknumber').setDescription('The position in queue to skip to.').setMinValue(1)
|
||||||
);
|
);
|
||||||
super(data);
|
super(data);
|
||||||
|
|
||||||
|
this.validators = [
|
||||||
|
(args) => checkInVoiceChannel(args),
|
||||||
|
(args) => checkSameVoiceChannel(args),
|
||||||
|
(args) => checkQueueExists(args),
|
||||||
|
(args) => checkQueueCurrentTrack(args)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
@@ -22,18 +29,7 @@ class SkipCommand extends BaseSlashCommandInteraction {
|
|||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
const validators = [
|
await this.runValidators({ interaction, queue, executionId });
|
||||||
() => notInVoiceChannel({ interaction, executionId }),
|
|
||||||
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
|
||||||
() => queueDoesNotExist({ interaction, queue, executionId }),
|
|
||||||
() => queueNoCurrentTrack({ interaction, queue, executionId })
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const validator of validators) {
|
|
||||||
if (await validator()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const skipToTrack: number = interaction.options.getNumber('tracknumber')!;
|
const skipToTrack: number = interaction.options.getNumber('tracknumber')!;
|
||||||
|
|
||||||
@@ -67,22 +63,11 @@ class SkipCommand extends BaseSlashCommandInteraction {
|
|||||||
queue.node.skipTo(skipToTrack - 1);
|
queue.node.skipTo(skipToTrack - 1);
|
||||||
logger.debug('Skipped to specified track number.');
|
logger.debug('Skipped to specified track number.');
|
||||||
|
|
||||||
let authorName: string;
|
|
||||||
|
|
||||||
if (interaction.member instanceof GuildMember) {
|
|
||||||
authorName = interaction.member.nickname || interaction.user.username;
|
|
||||||
} else {
|
|
||||||
authorName = interaction.user.username;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor(await this.getEmbedUserAuthor(interaction))
|
||||||
name: authorName,
|
|
||||||
iconURL: interaction.user.avatarURL() || this.embedOptions.info.fallbackIconUrl
|
|
||||||
})
|
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.skipped} Skipped track**\n**${durationFormat} [${
|
`**${this.embedOptions.icons.skipped} Skipped track**\n**${durationFormat} [${
|
||||||
skippedTrack.title
|
skippedTrack.title
|
||||||
@@ -138,22 +123,11 @@ class SkipCommand extends BaseSlashCommandInteraction {
|
|||||||
|
|
||||||
const repeatModeString: string = queue.repeatMode === 0 ? '' : getRepeatModeMessage(queue.repeatMode);
|
const repeatModeString: string = queue.repeatMode === 0 ? '' : getRepeatModeMessage(queue.repeatMode);
|
||||||
|
|
||||||
let authorName: string;
|
|
||||||
|
|
||||||
if (interaction.member instanceof GuildMember) {
|
|
||||||
authorName = interaction.member.nickname || interaction.user.username;
|
|
||||||
} else {
|
|
||||||
authorName = interaction.user.username;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor(await this.getEmbedUserAuthor(interaction))
|
||||||
name: authorName,
|
|
||||||
iconURL: interaction.user.avatarURL() || this.embedOptions.info.fallbackIconUrl
|
|
||||||
})
|
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.skipped} Skipped track**\n**${durationFormat} [${
|
`**${this.embedOptions.icons.skipped} Skipped track**\n**${durationFormat} [${
|
||||||
skippedTrack.title
|
skippedTrack.title
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { GuildQueue, useQueue } from 'discord-player';
|
import { GuildQueue, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
|
||||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||||
import { queueDoesNotExist } from '../../../utils/validation/queueValidator';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
|
|
||||||
class StopCommand extends BaseSlashCommandInteraction {
|
class StopCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -11,6 +11,12 @@ class StopCommand extends BaseSlashCommandInteraction {
|
|||||||
.setName('stop')
|
.setName('stop')
|
||||||
.setDescription('Clear the queue and stop playing audio.');
|
.setDescription('Clear the queue and stop playing audio.');
|
||||||
super(data);
|
super(data);
|
||||||
|
|
||||||
|
this.validators = [
|
||||||
|
(args) => checkInVoiceChannel(args),
|
||||||
|
(args) => checkSameVoiceChannel(args),
|
||||||
|
(args) => checkQueueExists(args)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
@@ -19,17 +25,7 @@ class StopCommand extends BaseSlashCommandInteraction {
|
|||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
const validators = [
|
await this.runValidators({ interaction, queue, executionId });
|
||||||
() => notInVoiceChannel({ interaction, executionId }),
|
|
||||||
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
|
||||||
() => queueDoesNotExist({ interaction, queue, executionId })
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const validator of validators) {
|
|
||||||
if (await validator()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!queue.deleted) {
|
if (!queue.deleted) {
|
||||||
queue.setRepeatMode(0);
|
queue.setRepeatMode(0);
|
||||||
@@ -38,22 +34,11 @@ class StopCommand extends BaseSlashCommandInteraction {
|
|||||||
logger.debug('Cleared and stopped the queue.');
|
logger.debug('Cleared and stopped the queue.');
|
||||||
}
|
}
|
||||||
|
|
||||||
let authorName: string;
|
|
||||||
|
|
||||||
if (interaction.member instanceof GuildMember) {
|
|
||||||
authorName = interaction.member.nickname || interaction.user.username;
|
|
||||||
} else {
|
|
||||||
authorName = interaction.user.username;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor(await this.getEmbedUserAuthor(interaction))
|
||||||
name: authorName,
|
|
||||||
iconURL: interaction.user.avatarURL() || this.embedOptions.info.fallbackIconUrl
|
|
||||||
})
|
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.success} Stopped playing**\nStopped playing audio and cleared the track queue.\n\nTo play more music, use the **\`/play\`** command!`
|
`**${this.embedOptions.icons.success} Stopped playing**\nStopped playing audio and cleared the track queue.\n\nTo play more music, use the **\`/play\`** command!`
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { GuildQueue, useQueue } from 'discord-player';
|
import { GuildQueue, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
|
||||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||||
import { queueDoesNotExist } from '../../../utils/validation/queueValidator';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
import { checkQueueExists } from '../../../utils/validation/queueValidator';
|
||||||
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../../utils/validation/voiceChannelValidator';
|
||||||
|
|
||||||
class VolumeCommand extends BaseSlashCommandInteraction {
|
class VolumeCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -18,6 +18,12 @@ class VolumeCommand extends BaseSlashCommandInteraction {
|
|||||||
.setMaxValue(100)
|
.setMaxValue(100)
|
||||||
);
|
);
|
||||||
super(data);
|
super(data);
|
||||||
|
|
||||||
|
this.validators = [
|
||||||
|
(args) => checkInVoiceChannel(args),
|
||||||
|
(args) => checkSameVoiceChannel(args),
|
||||||
|
(args) => checkQueueExists(args)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
@@ -26,17 +32,7 @@ class VolumeCommand extends BaseSlashCommandInteraction {
|
|||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
const validators = [
|
await this.runValidators({ interaction, queue, executionId });
|
||||||
() => notInVoiceChannel({ interaction, executionId }),
|
|
||||||
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
|
||||||
() => queueDoesNotExist({ interaction, queue, executionId })
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const validator of validators) {
|
|
||||||
if (await validator()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const volume: number = interaction.options.getNumber('percentage')!;
|
const volume: number = interaction.options.getNumber('percentage')!;
|
||||||
|
|
||||||
@@ -76,23 +72,12 @@ class VolumeCommand extends BaseSlashCommandInteraction {
|
|||||||
queue.node.setVolume(volume);
|
queue.node.setVolume(volume);
|
||||||
logger.debug(`Set volume to ${volume}%.`);
|
logger.debug(`Set volume to ${volume}%.`);
|
||||||
|
|
||||||
let authorName: string;
|
|
||||||
|
|
||||||
if (interaction.member instanceof GuildMember) {
|
|
||||||
authorName = interaction.member.nickname || interaction.user.username;
|
|
||||||
} else {
|
|
||||||
authorName = interaction.user.username;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (volume === 0) {
|
if (volume === 0) {
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor(await this.getEmbedUserAuthor(interaction))
|
||||||
name: authorName,
|
|
||||||
iconURL: interaction.user.avatarURL() || this.embedOptions.info.fallbackIconUrl
|
|
||||||
})
|
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.volumeMuted} Audio muted**\nPlayback audio has been muted, because volume was set to **\`${volume}%\`**.`
|
`**${this.embedOptions.icons.volumeMuted} Audio muted**\nPlayback audio has been muted, because volume was set to **\`${volume}%\`**.`
|
||||||
)
|
)
|
||||||
@@ -105,10 +90,7 @@ class VolumeCommand extends BaseSlashCommandInteraction {
|
|||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor(await this.getEmbedUserAuthor(interaction))
|
||||||
name: authorName,
|
|
||||||
iconURL: interaction.user.avatarURL() || this.embedOptions.info.fallbackIconUrl
|
|
||||||
})
|
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.volumeChanged} Volume changed**\nPlayback volume has been changed to **\`${volume}%\`**.`
|
`**${this.embedOptions.icons.volumeChanged} Volume changed**\nPlayback volume has been changed to **\`${volume}%\`**.`
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { EmbedBuilder, Guild, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, Guild, SlashCommandBuilder } from 'discord.js';
|
||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
|
||||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||||
import { notValidGuildId } from '../../../utils/validation/systemCommandValidator';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
|
import { checkValidGuildId } from '../../../utils/validation/systemCommandValidator';
|
||||||
|
|
||||||
class GuildsCommand extends BaseSlashCommandInteraction {
|
class GuildsCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -10,15 +10,15 @@ class GuildsCommand extends BaseSlashCommandInteraction {
|
|||||||
.setDescription('Show the top 25 guilds by member count.');
|
.setDescription('Show the top 25 guilds by member count.');
|
||||||
const isSystemCommand: boolean = true;
|
const isSystemCommand: boolean = true;
|
||||||
super(data, isSystemCommand);
|
super(data, isSystemCommand);
|
||||||
|
|
||||||
|
this.validators = [(args) => checkValidGuildId(args)];
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction, client } = params;
|
const { executionId, interaction, client } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
if (await notValidGuildId({ interaction, executionId })) {
|
await this.runValidators({ interaction, executionId });
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let shardGuilds: Guild[] = [];
|
let shardGuilds: Guild[] = [];
|
||||||
let totalGuildCount: number = 0;
|
let totalGuildCount: number = 0;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { ApplicationCommandOption, ApplicationCommandOptionData, EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
import { ApplicationCommandOption, ApplicationCommandOptionData, EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
|
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||||
import { ExtendedClient } from '../../../types/clientTypes';
|
import { ExtendedClient } from '../../../types/clientTypes';
|
||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
import { checkValidGuildId } from '../../../utils/validation/systemCommandValidator';
|
||||||
import { notValidGuildId } from '../../../utils/validation/systemCommandValidator';
|
|
||||||
|
|
||||||
class ReloadCommand extends BaseSlashCommandInteraction {
|
class ReloadCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -11,15 +11,15 @@ class ReloadCommand extends BaseSlashCommandInteraction {
|
|||||||
.setDescription('Reload slash command, autocomplete and component interactions across shards.');
|
.setDescription('Reload slash command, autocomplete and component interactions across shards.');
|
||||||
const isSystemCommand: boolean = true;
|
const isSystemCommand: boolean = true;
|
||||||
super(data, isSystemCommand);
|
super(data, isSystemCommand);
|
||||||
|
|
||||||
|
this.validators = [(args) => checkValidGuildId(args)];
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction, client } = params;
|
const { executionId, interaction, client } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
if (await notValidGuildId({ interaction, executionId })) {
|
await this.runValidators({ interaction, executionId });
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logger.debug('Reloading interaction module across all shards.');
|
logger.debug('Reloading interaction module across all shards.');
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { EmbedBuilder, EmbedField, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, EmbedField, SlashCommandBuilder } from 'discord.js';
|
||||||
|
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||||
import { ExtendedClient } from '../../../types/clientTypes';
|
import { ExtendedClient } from '../../../types/clientTypes';
|
||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType, ShardInfo } from '../../../types/interactionTypes';
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType, ShardInfo } from '../../../types/interactionTypes';
|
||||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
import { checkValidGuildId } from '../../../utils/validation/systemCommandValidator';
|
||||||
import { notValidGuildId } from '../../../utils/validation/systemCommandValidator';
|
|
||||||
|
|
||||||
class ShardsCommand extends BaseSlashCommandInteraction {
|
class ShardsCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -29,15 +29,15 @@ class ShardsCommand extends BaseSlashCommandInteraction {
|
|||||||
);
|
);
|
||||||
const isSystemCommand: boolean = true;
|
const isSystemCommand: boolean = true;
|
||||||
super(data, isSystemCommand);
|
super(data, isSystemCommand);
|
||||||
|
|
||||||
|
this.validators = [(args) => checkValidGuildId(args)];
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction, client } = params;
|
const { executionId, interaction, client } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
if (await notValidGuildId({ interaction, executionId })) {
|
await this.runValidators({ interaction, executionId });
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let shardInfoList: ShardInfo[] = [];
|
let shardInfoList: ShardInfo[] = [];
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ import { EmbedBuilder, Guild, SlashCommandBuilder } from 'discord.js';
|
|||||||
import osu from 'node-os-utils';
|
import osu from 'node-os-utils';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { dependencies, version } from '../../../../package.json';
|
import { dependencies, version } from '../../../../package.json';
|
||||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
|
||||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||||
|
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||||
import { getUptimeFormatted } from '../../../utils/system/getUptimeFormatted';
|
import { getUptimeFormatted } from '../../../utils/system/getUptimeFormatted';
|
||||||
import { notValidGuildId } from '../../../utils/validation/systemCommandValidator';
|
import { checkValidGuildId } from '../../../utils/validation/systemCommandValidator';
|
||||||
|
|
||||||
class SystemStatusCommand extends BaseSlashCommandInteraction {
|
class SystemStatusCommand extends BaseSlashCommandInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -14,15 +14,15 @@ class SystemStatusCommand extends BaseSlashCommandInteraction {
|
|||||||
.setDescription('Show operational status of the bot with additional technical information.');
|
.setDescription('Show operational status of the bot with additional technical information.');
|
||||||
const isSystemCommand: boolean = true;
|
const isSystemCommand: boolean = true;
|
||||||
super(data, isSystemCommand);
|
super(data, isSystemCommand);
|
||||||
|
|
||||||
|
this.validators = [(args) => checkValidGuildId(args)];
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||||
const { executionId, interaction, client } = params;
|
const { executionId, interaction, client } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
if (await notValidGuildId({ interaction, executionId })) {
|
await this.runValidators({ interaction, executionId });
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// from normal /status command
|
// from normal /status command
|
||||||
const uptimeString: string = await getUptimeFormatted({ executionId });
|
const uptimeString: string = await getUptimeFormatted({ executionId });
|
||||||
|
|||||||
@@ -1,13 +1,19 @@
|
|||||||
import { GuildQueue, useQueue } from 'discord-player';
|
import { GuildQueue, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember } from 'discord.js';
|
import { EmbedBuilder } from 'discord.js';
|
||||||
import { BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
|
||||||
import { BaseComponentInteraction } from '../../classes/interactions';
|
import { BaseComponentInteraction } from '../../classes/interactions';
|
||||||
import { queueDoesNotExist } from '../../utils/validation/queueValidator';
|
import { BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
||||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
import { checkQueueExists } from '../../utils/validation/queueValidator';
|
||||||
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
||||||
|
|
||||||
class FiltersDisableButtonComponent extends BaseComponentInteraction {
|
class FiltersDisableButtonComponent extends BaseComponentInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
super('filters-disable-button');
|
super('filters-disable-button');
|
||||||
|
|
||||||
|
this.validators = [
|
||||||
|
(args) => checkInVoiceChannel(args),
|
||||||
|
(args) => checkSameVoiceChannel(args),
|
||||||
|
(args) => checkQueueExists(args)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
||||||
@@ -16,17 +22,7 @@ class FiltersDisableButtonComponent extends BaseComponentInteraction {
|
|||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
const validators = [
|
await this.runValidators({ interaction, queue, executionId });
|
||||||
() => notInVoiceChannel({ interaction, executionId }),
|
|
||||||
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
|
||||||
() => queueDoesNotExist({ interaction, queue, executionId })
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const validator of validators) {
|
|
||||||
if (await validator()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset filters before enabling provided filters
|
// Reset filters before enabling provided filters
|
||||||
if (queue.filters.ffmpeg.filters.length > 0) {
|
if (queue.filters.ffmpeg.filters.length > 0) {
|
||||||
@@ -34,22 +30,11 @@ class FiltersDisableButtonComponent extends BaseComponentInteraction {
|
|||||||
logger.debug('Reset queue filters.');
|
logger.debug('Reset queue filters.');
|
||||||
}
|
}
|
||||||
|
|
||||||
let authorName: string;
|
|
||||||
|
|
||||||
if (interaction.member instanceof GuildMember) {
|
|
||||||
authorName = interaction.member.nickname || interaction.user.username;
|
|
||||||
} else {
|
|
||||||
authorName = interaction.user.username;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor(await this.getEmbedUserAuthor(interaction))
|
||||||
name: authorName,
|
|
||||||
iconURL: interaction.user.avatarURL() || this.embedOptions.info.fallbackIconUrl
|
|
||||||
})
|
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.success} Disabled filters**\nAll audio filters have been disabled.`
|
`**${this.embedOptions.icons.success} Disabled filters**\nAll audio filters have been disabled.`
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,16 +1,23 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { GuildQueue, QueueFilters, useQueue } from 'discord-player';
|
import { GuildQueue, QueueFilters, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember, StringSelectMenuInteraction } from 'discord.js';
|
import { EmbedBuilder, StringSelectMenuInteraction } from 'discord.js';
|
||||||
|
import { BaseComponentInteraction } from '../../classes/interactions';
|
||||||
import { FFmpegFilterOption, FFmpegFilterOptions } from '../../types/configTypes';
|
import { FFmpegFilterOption, FFmpegFilterOptions } from '../../types/configTypes';
|
||||||
import { BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
import { BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
||||||
import { BaseComponentInteraction } from '../../classes/interactions';
|
import { checkQueueExists } from '../../utils/validation/queueValidator';
|
||||||
import { queueDoesNotExist } from '../../utils/validation/queueValidator';
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
||||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
|
||||||
const ffmpegFilterOptions: FFmpegFilterOptions = config.get('ffmpegFilterOptions');
|
const ffmpegFilterOptions: FFmpegFilterOptions = config.get('ffmpegFilterOptions');
|
||||||
|
|
||||||
class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
super('filters-select-menu');
|
super('filters-select-menu');
|
||||||
|
|
||||||
|
this.validators = [
|
||||||
|
(args) => checkInVoiceChannel(args),
|
||||||
|
(args) => checkSameVoiceChannel(args),
|
||||||
|
(args) => checkQueueExists(args)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
||||||
@@ -22,17 +29,7 @@ class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
|||||||
const selectMenuInteraction: StringSelectMenuInteraction = interaction as StringSelectMenuInteraction;
|
const selectMenuInteraction: StringSelectMenuInteraction = interaction as StringSelectMenuInteraction;
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
const validators = [
|
await this.runValidators({ interaction, queue, executionId });
|
||||||
() => notInVoiceChannel({ interaction, executionId }),
|
|
||||||
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
|
||||||
() => queueDoesNotExist({ interaction, queue, executionId })
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const validator of validators) {
|
|
||||||
if (await validator()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
queue.filters.ffmpeg.setInputArgs([
|
queue.filters.ffmpeg.setInputArgs([
|
||||||
'-threads',
|
'-threads',
|
||||||
@@ -65,22 +62,11 @@ class FiltersSelectMenuComponent extends BaseComponentInteraction {
|
|||||||
queue.filters.ffmpeg.toggle(selectMenuInteraction.values as (keyof QueueFilters)[]);
|
queue.filters.ffmpeg.toggle(selectMenuInteraction.values as (keyof QueueFilters)[]);
|
||||||
logger.debug(`Enabled filters ${selectMenuInteraction.values.join(', ')}.`);
|
logger.debug(`Enabled filters ${selectMenuInteraction.values.join(', ')}.`);
|
||||||
|
|
||||||
let authorName: string;
|
|
||||||
|
|
||||||
if (selectMenuInteraction.member instanceof GuildMember) {
|
|
||||||
authorName = selectMenuInteraction.member.nickname || selectMenuInteraction.user.username;
|
|
||||||
} else {
|
|
||||||
authorName = selectMenuInteraction.user.username;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
return await selectMenuInteraction.editReply({
|
return await selectMenuInteraction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor(await this.getEmbedUserAuthor(interaction))
|
||||||
name: authorName,
|
|
||||||
iconURL: selectMenuInteraction.user.avatarURL() || ''
|
|
||||||
})
|
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${
|
`**${
|
||||||
this.embedOptions.icons.success
|
this.embedOptions.icons.success
|
||||||
|
|||||||
@@ -1,13 +1,20 @@
|
|||||||
import { GuildQueue, Track, useQueue } from 'discord-player';
|
import { GuildQueue, Track, useQueue } from 'discord-player';
|
||||||
import { EmbedBuilder, GuildMember } from 'discord.js';
|
import { EmbedBuilder } from 'discord.js';
|
||||||
import { BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
|
||||||
import { BaseComponentInteraction } from '../../classes/interactions';
|
import { BaseComponentInteraction } from '../../classes/interactions';
|
||||||
import { queueDoesNotExist, queueNoCurrentTrack } from '../../utils/validation/queueValidator';
|
import { BaseComponentParams, BaseComponentReturnType } from '../../types/interactionTypes';
|
||||||
import { notInSameVoiceChannel, notInVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
import { checkQueueCurrentTrack, checkQueueExists } from '../../utils/validation/queueValidator';
|
||||||
|
import { checkInVoiceChannel, checkSameVoiceChannel } from '../../utils/validation/voiceChannelValidator';
|
||||||
|
|
||||||
class NowplayingSkipButton extends BaseComponentInteraction {
|
class NowplayingSkipButton extends BaseComponentInteraction {
|
||||||
constructor() {
|
constructor() {
|
||||||
super('nowplaying-skip-button');
|
super('nowplaying-skip-button');
|
||||||
|
|
||||||
|
this.validators = [
|
||||||
|
(args) => checkInVoiceChannel(args),
|
||||||
|
(args) => checkSameVoiceChannel(args),
|
||||||
|
(args) => checkQueueExists(args),
|
||||||
|
(args) => checkQueueCurrentTrack(args)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
async execute(params: BaseComponentParams): BaseComponentReturnType {
|
||||||
@@ -16,18 +23,7 @@ class NowplayingSkipButton extends BaseComponentInteraction {
|
|||||||
|
|
||||||
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
const queue: GuildQueue = useQueue(interaction.guild!.id)!;
|
||||||
|
|
||||||
const validators = [
|
await this.runValidators({ interaction, queue, executionId });
|
||||||
() => notInVoiceChannel({ interaction, executionId }),
|
|
||||||
() => notInSameVoiceChannel({ interaction, queue, executionId }),
|
|
||||||
() => queueDoesNotExist({ interaction, queue, executionId }),
|
|
||||||
() => queueNoCurrentTrack({ interaction, queue, executionId })
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const validator of validators) {
|
|
||||||
if (await validator()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!queue || (queue.tracks.data.length === 0 && !queue.currentTrack)) {
|
if (!queue || (queue.tracks.data.length === 0 && !queue.currentTrack)) {
|
||||||
logger.debug('Tried skipping track but there was no queue.');
|
logger.debug('Tried skipping track but there was no queue.');
|
||||||
@@ -89,22 +85,11 @@ class NowplayingSkipButton extends BaseComponentInteraction {
|
|||||||
|
|
||||||
const repeatModeString: string = queue.repeatMode === 0 ? '' : getRepeatModeMessage(queue.repeatMode);
|
const repeatModeString: string = queue.repeatMode === 0 ? '' : getRepeatModeMessage(queue.repeatMode);
|
||||||
|
|
||||||
let authorName: string;
|
|
||||||
|
|
||||||
if (interaction.member instanceof GuildMember) {
|
|
||||||
authorName = interaction.member.nickname || interaction.user.username;
|
|
||||||
} else {
|
|
||||||
authorName = interaction.user.username;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug('Responding with success embed.');
|
logger.debug('Responding with success embed.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor(await this.getEmbedUserAuthor(interaction))
|
||||||
name: authorName,
|
|
||||||
iconURL: interaction.user.avatarURL() || this.embedOptions.info.fallbackIconUrl
|
|
||||||
})
|
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${this.embedOptions.icons.skipped} Skipped track**\n**${durationFormat} [${
|
`**${this.embedOptions.icons.skipped} Skipped track**\n**${durationFormat} [${
|
||||||
skippedTrack.title
|
skippedTrack.title
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import pino, { DestinationStream, Logger, LoggerOptions } from 'pino';
|
import pino, { DestinationStream, Logger, LoggerOptions } from 'pino';
|
||||||
|
|
||||||
import { CustomLoggerOptions } from '../types/configTypes';
|
import { CustomLoggerOptions } from '../types/configTypes';
|
||||||
import { TargetOptions } from '../types/serviceTypes';
|
import { TargetOptions } from '../types/serviceTypes';
|
||||||
|
|
||||||
|
|||||||
Vendored
-1
@@ -1,6 +1,5 @@
|
|||||||
import { GuildQueuePlayerNode } from 'discord-player';
|
import { GuildQueuePlayerNode } from 'discord-player';
|
||||||
import { BaseGuildTextChannel } from 'discord.js';
|
import { BaseGuildTextChannel } from 'discord.js';
|
||||||
|
|
||||||
import { ExtendedClient } from './clientTypes';
|
import { ExtendedClient } from './clientTypes';
|
||||||
|
|
||||||
export type ClientEventArguments = unknown[];
|
export type ClientEventArguments = unknown[];
|
||||||
|
|||||||
Vendored
+19
-8
@@ -7,22 +7,26 @@ import {
|
|||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
import { ExtendedClient } from './clientTypes';
|
import { ExtendedClient } from './clientTypes';
|
||||||
|
|
||||||
|
export type PlayerStatistics = {
|
||||||
|
activeVoiceConnections: number;
|
||||||
|
totalTracks: number;
|
||||||
|
totalListeners: number;
|
||||||
|
};
|
||||||
|
|
||||||
export type ShardInfo = {
|
export type ShardInfo = {
|
||||||
shardId: number;
|
shardId: number;
|
||||||
memUsage: number;
|
memUsage: number;
|
||||||
guildCount: number;
|
guildCount: number;
|
||||||
guildMemberCount: number;
|
guildMemberCount: number;
|
||||||
playerStatistics: {
|
playerStatistics: PlayerStatistics;
|
||||||
activeVoiceConnections: number;
|
};
|
||||||
totalTracks: number;
|
|
||||||
totalListeners: number;
|
export type Bridge = {
|
||||||
};
|
views: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TrackMetadata = {
|
export type TrackMetadata = {
|
||||||
bridge: {
|
bridge: Bridge;
|
||||||
views: number;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
type BaseInteractionParams = {
|
type BaseInteractionParams = {
|
||||||
@@ -48,3 +52,10 @@ export type BaseSlashCommandReturnType = Promise<Message<boolean> | void>;
|
|||||||
export type BaseAutocompleteReturnType = Promise<ApplicationCommandOptionChoiceData | void>;
|
export type BaseAutocompleteReturnType = Promise<ApplicationCommandOptionChoiceData | void>;
|
||||||
|
|
||||||
export type BaseComponentReturnType = Promise<Message<boolean> | void>;
|
export type BaseComponentReturnType = Promise<Message<boolean> | void>;
|
||||||
|
|
||||||
|
export enum FilterType {
|
||||||
|
FFmpeg = 'ffmpeg',
|
||||||
|
Biquad = 'biquad',
|
||||||
|
Equalizer = 'equalizer',
|
||||||
|
Disable = 'disable'
|
||||||
|
}
|
||||||
Vendored
+3
-40
@@ -1,6 +1,5 @@
|
|||||||
import { GuildQueue, Player } from 'discord-player';
|
import { GuildQueue, Player } from 'discord-player';
|
||||||
import { ChatInputCommandInteraction, MessageComponentInteraction } from 'discord.js';
|
import { ChatInputCommandInteraction, MessageComponentInteraction } from 'discord.js';
|
||||||
|
|
||||||
import { ExtendedClient } from './clientTypes';
|
import { ExtendedClient } from './clientTypes';
|
||||||
|
|
||||||
export type RegisterEventListenersParams = {
|
export type RegisterEventListenersParams = {
|
||||||
@@ -23,19 +22,11 @@ export type CustomEvent = {
|
|||||||
isPlayerEvent?: boolean;
|
isPlayerEvent?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type NotInVoiceChannelParams = {
|
export type Validator = (args: ValidatorParams) => Promise<void>;
|
||||||
interaction: ChatInputCommandInteraction | MessageComponentInteraction;
|
|
||||||
executionId: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type NotInSameVoiceChannelParams = {
|
export type ValidatorParams = {
|
||||||
interaction: ChatInputCommandInteraction | MessageComponentInteraction;
|
|
||||||
queue: GuildQueue;
|
|
||||||
executionId: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type NotValidGuildIdParams = {
|
|
||||||
interaction: ChatInputCommandInteraction | MessageComponentInteraction;
|
interaction: ChatInputCommandInteraction | MessageComponentInteraction;
|
||||||
|
queue?: GuildQueue;
|
||||||
executionId: string;
|
executionId: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -44,34 +35,6 @@ export type TransformQueryParams = {
|
|||||||
executionId: string;
|
executionId: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type QueueDoesNotExistParams = {
|
|
||||||
interaction: ChatInputCommandInteraction | MessageComponentInteraction;
|
|
||||||
queue: GuildQueue;
|
|
||||||
executionId: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type QueueNoCurrentTrackParams = {
|
|
||||||
interaction: ChatInputCommandInteraction | MessageComponentInteraction;
|
|
||||||
queue: GuildQueue;
|
|
||||||
executionId: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type QueueIsEmptyParams = {
|
|
||||||
interaction: ChatInputCommandInteraction | MessageComponentInteraction;
|
|
||||||
queue: GuildQueue;
|
|
||||||
executionId: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type CannotJoinVoiceOrTalkParams = {
|
|
||||||
interaction: ChatInputCommandInteraction | MessageComponentInteraction;
|
|
||||||
executionId: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type CannotSendMessageInChannelParams = {
|
|
||||||
interaction: ChatInputCommandInteraction | MessageComponentInteraction;
|
|
||||||
executionId: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type GetUptimeFormattedParams = {
|
export type GetUptimeFormattedParams = {
|
||||||
executionId: string;
|
executionId: string;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,19 +1,16 @@
|
|||||||
import 'dotenv/config';
|
|
||||||
|
|
||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { REST, RESTPostAPIChatInputApplicationCommandsJSONBody, RouteLike, Routes } from 'discord.js';
|
import { REST, RESTPostAPIChatInputApplicationCommandsJSONBody, RouteLike, Routes } from 'discord.js';
|
||||||
|
import 'dotenv/config';
|
||||||
|
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
import { Logger } from 'pino';
|
||||||
|
|
||||||
import loggerModule from '../services/logger';
|
import loggerModule from '../services/logger';
|
||||||
import { SystemOptions } from '../types/configTypes';
|
import { SystemOptions } from '../types/configTypes';
|
||||||
import { Logger } from 'pino';
|
|
||||||
|
|
||||||
const systemOptions: SystemOptions = config.get('systemOptions');
|
const systemOptions: SystemOptions = config.get('systemOptions');
|
||||||
|
|
||||||
const executionId: string = uuidv4();
|
const executionId: string = uuidv4();
|
||||||
|
|
||||||
const logger: Logger = loggerModule.child({
|
const logger: Logger = loggerModule.child({
|
||||||
module: 'deploy',
|
module: 'deploy',
|
||||||
name: 'deploySlashCommands',
|
name: 'deploySlashCommands',
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import Discord, { Client } from 'discord.js';
|
import Discord, { Client } from 'discord.js';
|
||||||
|
|
||||||
import loggerModule from '../../services/logger';
|
|
||||||
import { Logger } from 'pino';
|
import { Logger } from 'pino';
|
||||||
|
import loggerModule from '../../services/logger';
|
||||||
|
|
||||||
export const createClient = async ({ executionId }: { executionId: string }) => {
|
export const createClient = async ({ executionId }: { executionId: string }) => {
|
||||||
const logger: Logger = loggerModule.child({
|
const logger: Logger = loggerModule.child({
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { Channel, Client } from 'discord.js';
|
import { Channel, Client } from 'discord.js';
|
||||||
|
|
||||||
import { Logger } from 'pino';
|
import { Logger } from 'pino';
|
||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
import { LoadTestOptions } from '../../types/configTypes';
|
import { LoadTestOptions } from '../../types/configTypes';
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import { Collection } from 'discord.js';
|
import { Collection } from 'discord.js';
|
||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
|
|
||||||
import loggerModule from '../services/logger';
|
|
||||||
import { RegisterClientInteractionsParams } from '../types/utilTypes';
|
|
||||||
import { Logger } from 'pino';
|
import { Logger } from 'pino';
|
||||||
|
import loggerModule from '../services/logger';
|
||||||
import { ExtendedClient } from '../types/clientTypes';
|
import { ExtendedClient } from '../types/clientTypes';
|
||||||
|
import { RegisterClientInteractionsParams } from '../types/utilTypes';
|
||||||
|
|
||||||
export const registerClientInteractions = async ({ client, executionId }: RegisterClientInteractionsParams) => {
|
export const registerClientInteractions = async ({ client, executionId }: RegisterClientInteractionsParams) => {
|
||||||
const logger: Logger = loggerModule.child({
|
const logger: Logger = loggerModule.child({
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import fs from 'node:fs';
|
|
||||||
import path from 'node:path';
|
|
||||||
|
|
||||||
import { GuildQueueEvents, Player, PlayerEvents } from 'discord-player';
|
import { GuildQueueEvents, Player, PlayerEvents } from 'discord-player';
|
||||||
import { Client } from 'discord.js';
|
import { Client } from 'discord.js';
|
||||||
|
import fs from 'node:fs';
|
||||||
|
import path from 'node:path';
|
||||||
|
import { Logger } from 'pino';
|
||||||
import loggerModule from '../services/logger';
|
import loggerModule from '../services/logger';
|
||||||
import { CustomLoggerOptions } from '../types/configTypes';
|
import { CustomLoggerOptions } from '../types/configTypes';
|
||||||
import { ClientEventArguments, PlayerEventArguments, ProcessEventArguments } from '../types/eventTypes';
|
import { ClientEventArguments, PlayerEventArguments, ProcessEventArguments } from '../types/eventTypes';
|
||||||
import { CustomEvent, RegisterEventListenersParams } from '../types/utilTypes';
|
import { CustomEvent, RegisterEventListenersParams } from '../types/utilTypes';
|
||||||
import { Logger } from 'pino';
|
|
||||||
|
|
||||||
const loggerOptions: CustomLoggerOptions = config.get('loggerOptions');
|
const loggerOptions: CustomLoggerOptions = config.get('loggerOptions');
|
||||||
|
|
||||||
|
|||||||
@@ -8,14 +8,14 @@ import {
|
|||||||
VoiceBasedChannel,
|
VoiceBasedChannel,
|
||||||
VoiceChannel
|
VoiceChannel
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
|
|
||||||
import { Logger } from 'pino';
|
import { Logger } from 'pino';
|
||||||
|
import { InteractionValidationError } from '../../classes/interactions';
|
||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
import { EmbedOptions } from '../../types/configTypes';
|
import { EmbedOptions } from '../../types/configTypes';
|
||||||
import { CannotJoinVoiceOrTalkParams, CannotSendMessageInChannelParams } from '../../types/utilTypes';
|
import { ValidatorParams } from '../../types/utilTypes';
|
||||||
|
|
||||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||||
export const cannotJoinVoiceOrTalk = async ({ interaction, executionId }: CannotJoinVoiceOrTalkParams) => {
|
export const checkVoicePermissionJoinAndTalk = async ({ interaction, executionId }: ValidatorParams) => {
|
||||||
const logger: Logger = loggerModule.child({
|
const logger: Logger = loggerModule.child({
|
||||||
module: 'utilValidation',
|
module: 'utilValidation',
|
||||||
name: 'cannotJoinVoiceOrTalk',
|
name: 'cannotJoinVoiceOrTalk',
|
||||||
@@ -34,7 +34,7 @@ export const cannotJoinVoiceOrTalk = async ({ interaction, executionId }: Cannot
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${embedOptions.icons.warning} Oops!**\nI do not have permission to play audio in the voice channel you are in.\n\nPlease make sure I have the **\`Connect\`** and **\`Speak\`** permissions in this voice channel.`
|
`**${embedOptions.icons.warning} Oops!**\nI do not have permission to play audio in the voice channel <#${channel.id}>.\n\nPlease make sure I have the **\`Connect\`** and **\`Speak\`** permissions in this voice channel.`
|
||||||
)
|
)
|
||||||
.setColor(embedOptions.colors.warning)
|
.setColor(embedOptions.colors.warning)
|
||||||
]
|
]
|
||||||
@@ -43,13 +43,13 @@ export const cannotJoinVoiceOrTalk = async ({ interaction, executionId }: Cannot
|
|||||||
logger.debug(
|
logger.debug(
|
||||||
`User tried to use command '${interactionIdentifier}' but the bot had no permission to join/speak in the voice channel.`
|
`User tried to use command '${interactionIdentifier}' but the bot had no permission to join/speak in the voice channel.`
|
||||||
);
|
);
|
||||||
return true;
|
throw new InteractionValidationError('Bot cannot join or speak in voice channel.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const cannotSendMessageInChannel = async ({ interaction, executionId }: CannotSendMessageInChannelParams) => {
|
export const checkChannelPermissionViewable = async ({ interaction, executionId }: ValidatorParams) => {
|
||||||
const logger: Logger = loggerModule.child({
|
const logger: Logger = loggerModule.child({
|
||||||
module: 'utilValidation',
|
module: 'utilValidation',
|
||||||
name: 'cannotSendMessageInChannel',
|
name: 'cannotSendMessageInChannel',
|
||||||
@@ -82,7 +82,7 @@ export const cannotSendMessageInChannel = async ({ interaction, executionId }: C
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${embedOptions.icons.warning} Oops!**\nI do not have permission to send message replies in the channel you are in.\n\nPlease make sure I have the **\`View Channel\`** permission in this text channel.`
|
`**${embedOptions.icons.warning} Oops!**\nI do not have permission to send message replies in the channel <#${channel.id}>.\n\nPlease make sure I have the **\`View Channel\`** permission in this text channel.`
|
||||||
)
|
)
|
||||||
.setColor(embedOptions.colors.warning)
|
.setColor(embedOptions.colors.warning)
|
||||||
]
|
]
|
||||||
@@ -107,8 +107,8 @@ export const cannotSendMessageInChannel = async ({ interaction, executionId }: C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
throw new InteractionValidationError('Bot cannot send message in channel.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return;
|
||||||
};
|
};
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { EmbedBuilder, InteractionType } from 'discord.js';
|
import { EmbedBuilder, InteractionType } from 'discord.js';
|
||||||
|
import { Logger } from 'pino';
|
||||||
|
import { InteractionValidationError } from '../../classes/interactions';
|
||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
import { EmbedOptions } from '../../types/configTypes';
|
import { EmbedOptions } from '../../types/configTypes';
|
||||||
import { QueueDoesNotExistParams, QueueIsEmptyParams, QueueNoCurrentTrackParams } from '../../types/utilTypes';
|
import { ValidatorParams } from '../../types/utilTypes';
|
||||||
import { Logger } from 'pino';
|
|
||||||
|
|
||||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||||
export const queueDoesNotExist = async ({ interaction, queue, executionId }: QueueDoesNotExistParams) => {
|
export const checkQueueExists = async ({ interaction, queue, executionId }: ValidatorParams) => {
|
||||||
const logger: Logger = loggerModule.child({
|
const logger: Logger = loggerModule.child({
|
||||||
module: 'utilValidation',
|
module: 'utilValidation',
|
||||||
name: 'queueDoesNotExist',
|
name: 'queueDoesNotExist',
|
||||||
@@ -31,13 +31,13 @@ export const queueDoesNotExist = async ({ interaction, queue, executionId }: Que
|
|||||||
});
|
});
|
||||||
|
|
||||||
logger.debug(`User tried to use command '${interactionIdentifier}' but there was no queue.`);
|
logger.debug(`User tried to use command '${interactionIdentifier}' but there was no queue.`);
|
||||||
return true;
|
throw new InteractionValidationError('Queue does not exist.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const queueNoCurrentTrack = async ({ interaction, queue, executionId }: QueueNoCurrentTrackParams) => {
|
export const checkQueueCurrentTrack = async ({ interaction, queue, executionId }: ValidatorParams) => {
|
||||||
const logger: Logger = loggerModule.child({
|
const logger: Logger = loggerModule.child({
|
||||||
module: 'utilValidation',
|
module: 'utilValidation',
|
||||||
name: 'queueNoCurrentTrack',
|
name: 'queueNoCurrentTrack',
|
||||||
@@ -49,7 +49,7 @@ export const queueNoCurrentTrack = async ({ interaction, queue, executionId }: Q
|
|||||||
const interactionIdentifier =
|
const interactionIdentifier =
|
||||||
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
||||||
|
|
||||||
if (!queue.currentTrack) {
|
if (queue && !queue.currentTrack) {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
@@ -61,13 +61,13 @@ export const queueNoCurrentTrack = async ({ interaction, queue, executionId }: Q
|
|||||||
});
|
});
|
||||||
|
|
||||||
logger.debug(`User tried to use command '${interactionIdentifier}' but there was no current track.`);
|
logger.debug(`User tried to use command '${interactionIdentifier}' but there was no current track.`);
|
||||||
return true;
|
throw new InteractionValidationError('Queue has no current track.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const queueIsEmpty = async ({ interaction, queue, executionId }: QueueIsEmptyParams) => {
|
export const checkQueueEmpty = async ({ interaction, queue, executionId }: ValidatorParams) => {
|
||||||
const logger: Logger = loggerModule.child({
|
const logger: Logger = loggerModule.child({
|
||||||
module: 'utilValidation',
|
module: 'utilValidation',
|
||||||
name: 'queueIsEmpty',
|
name: 'queueIsEmpty',
|
||||||
@@ -79,7 +79,7 @@ export const queueIsEmpty = async ({ interaction, queue, executionId }: QueueIsE
|
|||||||
const interactionIdentifier =
|
const interactionIdentifier =
|
||||||
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
||||||
|
|
||||||
if (queue.tracks.data.length === 0) {
|
if (queue && queue.tracks.data.length === 0) {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
@@ -91,8 +91,8 @@ export const queueIsEmpty = async ({ interaction, queue, executionId }: QueueIsE
|
|||||||
});
|
});
|
||||||
|
|
||||||
logger.debug(`User tried to use command '${interactionIdentifier}' but there was no tracks in the queue.`);
|
logger.debug(`User tried to use command '${interactionIdentifier}' but there was no tracks in the queue.`);
|
||||||
return true;
|
throw new InteractionValidationError('Queue is empty.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return;
|
||||||
};
|
};
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { EmbedBuilder, InteractionType } from 'discord.js';
|
import { EmbedBuilder, InteractionType } from 'discord.js';
|
||||||
|
import { Logger } from 'pino';
|
||||||
|
import { InteractionValidationError } from '../../classes/interactions';
|
||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
import { EmbedOptions, SystemOptions } from '../../types/configTypes';
|
import { EmbedOptions, SystemOptions } from '../../types/configTypes';
|
||||||
import { NotValidGuildIdParams } from '../../types/utilTypes';
|
import { ValidatorParams } from '../../types/utilTypes';
|
||||||
import { Logger } from 'pino';
|
|
||||||
|
|
||||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||||
const systemOptions: SystemOptions = config.get('systemOptions');
|
const systemOptions: SystemOptions = config.get('systemOptions');
|
||||||
export const notValidGuildId = async ({ interaction, executionId }: NotValidGuildIdParams) => {
|
export const checkValidGuildId = async ({ interaction, executionId }: ValidatorParams) => {
|
||||||
const logger: Logger = loggerModule.child({
|
const logger: Logger = loggerModule.child({
|
||||||
module: 'utilValidation',
|
module: 'utilValidation',
|
||||||
name: 'notValidGuildId',
|
name: 'notValidGuildId',
|
||||||
@@ -25,7 +25,7 @@ export const notValidGuildId = async ({ interaction, executionId }: NotValidGuil
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${embedOptions.icons.warning} Oops!**\nNo permission to execute this command.\n\nThe command **\`/${interactionIdentifier}\`** cannot be executed in this server.`
|
`**${embedOptions.icons.warning} Oops!**\nNo permission to perform this action.\n\nThe command **\`/${interactionIdentifier}\`** cannot be executed in this server.`
|
||||||
)
|
)
|
||||||
.setColor(embedOptions.colors.warning)
|
.setColor(embedOptions.colors.warning)
|
||||||
]
|
]
|
||||||
@@ -34,8 +34,8 @@ export const notValidGuildId = async ({ interaction, executionId }: NotValidGuil
|
|||||||
logger.debug(
|
logger.debug(
|
||||||
`User tried to use command '${interactionIdentifier}' but system command cannot be executed in the specified guild.`
|
`User tried to use command '${interactionIdentifier}' but system command cannot be executed in the specified guild.`
|
||||||
);
|
);
|
||||||
return true;
|
throw new InteractionValidationError('System command cannot be executed in the specified guild.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return;
|
||||||
};
|
};
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { EmbedBuilder, GuildMember, InteractionType } from 'discord.js';
|
import { EmbedBuilder, GuildMember, InteractionType } from 'discord.js';
|
||||||
|
|
||||||
import { Logger } from 'pino';
|
import { Logger } from 'pino';
|
||||||
|
import { InteractionValidationError } from '../../classes/interactions';
|
||||||
import loggerModule from '../../services/logger';
|
import loggerModule from '../../services/logger';
|
||||||
import { EmbedOptions } from '../../types/configTypes';
|
import { EmbedOptions } from '../../types/configTypes';
|
||||||
import { NotInSameVoiceChannelParams, NotInVoiceChannelParams } from '../../types/utilTypes';
|
import { ValidatorParams } from '../../types/utilTypes';
|
||||||
|
|
||||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||||
export const notInVoiceChannel = async ({ interaction, executionId }: NotInVoiceChannelParams) => {
|
export const checkInVoiceChannel = async ({ interaction, executionId }: ValidatorParams) => {
|
||||||
const logger: Logger = loggerModule.child({
|
const logger: Logger = loggerModule.child({
|
||||||
module: 'validator',
|
module: 'validator',
|
||||||
name: 'notInVoiceChannel',
|
name: 'notInVoiceChannel',
|
||||||
@@ -24,20 +24,20 @@ export const notInVoiceChannel = async ({ interaction, executionId }: NotInVoice
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${embedOptions.icons.warning} Not in a voice channel**\nYou need to be in a voice channel to use this command.`
|
`**${embedOptions.icons.warning} Not in a voice channel**\nYou need to be in a voice channel to perform this action.`
|
||||||
)
|
)
|
||||||
.setColor(embedOptions.colors.warning)
|
.setColor(embedOptions.colors.warning)
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.debug(`User tried to use command '${interactionIdentifier}' but was not in a voice channel.`);
|
logger.debug(`User tried to use command '${interactionIdentifier}' but was not in a voice channel.`);
|
||||||
return true;
|
throw new InteractionValidationError('User not in voice channel.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const notInSameVoiceChannel = async ({ interaction, queue, executionId }: NotInSameVoiceChannelParams) => {
|
export const checkSameVoiceChannel = async ({ interaction, queue, executionId }: ValidatorParams) => {
|
||||||
const logger: Logger = loggerModule.child({
|
const logger: Logger = loggerModule.child({
|
||||||
module: 'utilValidation',
|
module: 'utilValidation',
|
||||||
name: 'notInSameVoiceChannel',
|
name: 'notInSameVoiceChannel',
|
||||||
@@ -51,7 +51,7 @@ export const notInSameVoiceChannel = async ({ interaction, queue, executionId }:
|
|||||||
|
|
||||||
if (!queue || !queue.dispatcher) {
|
if (!queue || !queue.dispatcher) {
|
||||||
// If there is no queue or bot is not in voice channel, then there is no need to check if user is in same voice channel.
|
// If there is no queue or bot is not in voice channel, then there is no need to check if user is in same voice channel.
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -62,15 +62,15 @@ export const notInSameVoiceChannel = async ({ interaction, queue, executionId }:
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`**${embedOptions.icons.warning} Not in same voice channel**\nYou need to be in the same voice channel as me to use this command.\n\n**Voice channel:** ${queue.dispatcher.channel.name}`
|
`**${embedOptions.icons.warning} Not in same voice channel**\nYou need to be in the same voice channel as me to perform this action.\n\n**Voice channel:** <#${queue.dispatcher.channel.id}>`
|
||||||
)
|
)
|
||||||
.setColor(embedOptions.colors.warning)
|
.setColor(embedOptions.colors.warning)
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.debug(`User tried to use command '${interactionIdentifier}' but was not in the same voice channel.`);
|
logger.debug(`User tried to use command '${interactionIdentifier}' but was not in the same voice channel.`);
|
||||||
return true;
|
throw new InteractionValidationError('User not in same voice channel.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return;
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user