Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
08a67bd
Start of new branch, added loudspeaker login but no actual music play…
CombustibleToast Mar 21, 2023
0043f45
Added recursive file finding for ./commands
CombustibleToast Mar 29, 2023
d7fb898
progress on adding music functionality, see https://discord.com/chann…
CombustibleToast Mar 29, 2023
ccba5c6
Update
CombustibleToast Mar 29, 2023
01b444a
Progress on adding music functionality
CombustibleToast Mar 29, 2023
f024991
Added the suggestion provided to me by someone in the DJS discord ser…
CombustibleToast Mar 30, 2023
a386d48
Fixed loudspeaker IDs not properly being used as values in the map
CombustibleToast May 18, 2023
05fe16d
Moved to the music commands folder
CombustibleToast May 18, 2023
0e6458b
Added a comment
CombustibleToast May 18, 2023
4ac4d17
Changed the function to only return the status.
CombustibleToast May 18, 2023
340bb6e
Added disconnect functionality
CombustibleToast May 18, 2023
9c4a030
Now initializes the assigned loudspeaker.
CombustibleToast May 18, 2023
6ea88d7
Added voice gateway intent bits to loudspeaker
CombustibleToast May 18, 2023
e8ecdc3
Added youtube packages
CombustibleToast May 19, 2023
01b91b3
Now will call enqueue function then resume playback.
CombustibleToast May 19, 2023
0d3f9bf
Added
CombustibleToast May 19, 2023
706b4e0
Added a voice channel check.
CombustibleToast May 19, 2023
c50e095
Now destroys the queue and unlinks the connection.
CombustibleToast May 19, 2023
fbaa773
Now replaced by enqueue.js function.
CombustibleToast May 19, 2023
df33b11
Changed response to include the link of the video using markdown.
CombustibleToast May 25, 2023
351e1c6
added
CombustibleToast May 29, 2023
537a2fd
update
CombustibleToast May 29, 2023
17a861f
Added call to resume.js to start playback
CombustibleToast May 29, 2023
9000126
Attempting to bugfix playback autopausing
CombustibleToast May 29, 2023
538913c
Thought it would be a good idea to destroy the player but that's not …
CombustibleToast May 29, 2023
b1e1148
Added comment detailing weird search bug and a fix for it.
CombustibleToast May 29, 2023
1463472
moved player debugging to connectLoudspeaker.js
CombustibleToast Jun 2, 2023
b2dda6d
Pause functionality added
CombustibleToast Jun 2, 2023
f058f4b
Added parent client (CAROLINE's client) as a loudspeaker attribute fo…
CombustibleToast Jun 2, 2023
5972525
Improved response formatting.
CombustibleToast Jun 2, 2023
23529fb
No longer used by anything
CombustibleToast Jun 2, 2023
2271395
Fixed the issue where playback would stop after 1 min.
CombustibleToast Jun 2, 2023
394d7fb
Provides feedback if there was no query to enqueue.
CombustibleToast Jun 2, 2023
9d0cc3f
Changed multiple ifs to a switch block.
CombustibleToast Jun 2, 2023
6e1803a
AudioPlayerStatus no longer needed, moved to connectLoudspeaker.js
CombustibleToast Jun 2, 2023
99c4a23
Added different functionalities for different player statuses.
CombustibleToast Jun 2, 2023
a445005
Added
CombustibleToast Jun 2, 2023
beceb3c
Added comment
CombustibleToast Jun 2, 2023
9bcc28d
Added
CombustibleToast Jun 2, 2023
7ef859c
Removed a debugging log
CombustibleToast Jun 2, 2023
ecffa2a
Description wording changed
CombustibleToast Jun 2, 2023
c8284b3
Added. Seems to work.
CombustibleToast Jun 3, 2023
b3d4d0e
Added.
CombustibleToast Jun 3, 2023
9201fa8
Removed a lot of debugging code.
CombustibleToast Jun 3, 2023
f86a5dc
Changed description wording and fixed interaction replying.
CombustibleToast Jun 3, 2023
717544a
Fixed logical error and improved response.
CombustibleToast Jun 3, 2023
a48efbc
Works properly now.
CombustibleToast Jun 3, 2023
e423adf
Implemented not readding songs during loop handling.
CombustibleToast Jun 3, 2023
da02226
Added and working
CombustibleToast Jun 3, 2023
196dbad
Implemented edge case where looped songs shouldn't be readded if they…
CombustibleToast Jun 3, 2023
c336f5e
removed debugging code
CombustibleToast Jun 3, 2023
bb00bf6
removed debugging code
CombustibleToast Jun 3, 2023
2586baf
renamed a variable to be more descriptive
CombustibleToast Jun 3, 2023
511c100
Now clears queue and destroys player.
CombustibleToast Jun 3, 2023
d02fd83
attempting to fix an issue where the same bot will leave a channel an…
CombustibleToast Jun 3, 2023
c0f6ec8
Randomized which loudspeaker is assigned.
CombustibleToast Jun 3, 2023
d9374d5
Changed log text
CombustibleToast Jun 3, 2023
23ad1c3
Removed debugging logs
CombustibleToast Jun 3, 2023
07f6276
Package update
CombustibleToast Jun 3, 2023
1b0f7e1
Added
CombustibleToast Jun 3, 2023
101681e
Edited log outputs.
CombustibleToast Jun 3, 2023
1d4fe65
Attempted to fix #1
CombustibleToast Jun 3, 2023
be42d48
Added a semicolon
CombustibleToast Jun 3, 2023
4f2e602
Removed the option to skip the current song, idk why it was there
CombustibleToast Jun 3, 2023
26b898b
youtube-dl-exec installed
CombustibleToast Jun 3, 2023
ce2a66d
Improved response logic.
CombustibleToast Jun 3, 2023
c427599
removed debug logs
CombustibleToast Jun 3, 2023
1a1b5ce
Transitioned all frontend (replies) from the command to the function.
CombustibleToast Jun 3, 2023
60040e4
Added to remove code redundancy in a lot of functions.
CombustibleToast Jun 3, 2023
263ed89
Transitioned responses to function backend.
CombustibleToast Jun 3, 2023
2281846
removed debugging log
CombustibleToast Jun 3, 2023
d688821
Switched around order of interaction replies.
CombustibleToast Jun 3, 2023
44a4d76
Transitioned frontend responses to function.
CombustibleToast Jun 3, 2023
1be37fa
Formatting
CombustibleToast Jun 3, 2023
a31bbad
Autoplayer now checks if the player exists before playing the next song.
CombustibleToast Jun 3, 2023
8449488
Moved things around and added a field to notify the autoplayer that t…
CombustibleToast Jun 3, 2023
3ceef2e
Transitioned frontend responses to function.
CombustibleToast Jun 3, 2023
9a53884
improved response
CombustibleToast Jun 3, 2023
e941473
Replaced with /leave in leave.js
CombustibleToast Jun 3, 2023
d857f05
Transitioned frontend responses to function.
CombustibleToast Jun 3, 2023
012a290
Transitioned frontend responses to function.
CombustibleToast Jun 3, 2023
c35eb65
Transitionted frontend responses to function.
CombustibleToast Jun 3, 2023
da99706
Transitioned frontend responses to function.
CombustibleToast Jun 3, 2023
8024e66
Fixed guard clause logic.
CombustibleToast Jun 3, 2023
734a5b9
Transitioned frontend responses to function.
CombustibleToast Jun 3, 2023
e185b18
Transitioned frontend responses to function.
CombustibleToast Jun 3, 2023
1e300be
Transitioned frontend responses to function.
CombustibleToast Jun 3, 2023
c32193f
Fixes #2
CombustibleToast Jun 3, 2023
58a6351
Since this is called by another function that replies to an interacti…
CombustibleToast Jun 3, 2023
3cc33d7
same as previous commit
CombustibleToast Jun 3, 2023
7555ed7
Fixed weird interactions with replying to already replied interactions.
CombustibleToast Jun 3, 2023
697a903
Added, seems to work
CombustibleToast Jun 4, 2023
cb83d7d
Changed a comment
CombustibleToast Jun 4, 2023
ec95384
Added initiailize music button functionality.
CombustibleToast Jun 4, 2023
1c09ce1
Added try-catch to ytsr because it sucks lol.
CombustibleToast Jun 4, 2023
8d9610e
Added compatibility with enqueueModal.
CombustibleToast Jun 4, 2023
155cda9
Added. For use with music control buttons.
CombustibleToast Jun 4, 2023
e81fbb0
Added compatibility with music button controls.
CombustibleToast Jun 4, 2023
baab8cb
Fixed messages not being sent/edited when used with button controls.
CombustibleToast Jun 4, 2023
e378712
Added compatibility with music button controls.
CombustibleToast Jun 4, 2023
8bdaedc
Added latent check.
CombustibleToast Jun 4, 2023
3eecc7f
Added queue empty check.
CombustibleToast Jun 4, 2023
1600017
Fixed logic for latent check.
CombustibleToast Jun 4, 2023
1cfd20c
Added custom latent test since modals require the interaction to not …
CombustibleToast Jun 4, 2023
dcfb57c
Added compatibility with music control buttons.
CombustibleToast Jun 4, 2023
0fced4b
Added extra queue overflow viewing functionality.
CombustibleToast Jun 4, 2023
3efb6d4
Added button to squelch replies.
CombustibleToast Jun 4, 2023
b0931e8
Added support for looping a single song.
CombustibleToast Jun 4, 2023
c758575
removed squelch option for now
CombustibleToast Jun 4, 2023
838cc52
Package update
CombustibleToast Jun 5, 2023
55afacd
Changed comment
CombustibleToast Jun 5, 2023
c9e370d
package update
CombustibleToast Jun 5, 2023
60f82c9
Going to try ignoring the packages for merging
CombustibleToast Jun 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ secrets*
deploycommands.json
data/existingGames/*.json
data/gameApplications/*.json
data/archivedGames/*.json
data/archivedGames/*.json
node_modules/*
137 changes: 125 additions & 12 deletions commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,29 @@ module.exports = {
//command definition for discord API
data: new SlashCommandBuilder()
.setName('init')
.setDescription('what could this be?'),
.setDescription('what could this be?')
.addStringOption(option =>
option
.setName("type")
.setDescription("gaming")),

//the funciton to be run
async execute(interaction){
if(interaction.user.id != '122065561428426755'){
await interaction.reply({content: "Permission Denied", ephemeral: true});
async execute(interaction) {
if (interaction.user.id != '122065561428426755') {
await interaction.reply({ content: "Permission Denied", ephemeral: true });
return;
}

await initGmAndReportForm(interaction);
interaction.reply({content:"Done", ephemeral:"true"})
const choice = interaction.options.getString("type");
switch (choice) {
case "music":
await initMusicButtons(interaction);
break;
default:
await initGmAndReportForm(interaction);
break;
}
await interaction.reply({ content: "Done", ephemeral: "true" })
}
}

Expand All @@ -27,14 +39,115 @@ async function initGmAndReportForm(interaction) {
const actionRow = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId("pushGmForm")
.setLabel("GM Form")
.setStyle(ButtonStyle.Primary),
.setCustomId("pushGmForm")
.setLabel("GM Form")
.setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId("pushReportForm")
.setLabel("Report Form")
.setStyle(ButtonStyle.Danger)
.setCustomId("pushReportForm")
.setLabel("Report Form")
.setStyle(ButtonStyle.Danger)
);

await interaction.channel.send({ embeds: [embed], components: [actionRow] });
}

async function initMusicButtons(interaction) {
//row 1
//join(green), leave(red),

const row1 = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId("join")
.setEmoji('📻')
.setLabel("Join")
.setStyle(ButtonStyle.Success),
new ButtonBuilder()
.setCustomId("leave")
.setEmoji('👋')
.setLabel("Leave")
.setStyle(ButtonStyle.Danger),
/*
new ButtonBuilder()
.setCustomId("squelch")
.setEmoji('🔕')
.setLabel("Disable Replies")
.setStyle(ButtonStyle.Secondary)
*/
);

