Skip to content

Commit

Permalink
3.5.0-dev-4
Browse files Browse the repository at this point in the history
Removed song history and voice status fields from guild schema.
Renaming of player components.
  • Loading branch information
AlexInCube committed Aug 6, 2024
1 parent db3c4f8 commit 9fb9781
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 33 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aicbot",
"version": "3.5.0-dev",
"version": "3.5.0",
"description": "Discord Bot for playing music",
"main": "build/main.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions src/DiscordTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ declare module 'discord.js' {
export interface BotEvent {
name: keyof ClientEvents;
once?: boolean | false;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
execute: (client: Client, ...args: any) => void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const rowWithOnlyStop = new ActionRowBuilder<ButtonBuilder>().addComponents(
.setEmoji(AudioPlayerIcons.stop)
);

export class MessagePlayerButtonsHandler {
export class PlayerButtons {
private collector: InteractionCollector<ButtonInteraction>;
private client: Client;
private components: Array<ActionRowBuilder<ButtonBuilder>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import i18next from 'i18next';
import { Playlist, Song } from 'distube';
import { getIconFromSource } from './util/getIconFromSource.js';

export class MessagePlayerEmbedBuilder extends EmbedBuilder {
export class PlayerEmbed extends EmbedBuilder {
private playerState: AudioPlayerState = 'loading';
private requester: User | undefined = undefined;
private uploader = i18next.t('audioplayer:player_embed_unknown');
Expand Down
10 changes: 5 additions & 5 deletions src/audioplayer/PlayerInstance.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Client, GuildTextBasedChannel, Message } from 'discord.js';
import { MessagePlayerEmbedBuilder } from './MessagePlayerEmbedBuilder.js';
import { PlayerEmbed } from './PlayerEmbed.js';
import { Queue, Song } from 'distube';
import { MessagePlayerButtonsHandler } from './MessagePlayerButtonsHandler.js';
import { PlayerButtons } from './PlayerButtons.js';
import { AudioPlayerState } from './AudioPlayerTypes.js';
import { checkBotInVoice } from '../utilities/checkBotInVoice.js';
import i18next from 'i18next';
Expand All @@ -16,9 +16,9 @@ export class PlayerInstance {
// Player state
private state: AudioPlayerState = 'loading';
// Player embed interface
embedBuilder: MessagePlayerEmbedBuilder = new MessagePlayerEmbedBuilder();
embedBuilder: PlayerEmbed = new PlayerEmbed();
// Player buttons for embed
private buttonsHandler: MessagePlayerButtonsHandler;
private buttonsHandler: PlayerButtons;
// Message where player is stored right now
private messageWithPlayer: Message | undefined;
private queue: Queue;
Expand All @@ -43,7 +43,7 @@ export class PlayerInstance {
this.client = client;
this.textChannel = txtChannel;
this.queue = queue;
this.buttonsHandler = new MessagePlayerButtonsHandler(this.client, this.textChannel);
this.buttonsHandler = new PlayerButtons(this.client, this.textChannel);
this.leaveOnEmpty = false;
}

Expand Down
12 changes: 4 additions & 8 deletions src/commands/audio/247.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,27 @@ export default function (): ICommand {
.setDescription(i18next.t('commands:247_desc')),
execute: async (interaction) => {
const newMode = await toggleLeaveOnEmpty(interaction.guild as Guild);
await interaction.reply({ embeds: [generateToggleLeaveOnEmptyMessage(newMode)] });
await interaction.reply({ embeds: [generateToggleLeaveOnEmptyEmbed(newMode)] });
}
},
text_data: {
name: '247',
description: i18next.t('commands:247_desc'),
execute: async (message) => {
const newMode = await toggleLeaveOnEmpty(message.guild as Guild);
await message.reply({ embeds: [generateToggleLeaveOnEmptyMessage(newMode)] });
await message.reply({ embeds: [generateToggleLeaveOnEmptyEmbed(newMode)] });
}
},
guild_data: {
guild_only: true
},
group: GroupAudio,
bot_permissions: [
PermissionsBitField.Flags.SendMessages,
PermissionsBitField.Flags.ViewChannel,
PermissionsBitField.Flags.ManageMessages
],
bot_permissions: [PermissionsBitField.Flags.SendMessages],
user_permissions: [PermissionsBitField.Flags.ManageGuild]
};
}

function generateToggleLeaveOnEmptyMessage(newMode: boolean) {
function generateToggleLeaveOnEmptyEmbed(newMode: boolean) {
return generateSimpleEmbed(
`${newMode ? i18next.t('commands:247_disabled') : i18next.t('commands:247_enabled')}`
);
Expand Down
18 changes: 1 addition & 17 deletions src/schemas/SchemaGuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ const SchemaGuild = new Schema<ISchemaGuild>({
guildID: { type: String, required: true, unique: true },
options: {
prefix: { type: String, default: ENV.BOT_COMMAND_PREFIX },
leaveOnEmpty: { type: Boolean, default: true },
voiceStatus: { type: Boolean, default: true },
songsHistory: { type: Array, default: [] }
leaveOnEmpty: { type: Boolean, default: true }
}
});

Expand Down Expand Up @@ -64,17 +62,3 @@ export async function getGuildOptionLeaveOnEmpty(guildID: string): Promise<boole
const guild: GuildModelClass = await getOrCreateGuildSettings(guildID);
return guild.options.leaveOnEmpty;
}

export async function setGuildOptionVoiceStatus(
guildID: string,
voiceStatus: boolean
): Promise<void> {
const guild: GuildModelClass = await getOrCreateGuildSettings(guildID);
guild.set({ options: { voiceStatus: voiceStatus } });
await guild.save();
}

export async function getGuildOptionVoiceStatus(guildID: string): Promise<boolean> {
const guild: GuildModelClass = await getOrCreateGuildSettings(guildID);
return guild.options.voiceStatus;
}

0 comments on commit 9fb9781

Please sign in to comment.