Skip to content

Commit

Permalink
Info Button
Browse files Browse the repository at this point in the history
  • Loading branch information
Kathund committed Sep 24, 2024
1 parent e70cd4b commit fe5625a
Show file tree
Hide file tree
Showing 12 changed files with 108 additions and 37 deletions.
Binary file added emojis/info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions src/Discord/Buttons/Info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import Button from '../Private/Button';
import ButtonData from '../Private/ButtonData';
import DiscordManager from '../DiscordManager';
import { ButtonInteraction } from 'discord.js';

class InfoButton extends Button {
constructor(discord: DiscordManager) {
super(discord);
this.data = new ButtonData('info');
}

async execute(interaction: ButtonInteraction): Promise<void> {
const command = interaction.client.commands.get(interaction.customId);
if (command === undefined) {
await interaction.reply({ content: 'Button not found.', ephemeral: true });
return;
}
await interaction.deferReply({ ephemeral: true });
await command.execute(interaction);
}
}

export default InfoButton;
2 changes: 1 addition & 1 deletion src/Discord/Buttons/Pause.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PauseButton extends Button {
async execute(interaction: ButtonInteraction): Promise<void> {
const command = interaction.client.commands.get(interaction.customId);
if (command === undefined) {
await interaction.reply({ content: 'Can i click ur buttons?', ephemeral: true });
await interaction.reply({ content: 'Button not found.', ephemeral: true });
return;
}
await command.execute(interaction);
Expand Down
2 changes: 1 addition & 1 deletion src/Discord/Buttons/Play.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PlayButton extends Button {
async execute(interaction: ButtonInteraction): Promise<void> {
const command = interaction.client.commands.get(interaction.customId);
if (command === undefined) {
await interaction.reply({ content: 'Can i click ur buttons?', ephemeral: true });
await interaction.reply({ content: 'Button not found.', ephemeral: true });
return;
}
await command.execute(interaction);
Expand Down
2 changes: 1 addition & 1 deletion src/Discord/Buttons/Previous.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PreviousButton extends Button {
async execute(interaction: ButtonInteraction): Promise<void> {
const command = interaction.client.commands.get(interaction.customId);
if (command === undefined) {
await interaction.reply({ content: 'Can i click ur buttons?', ephemeral: true });
await interaction.reply({ content: 'Button not found.', ephemeral: true });
return;
}
await command.execute(interaction);
Expand Down
2 changes: 1 addition & 1 deletion src/Discord/Buttons/Queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class QueueButton extends Button {
async execute(interaction: ButtonInteraction): Promise<void> {
const command = interaction.client.commands.get(interaction.customId);
if (command === undefined) {
await interaction.reply({ content: 'Can i click ur buttons?', ephemeral: true });
await interaction.reply({ content: 'Button not found.', ephemeral: true });
return;
}
await command.execute(interaction);
Expand Down
2 changes: 1 addition & 1 deletion src/Discord/Buttons/Shuffle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ShuffleButton extends Button {
async execute(interaction: ButtonInteraction): Promise<void> {
const command = interaction.client.commands.get(interaction.customId);
if (command === undefined) {
await interaction.reply({ content: 'Can i click ur buttons?', ephemeral: true });
await interaction.reply({ content: 'Button not found.', ephemeral: true });
return;
}
await command.execute(interaction);
Expand Down
2 changes: 1 addition & 1 deletion src/Discord/Buttons/Skip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SkipButton extends Button {
async execute(interaction: ButtonInteraction): Promise<void> {
const command = interaction.client.commands.get(interaction.customId);
if (command === undefined) {
await interaction.reply({ content: 'Can i click ur buttons?', ephemeral: true });
await interaction.reply({ content: 'Button not found.', ephemeral: true });
return;
}
await command.execute(interaction);
Expand Down
26 changes: 0 additions & 26 deletions src/Discord/Commands/About.ts

This file was deleted.

66 changes: 66 additions & 0 deletions src/Discord/Commands/Info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import Command from '../Private/Command';
import CommandData from '../Private/CommandData';
import DiscordManager from '../DiscordManager';
import Embed from '../Private/Embed';
import { ButtonInteraction, ChatInputCommandInteraction } from 'discord.js';

class InfoCommand extends Command {
constructor(discord: DiscordManager) {
super(discord);
this.data = new CommandData().setName('info').setDescription('info');
}

async execute(interaction: ChatInputCommandInteraction | ButtonInteraction): Promise<void> {
const app = await interaction.client.application.fetch();
await interaction.followUp({
embeds: [
new Embed({
title: 'Spotify Manager',
description: `Spotify Manager made with :purple_heart: by <@1276524855445164098>\nOpen source on [Github](https://github.com/Kathund/Spotify-Manager)\n\n**Stats:**\nServers: ${
app.approximateGuildCount || 0
}\nUser Installs: ${app.approximateUserInstallCount || 0}`
}).addFields(
{
name: 'Buttons',
value: `${this.discord.emojis.get(
'shuffle'
)} Shuffle Button | Toggles the shuffle mode between off and on!\n${this.discord.emojis.get(
'back'
)} Previous Song Button | Go back a song\n${this.discord.emojis.get(
'pause'
)} Pause Button | Pause the music\n${this.discord.emojis.get(
'play'
)} Play Button | Play the music\n${this.discord.emojis.get(
'forward'
)} Skip Song Button | Skip the current song\n${this.discord.emojis.get(
'repeatOne'
)} Repeat One Button | Toggles between being on Repeat Track and Repeat Context\n${this.discord.emojis.get(
'refresh'
)} Refresh Button | Refreshes playback info\n${this.discord.emojis.get(
'queue'
)} Queue Button | View upcomming queue\n${this.discord.emojis.get(
'spotify'
)} Spotify Button | Opens the current song's url\n${this.discord.emojis.get(
'info'
)} Info Button | Displays this info embed`
},
{
name: 'Emojis',
value: `${this.discord.emojis.get(
'explicit'
)} | Shows if the song is tagged explicit\n${this.discord.emojis.get(
'local'
)} | Shows if the song is a local file`
},
{
name: 'Credits',
value: 'Default Emojis/Button Icons are sourced from [Icons discord server](https://discord.gg/aPvvhefmt3)'
}
)
],
ephemeral: interaction.isButton()
});
}
}

export default InfoCommand;
13 changes: 9 additions & 4 deletions src/Spotify/Private/API/Playback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ class Playback {
if (!this.item) {
return new Embed({ title: 'Nothing is playing.', description: 'User has nothing playing on spotify' });
}
return this.item
const embed = this.item
.toEmbed(emojis)
.setTitle(`Currently ${this.playing ? 'Playing' : 'Paused'}`)
.addFields({ name: 'Progress', value: this.getPrograssBar() })
.addFields({ name: 'Volume', value: this.getVolumeBar() });
.addFields({ name: 'Progress', value: this.getPrograssBar() });
if (this.device?.supportsVolume) embed.addFields({ name: 'Volume', value: this.getVolumeBar() });
return embed;
}

toButtons(emojis: Collection<string, string>): ActionRowBuilder<ButtonBuilder>[] {
Expand Down Expand Up @@ -108,7 +109,11 @@ class Playback {
new ButtonBuilder()
.setEmoji(emojis.get('spotify') || '')
.setStyle(ButtonStyle.Link)
.setURL(this.item.spotifyUrl || 'https://open.spotify.com')
.setURL(this.item.spotifyUrl || 'https://open.spotify.com'),
new ButtonBuilder()
.setEmoji(emojis.get('info') || '')
.setStyle(ButtonStyle.Primary)
.setCustomId('info')
)
];
}
Expand Down
5 changes: 4 additions & 1 deletion src/Spotify/Private/API/Queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ class Queue {
}

toEmbed(emojis: Collection<string, string>): EmbedBuilder {
const embed = new Embed({ title: 'Queue', description: 'Upcomming Queue' });
const embed = new Embed({
title: 'Queue',
description: 'Upcomming Queue\n**Warning: ** This dose not show local files'
});
this.queue.map((track) => {
embed.addFields({
name: `${track.name} ${track.toEmojis(emojis)}`,
Expand Down

0 comments on commit fe5625a

Please sign in to comment.