Skip to content

Commit

Permalink
πŸ”– 2.0.0: The 2022 Summer Update
Browse files Browse the repository at this point in the history
Read release notes for more information.
  • Loading branch information
daniwasonline authored Jun 18, 2022
2 parents 69bd5bb + ec7c03e commit 64ba514
Show file tree
Hide file tree
Showing 22 changed files with 197 additions and 138 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ A list of key people in Songfish will be provided below:
- [Bren](https://github.com/smatman): The sole person who inspired me to create this bot. His bird, Edward (Eddie), is the namesake of the VIP instance of Songfish (Edward's Tunes)!

### Translators
**NOTE: Translations are not complete, and current translations may be inaccurate or incorrect in grammar. Please help us out by providing native translations - thank you!**

- [NeverLand](https://github.com/ItsNeverLand): pt-PT (Portugal Portuguese)
- [Myself (Dannington)](https://danny.works): Original/en-GB (UK English), fr-FR (French), and fr-CA (Canadian/Quebecois French)
- [Myself (Dannington)](https://danny.works): Original/en-GB (UK English), fr-FR (French)
- [Mustafa](https://musti.codes/): tr-TR (Turkish)
11 changes: 0 additions & 11 deletions VERSIONING.md

This file was deleted.

34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{
"name": "songfish",
"version": "22.0.1.0",
"version": "2.0.0",
"description": "An open-sourced music bot for Discord",
"main": "src/index.js",
"repository": "https://github.com/Dannnington/songfish.git",
"author": "Daniel Hyders <[email protected]>",
"license": "GPL-3.0-or-later",
"private": false,
"dependencies": {
"@discordjs/builders": "^0.6.0",
"@discordjs/collection": "^0.2.1",
"@discordjs/rest": "^0.1.0-canary.0",
"@keyv/mongo": "^1.1.0",
"@keyv/redis": "^2.1.2",
"@lavaclient/queue": "^2.0.6",
"@lavaclient/spotify": "^3.0.0",
"array.prototype.move": "^0.0.4",
"@discordjs/builders": "0.15.0",
"@discordjs/collection": "0.7.0",
"@discordjs/rest": "0.5.0",
"@keyv/mongo": "2.1.6",
"@keyv/redis": "2.3.6",
"@lavaclient/queue": "2.0.6",
"@lavaclient/spotify": "3.0.0",
"array.prototype.move": "0.0.4",
"chalk": "^4.1.2",
"discord-api-types": "^0.23.1",
"discord.js-light": "^4.5.2",
"discord.js": "^13.6.0",
"duration-pretty": "^0.1.1",
"keyv": "^4.0.3",
"lavaclient": "^4.0.4",
"discord-api-types": "0.34.0",
"discord.js": "13.8.0",
"discord.js-light": "4.8.0",
"duration-pretty": "0.1.1",
"keyv": "4.3.0",
"lavaclient": "4.0.8",
"node-fetch": "^3.0.0",
"spotify-url-info": "^2.2.3",
"string-progress": "^1.8.9"
"spotify-url-info": "3.1.2",
"string-progress": "1.8.9"
},
"scripts": {
"start": "node src/index.js"
Expand Down
110 changes: 68 additions & 42 deletions src/i18n/locales/moduleconfig.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const path = require("path");
const { Options } = require("discord.js-light");
const { Client, Intents } = require("discord.js");
const { Routes } = require("discord-api-types/v9");
const { Cluster } = require("lavaclient");
const { Cluster, Player } = require("lavaclient");
const { load } = require("@lavaclient/spotify");
const { PlayerManager, YouTubeManager } = require("./lib/MusicManagers");

Expand Down Expand Up @@ -93,7 +93,7 @@ for (const f of cmdDir) {
async function postCommands() {
const api = new API.REST({ version: "9" }).setToken(config.discord.clientToken);

if (config.testing === true) api.put(Routes.applicationGuildCommands(config.discord.clientID, "905257442626113547"), { body: cmdMetadata });
if (config.testing === true) api.put(Routes.applicationGuildCommands(config.discord.clientID, config.testingServerID), { body: cmdMetadata });
else await api.put(Routes.applicationCommands(config.discord.clientID), { body: cmdMetadata });

return true;
Expand All @@ -104,10 +104,10 @@ client.on("ready", function () {
if (config.discord.status.type) status.type = config.discord.status.type;
if (config.discord.status.content) status.content = config.discord.status.content;
console.log(`${chalk.green("READY")} || ${client.user.tag} is ready (${new Date().toUTCString()})`);
console.log(`${chalk.blue("INFO")} || Invite Songfish using the following link: https://discord.com/api/oauth2/authorize?client_id=${config.discord.clientID}&permissions=8&scope=bot%20applications.commands`);
client.user.setActivity(status.content, { type: status.type });
lavalink.connect(client.user.id);
client.lavalink = lavalink;

});

client.on("interactionCreate", async (interaction) => {
Expand Down
7 changes: 4 additions & 3 deletions src/interactions/clear.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { MessageEmbed } = require("discord.js-light");
const { LoopType } = require("@lavaclient/queue/dist/Queue");
const { LocalizationManager } = require('../lib/StringManagers');

module.exports = {
metadata: new SlashCommandBuilder()
Expand All @@ -10,15 +11,15 @@ module.exports = {
await interaction.deferReply();
let err;
if (interaction.member.voice.channelId === null || interaction.member.voice.channelId === undefined) {
return interaction.editReply("You must be in a voice channel in order to use this command.");
return interaction.editReply(LocalizationManager.localizeString("general", "userNotInVoiceChannel", interaction.locale));
};

if (interaction.guild.me.voice.channelId === null || interaction.guild.me.voice.channelId === undefined) {
return interaction.editReply("I am not currently playing audio in a voice channel!");
return interaction.editReply(LocalizationManager.localizeString("general", "notPlayingAudio", interaction.locale));
};

if (interaction.guild.me.voice.channelId !== interaction.member.voice.channelId) {
return interaction.editReply("I am not currently playing audio in the voice channel that you are in!");
return interaction.editReply(LocalizationManager.localizeString("general", "userNotInBotChannel", interaction.locale));
};

try {
Expand Down
12 changes: 7 additions & 5 deletions src/interactions/disconnect.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { MessageEmbed } = require("discord.js-light");
const { LocalizationManager } = require('../lib/StringManagers');

module.exports = {
metadata: new SlashCommandBuilder()
Expand All @@ -8,16 +9,17 @@ module.exports = {
run: async (client, interaction) => {
await interaction.deferReply();
let err;

if (interaction.member.voice.channelId === null || interaction.member.voice.channelId === undefined) {
return interaction.editReply("You must be in a voice channel in order to use this command.");
return interaction.editReply(LocalizationManager.localizeString("general", "userNotInVoiceChannel", interaction.locale));
};

if (interaction.guild.me.voice.channelId === null || interaction.guild.me.voice.channelId === undefined) {
return interaction.editReply("I am not currently in a voice channel!");
return interaction.editReply(LocalizationManager.localizeString("general", "notPlayingAudio", interaction.locale));
};

if (interaction.guild.me.voice.channelId !== interaction.member.voice.channelId) {
return interaction.editReply("I am not currently playing audio in the voice channel that you are in!");
return interaction.editReply(LocalizationManager.localizeString("general", "userNotInBotChannel", interaction.locale));
};

try {
Expand All @@ -28,9 +30,9 @@ module.exports = {
await client.lavalink.destroyPlayer(interaction.guild.id);
} catch (e) {
err = true;
return interaction.editReply(`An exception occurred whilst attempting to disconnect the bot. Try again later.`);
return interaction.editReply(LocalizationManager.localizeString("disconnect", "error", interaction.locale));
};

return interaction.editReply("🚫 Disconnected from your voice channel.");
return interaction.editReply(LocalizationManager.localizeString("disconnect", "success", interaction.locale));
}
};
9 changes: 6 additions & 3 deletions src/interactions/inviteManager.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { LocalizationManager } = require('../lib/StringManagers');

module.exports = {
metadata: new SlashCommandBuilder()
Expand All @@ -8,15 +9,17 @@ module.exports = {
o.setName("operation")
.setDescription("Select an operation")
.setRequired(true)
.addChoice("Add", "add")
.addChoice("Remove", "remove"))
.addChoices(
{ name: "Remove", value: "remove" },
{ name: "Add", value: "add" }
))
.addStringOption(o =>
o.setName("guild")
.setDescription("The ID of the guild to add or remove from the list of authorized guilds")
.setRequired(true)),
run: async (client, interaction) => {
await interaction.deferReply({ ephemeral: false });
if (!client.config.proctors.includes(interaction.member.id)) return interaction.editReply("You are not a proctor!");
if (!client.config.proctors.includes(interaction.member.id)) return interaction.editReply(LocalizationManager.localizeString("general", "noPermission", interaction.locale));
const operation = interaction.options.getString("operation");
const guild = interaction.options.getString("guild");

Expand Down
13 changes: 7 additions & 6 deletions src/interactions/join.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { MessageEmbed } = require("discord.js-light");
const { LocalizationManager } = require('../lib/StringManagers');

module.exports = {
metadata: new SlashCommandBuilder()
Expand All @@ -9,18 +10,18 @@ module.exports = {
await interaction.deferReply();
let err;
if (interaction.member.voice.channelId === null || interaction.member.voice.channelId === undefined) {
return interaction.editReply("You must be in a voice channel in order to use this command.");
return interaction.editReply(LocalizationManager.localizeString("general", "userNotInVoiceChannel", interaction.locale));
};

if (interaction.guild.me.voice.channelId !== null && interaction.guild.me.voice.channelId !== undefined) {
if (interaction.guild.me.voice.channelId !== interaction.member.voice.channelId) return interaction.editReply("I am currently in a voice channel. Try again later.");
if (interaction.guild.me.voice.channelId !== interaction.member.voice.channelId) return interaction.editReply(LocalizationManager.localizeString("general", "userNotInBotChannel", interaction.locale));
};

const vcType = interaction.guild.channels.cache.get(interaction.member.voice.channelId).type;

try {
const player = await client.lavalink.manager.fetch(interaction);
if (player.connected) return interaction.editReply("I'm already connected to your voice channel!");
if (player.connected) return interaction.editReply(LocalizationManager.localizeString("join", "alreadyConnected", interaction.locale));
await player.connect(interaction.member.voice.channelId);

if (vcType === "GUILD_STAGE_VOICE" && interaction.guild.me.voice.suppress) await interaction.guild.me.voice.setSuppressed(false);
Expand All @@ -34,9 +35,9 @@ module.exports = {
err = true;
const chalk = require("chalk");
console.log(`${chalk.red("ERROR")} || Songfish was able to successfully handle an exception (${new Date().toUTCString()}). Here is a debug stack trace in the case that you'd like to see the error:\n${e.stack}`);
return interaction.editReply(`An exception occurred whilst attempting to connect the bot. Try again later.`);
return interaction.editReply(LocalizationManager.localizeString("join", "error", interaction.locale));
};

return interaction.editReply(`β˜‘οΈ Connected to <#${interaction.member.voice.channelId}>.`);
return interaction.editReply(`${LocalizationManager.localizeString("join", "success", interaction.locale, `<#${interaction.member.voice.channelId}>`)}`);
}
};
25 changes: 14 additions & 11 deletions src/interactions/loop.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { MessageEmbed } = require("discord.js-light");
const { LocalizationManager } = require('../lib/StringManagers');

module.exports = {
metadata: new SlashCommandBuilder()
Expand All @@ -9,9 +10,11 @@ module.exports = {
o.setName("mode")
.setDescription("The loop mode")
.setRequired(true)
.addChoice("Queue", "Queue")
.addChoice("Audio", "Song")
.addChoice("Disable", "None")),
.addChoices(
{ name: "Queue", value: "Queue" },
{ name: "Audio", value: "Song" },
{ name: "Disable", value: "None" }
)),
run: async (client, interaction) => {
const { LoopType } = require("@lavaclient/queue/dist/Queue");
await interaction.deferReply();
Expand All @@ -20,30 +23,30 @@ module.exports = {

let err;
if (interaction.member.voice.channelId === null || interaction.member.voice.channelId === undefined) {
return interaction.editReply("You must be in a voice channel in order to use this command.");
return interaction.editReply(LocalizationManager.localizeString("general", "userNotInVoiceChannel", interaction.locale));
};

if (interaction.guild.me.voice.channelId === null || interaction.guild.me.voice.channelId === undefined) {
return interaction.editReply("I am not currently playing audio in a voice channel!");
return interaction.editReply(LocalizationManager.localizeString("general", "notPlayingAudio", interaction.locale));
};

if (interaction.guild.me.voice.channelId !== interaction.member.voice.channelId) {
return interaction.editReply("I am not currently playing audio in the voice channel that you are in!");
return interaction.editReply(LocalizationManager.localizeString("general", "userNotInBotChannel", interaction.locale));
};

try {
const player = await client.lavalink.manager.fetch(interaction);
if (!player.track) return interaction.editReply("There isn't an audio playing right now!");
if (!player.track) return interaction.editReply(LocalizationManager.localizeString("general", "noAudioPlayingInVC", interaction.locale));
await player.queue.setLoop(LoopType[mode]);
} catch (e) {
err = true;
const chalk = require("chalk");
console.log(`${chalk.red("ERROR")} || Songfish was able to successfully handle an exception (${new Date().toUTCString()}). Here is a debug stack trace in the case that you'd like to see the error:\n${e.stack}`);
return interaction.editReply(`An exception occurred whilst attempting to loop the audio. Try again later.`);
return interaction.editReply(LocalizationManager.localizeString("loop", "error", interaction.locale));
};

if (mode === "Queue") return interaction.editReply("πŸ” Songfish is now playing in queue-loop mode.");
if (mode === "Song") return interaction.editReply("πŸ”‚ Songfish is now playing in single-loop mode.");
if (mode === "None") return interaction.editReply("➑️ Songfish is now playing in queue mode.");
if (mode === "Queue") return interaction.editReply(LocalizationManager.localizeString("loop", "successQueue", interaction.locale));
if (mode === "Song") return interaction.editReply(LocalizationManager.localizeString("loop", "successSingle", interaction.locale));
if (mode === "None") return interaction.editReply(LocalizationManager.localizeString("loop", "successStop", interaction.locale));
}
};
1 change: 1 addition & 0 deletions src/interactions/move.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { MessageEmbed } = require("discord.js-light");
const { LocalizationManager } = require('../lib/StringManagers');

require("array.prototype.move");

Expand Down
Loading

0 comments on commit 64ba514

Please sign in to comment.