//row 2
//enqueue(modal??), clear, queue, nowplaying
const row2 = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId("enqueueModal")
//.setEmoji('')
.setLabel("Add Song")
.setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId("clearQueue")
//.setEmoji('')
.setLabel("Clear Queue")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId("showQueue")
//.setEmoji('')
.setLabel("Show Queue")
.setStyle(ButtonStyle.Secondary),
new ButtonBuilder()
.setCustomId("nowPlaying")
//.setEmoji('')
.setLabel("Now Playing")
.setStyle(ButtonStyle.Secondary)
);

//row 3
//loop, loopOne, shuffle
const row3 = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId("loop")
.setEmoji('🔁')
//.setLabel("")
.setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId("loopOne")
.setEmoji('🔂')
//.setLabel("")
.setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId("shuffleQueue")
.setEmoji('🔀')
//.setLabel("")
.setStyle(ButtonStyle.Secondary)
);

//row 4
//resume, pause, skip,
const row4 = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId("resumePlayback")
.setEmoji('▶️')
//.setLabel("")
.setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId("pause")
.setEmoji('⏸️')
//.setLabel("")
.setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId("skip")
.setEmoji('⏭️')
//.setLabel("")
.setStyle(ButtonStyle.Secondary),
);

//send rows as messages
const channel = interaction.channel;
await channel.send({ components: [row1] });
await channel.send({ components: [row2] });
await channel.send({ components: [row3] });
await channel.send({ components: [row4] });
}
16 changes: 16 additions & 0 deletions commands/music commands/clear.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName("clear")
.setDescription("Clears the playlist.")
.addBooleanOption(option =>
option
.setName("clearcurrentlyplaying")
.setDescription("Should the current song also be removed and skipped?")
.setRequired(false)),

