Skip to content

Commit

Permalink
add: new interface for setup (check log below)
Browse files Browse the repository at this point in the history
add: filter select menu (#100)

add: some extra button in the bottom (#148)
  • Loading branch information
RainyXeon committed Sep 7, 2024
1 parent 73a85a6 commit 850ea31
Show file tree
Hide file tree
Showing 28 changed files with 293 additions and 652 deletions.
2 changes: 1 addition & 1 deletion src/@types/Button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ export class PlayerButton {
language: string,
player: RainlinkPlayer,
nplaying: Message,
collector: InteractionCollector<ButtonInteraction<'cached'>>
collector?: InteractionCollector<ButtonInteraction<'cached'>>
): Promise<any> {}
}
4 changes: 2 additions & 2 deletions src/buttons/Clear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export default class implements PlayerButton {
language: string,
player: RainlinkPlayer,
nplaying: Message<boolean>,
collector: InteractionCollector<ButtonInteraction<'cached'>>
collector?: InteractionCollector<ButtonInteraction<'cached'>>
): Promise<any> {
if (!player) {
if (!player && collector) {
collector.stop()
}
player.queue.clear()
Expand Down
4 changes: 2 additions & 2 deletions src/buttons/Loop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export default class implements PlayerButton {
language: string,
player: RainlinkPlayer,
nplaying: Message<boolean>,
collector: InteractionCollector<ButtonInteraction<'cached'>>
collector?: InteractionCollector<ButtonInteraction<'cached'>>
): Promise<any> {
if (!player) {
if (!player && collector) {
collector.stop()
}

Expand Down
18 changes: 14 additions & 4 deletions src/buttons/Pause.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,33 @@ export default class implements PlayerButton {
language: string,
player: RainlinkPlayer,
nplaying: Message<boolean>,
collector: InteractionCollector<ButtonInteraction<'cached'>>
collector?: InteractionCollector<ButtonInteraction<'cached'>>
): Promise<any> {
if (!player) {
if (!player && collector) {
collector.stop()
}

player.data.set('pause-from-button', true)

const newPlayer = await player.setPause(!player.paused)

newPlayer.paused
? nplaying
.edit({
components: [playerRowOneEdited(client), playerRowTwo(client), filterSelect(client)],
components: [
filterSelect(client, false),
playerRowOneEdited(client, false),
playerRowTwo(client, false),
],
})
.catch(() => null)
: nplaying
.edit({
components: [playerRowOne(client), playerRowTwo(client), filterSelect(client)],
components: [
filterSelect(client, false),
playerRowOne(client, false),
playerRowTwo(client, false),
],
})
.catch(() => null)

Expand Down
4 changes: 2 additions & 2 deletions src/buttons/Previous.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export default class implements PlayerButton {
language: string,
player: RainlinkPlayer,
nplaying: Message<boolean>,
collector: InteractionCollector<ButtonInteraction<'cached'>>
collector?: InteractionCollector<ButtonInteraction<'cached'>>
): Promise<any> {
if (!player) {
if (!player && collector) {
collector.stop()
}
const previousIndex = player.queue.previous.length - 1
Expand Down
4 changes: 2 additions & 2 deletions src/buttons/Queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export default class implements PlayerButton {
language: string,
player: RainlinkPlayer,
nplaying: Message<boolean>,
collector: InteractionCollector<ButtonInteraction<'cached'>>
collector?: InteractionCollector<ButtonInteraction<'cached'>>
): Promise<any> {
if (!player) {
if (!player && collector) {
collector.stop()
}
const song = player.queue.current
Expand Down
4 changes: 2 additions & 2 deletions src/buttons/Shuffle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ export default class implements PlayerButton {
language: string,
player: RainlinkPlayer,
nplaying: Message<boolean>,
collector: InteractionCollector<ButtonInteraction<'cached'>>
collector?: InteractionCollector<ButtonInteraction<'cached'>>
): Promise<any> {
if (!player) {
if (!player && collector) {
collector.stop()
}

Expand Down
4 changes: 2 additions & 2 deletions src/buttons/Skip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export default class implements PlayerButton {
language: string,
player: RainlinkPlayer,
nplaying: Message<boolean>,
collector: InteractionCollector<ButtonInteraction<'cached'>>
collector?: InteractionCollector<ButtonInteraction<'cached'>>
): Promise<any> {
if (!player) {
if (!player && collector) {
collector.stop()
}

Expand Down
4 changes: 2 additions & 2 deletions src/buttons/Stop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export default class implements PlayerButton {
language: string,
player: RainlinkPlayer,
nplaying: Message<boolean>,
collector: InteractionCollector<ButtonInteraction<'cached'>>
collector?: InteractionCollector<ButtonInteraction<'cached'>>
): Promise<any> {
collector.stop()
if (collector) collector.stop()

player.data.set('sudo-destroy', true)
const is247 = await client.db.autoreconnect.get(`${message.guildId}`)
Expand Down
4 changes: 2 additions & 2 deletions src/buttons/VolumeDown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export default class implements PlayerButton {
language: string,
player: RainlinkPlayer,
nplaying: Message<boolean>,
collector: InteractionCollector<ButtonInteraction<'cached'>>
collector?: InteractionCollector<ButtonInteraction<'cached'>>
): Promise<any> {
if (!player) {
if (!player && collector) {
collector.stop()
}

Expand Down
4 changes: 2 additions & 2 deletions src/buttons/VolumeUp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export default class implements PlayerButton {
language: string,
player: RainlinkPlayer,
nplaying: Message<boolean>,
collector: InteractionCollector<ButtonInteraction<'cached'>>
collector?: InteractionCollector<ButtonInteraction<'cached'>>
): Promise<any> {
if (!player) {
if (!player && collector) {
collector.stop()
}

Expand Down
7 changes: 6 additions & 1 deletion src/commands/Utils/Setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { EmbedBuilder, ApplicationCommandOptionType, ChannelType } from 'discord
import { Manager } from '../../manager.js'
import { Accessableby, Command } from '../../structures/Command.js'
import { CommandHandler } from '../../structures/CommandHandler.js'
import { filterSelect, playerRowOne, playerRowTwo } from '../../utilities/PlayerControlButton.js'

export default class implements Command {
public name = ['setup']
Expand Down Expand Up @@ -92,7 +93,11 @@ export default class implements Command {
const channel_msg = await textChannel.send({
content: `${queueMsg}`,
embeds: [playEmbed],
components: [client.diSwitch],
components: [
filterSelect(client, true),
playerRowOne(client, true),
playerRowTwo(client, true),
],
})

const voiceChannel = await handler.guild!.channels.create({
Expand Down
7 changes: 6 additions & 1 deletion src/database/setup/setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Manager } from '../../manager.js'
import { filterSelect, playerRowOne, playerRowTwo } from '../../utilities/PlayerControlButton.js'
import { Setup } from '../schema/Setup.js'
import { EmbedBuilder, TextChannel } from 'discord.js'

Expand Down Expand Up @@ -55,7 +56,11 @@ export class SongRequesterCleanSetup {
.edit({
content: `${queueMsg}`,
embeds: [playEmbed],
components: [this.client.diSwitch],
components: [
filterSelect(this.client, true),
playerRowOne(this.client, true),
playerRowTwo(this.client, true),
],
})
.catch((e) => {})
}
Expand Down
25 changes: 22 additions & 3 deletions src/events/player/playerPause.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { playerRowOneEdited, playerRowTwo } from '../../utilities/PlayerControlButton.js'
import {
filterSelect,
playerRowOneEdited,
playerRowTwo,
} from '../../utilities/PlayerControlButton.js'
import { Manager } from '../../manager.js'
import { TextChannel } from 'discord.js'
import { RainlinkPlayer } from 'rainlink'
Expand All @@ -10,7 +14,13 @@ export default class {
const nowPlaying = client.nplayingMsg.get(`${player.guildId}`)
if (nowPlaying) {
nowPlaying.msg
.edit({ components: [playerRowOneEdited(client), playerRowTwo(client)] })
.edit({
components: [
filterSelect(client, false),
playerRowOneEdited(client, false),
playerRowTwo(client, false),
],
})
.catch(() => null)
}

Expand All @@ -22,11 +32,20 @@ export default class {
const channel = await client.channels.fetch(setup.channel).catch(() => undefined)
if (!channel) return
if (!channel.isTextBased) return
if (player.data.get('pause-from-button')) return player.data.delete('pause-from-button')
const msg = await (channel as TextChannel).messages
.fetch(setup.playmsg)
.catch(() => undefined)
if (!msg) return
msg.edit({ components: [client.enSwitch] }).catch(() => null)
msg
.edit({
components: [
filterSelect(client, false),
playerRowOneEdited(client, false),
playerRowTwo(client, false),
],
})
.catch(() => null)
}
}
}
20 changes: 17 additions & 3 deletions src/events/player/playerResume.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { playerRowOne, playerRowTwo } from '../../utilities/PlayerControlButton.js'
import { filterSelect, playerRowOne, playerRowTwo } from '../../utilities/PlayerControlButton.js'
import { Manager } from '../../manager.js'
import { TextChannel } from 'discord.js'
import { RainlinkPlayer } from 'rainlink'
Expand All @@ -10,7 +10,13 @@ export default class {
const nowPlaying = client.nplayingMsg.get(`${player.guildId}`)
if (nowPlaying) {
nowPlaying.msg
.edit({ components: [playerRowOne(client), playerRowTwo(client)] })
.edit({
components: [
filterSelect(client, false),
playerRowOne(client, false),
playerRowTwo(client, false),
],
})
.catch(() => null)
}

Expand All @@ -26,7 +32,15 @@ export default class {
.fetch(setup.playmsg)
.catch(() => undefined)
if (!msg) return
msg.edit({ components: [client.enSwitchMod] }).catch(() => null)
msg
.edit({
components: [
filterSelect(client, false),
playerRowOne(client, false),
playerRowTwo(client, false),
],
})
.catch(() => null)
}
}
}
6 changes: 5 additions & 1 deletion src/events/track/trackStart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ export default class {
const nplaying = playing_channel
? await playing_channel.send({
embeds: [embeded],
components: [filterSelect(client), playerRowOne(client), playerRowTwo(client)],
components: [
filterSelect(client, false),
playerRowOne(client, false),
playerRowTwo(client, false),
],
// files: client.config.bot.SAFE_PLAYER_MODE ? [] : [attachment],
})
: undefined
Expand Down
101 changes: 0 additions & 101 deletions src/handlers/Player/ButtonCommands/Loop.ts

This file was deleted.

Loading

0 comments on commit 850ea31

Please sign in to comment.