async execute(interaction) {
await interaction.client.functions.get("clearQueue").execute(interaction);
}
}
17 changes: 17 additions & 0 deletions commands/music commands/enqueue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName("enqueue")
.setDescription("Adds a song to the playlist.")
.addStringOption(option =>
option
.setName("query")
.setDescription("Enter a Youtube video or playlist URL, or enter a search query.")
.setRequired(true)
),

async execute(interaction) {
await interaction.client.functions.get("enqueue").execute(interaction);
}
}
12 changes: 12 additions & 0 deletions commands/music commands/join.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const { SlashCommandBuilder } = require('discord.js')

module.exports = {
//command definition for discord API
data: new SlashCommandBuilder()
.setName('join')
.setDescription('Assigns a loudspeaker to your channel.'),

async execute(interaction) {
await interaction.client.functions.get("join").execute(interaction);
}
}
11 changes: 11 additions & 0 deletions commands/music commands/leave.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName("leave")
.setDescription("Disconnects a loudspeaker from your channel."),

async execute(interaction) {
await interaction.client.functions.get("leave").execute(interaction);
}
}
15 changes: 15 additions & 0 deletions commands/music commands/loop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName("loop")
.setDescription("Sets the playlist on a loop. If not given a choice, on/off will be toggled.")
.addBooleanOption(option =>
option
.setName('on')
.setDescription("True turns loop on, False turns loop off.")),

async execute(interaction) {
await interaction.client.functions.get("loop").execute(interaction);
}
}
11 changes: 11 additions & 0 deletions commands/music commands/nowplaying.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName("nowplaying")
.setDescription("Displays the current song."),

async execute(interaction) {
await interaction.client.functions.get("nowPlaying").execute(interaction);
}
}
11 changes: 11 additions & 0 deletions commands/music commands/pause.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName("pause")
.setDescription("Pauses playback."),

async execute(interaction) {
await interaction.client.functions.get("pause").execute(interaction);
}
}
52 changes: 52 additions & 0 deletions commands/music commands/play.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const { SlashCommandBuilder } = require('discord.js')

module.exports = {
data: new SlashCommandBuilder()
.setName("play")
.setDescription("Plays a Youtube video or playlist given a URL or search query.")
.addStringOption(option =>
option
.setName("query")
.setDescription("Enter a Youtube video or playlist URL, or enter a search query.")
.setRequired(false)
),

/**
* This function should:
* Assign a new vacant loudspeaker to the user's channel if there isn't one already already assigned and have it join the channel.
* If there is no queue, create a new one.
* Parse whether the query is a video link, playlist link, or search term and enqueue the found video(s).
* If there is no query, unpause the playback (call resume.js).
* If there is a query and the queue was previously empty, start playback.
*/
async execute(interaction) {
if (!interaction.member.voice.channel) {
await interaction.reply({ content: "You need to be in a voice channel to use music commands.", ephemeral: true });
return;
}

await interaction.deferReply({ephemeral: true});

const result = await interaction.client.functions.get("connectLoudspeaker").execute(interaction);
let response = "";
//respond to the user
switch (result.status) {
case "no vacancies":
response = "Unfortunately there are no vacant loudspeakers at this time.\n";
break;
case "already assigned":
response = "";
break;
case "new assignment":
response = "Assigned a loudspeaker to your channel.\n"
break;
}

response += await interaction.client.functions.get("enqueue").execute(interaction) + "\n";

//TODO: resume/start playback
response += await interaction.client.functions.get("resumePlayback").execute(interaction);

await interaction.editReply(response);
}
}
11 changes: 11 additions & 0 deletions commands/music commands/queue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName("queue")
.setDescription("Shows the queue."),

async execute(interaction) {
await interaction.client.functions.get("showQueue").execute(interaction);
}
}
11 changes: 11 additions & 0 deletions commands/music commands/resume.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName("resume")
.setDescription("Resumes playback."),

async execute(interaction) {
await interaction.client.functions.get("resumePlayback").execute(interaction);
}
}
11 changes: 11 additions & 0 deletions commands/music commands/shuffle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName("shuffle")
.setDescription("Shuffles the playlist."),

async execute(interaction) {
await interaction.client.functions.get("shuffleQueue").execute(interaction);
}
}
15 changes: 15 additions & 0 deletions commands/music commands/skip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName("skip")
.setDescription("Skips current song.")
.addBooleanOption(option =>
option
.setName('pause')
.setDescription("(Default is false/no) Should the next song be paused?")),

async execute(interaction) {
await interaction.client.functions.get("skip").execute(interaction);
}
}
Loading