Skip to content

Commit

Permalink
Merge pull request #53 from Sobhan-SRZA/v0.0.0
Browse files Browse the repository at this point in the history
0.0.0
  • Loading branch information
Sobhan-SRZA authored Dec 16, 2024
2 parents 48118b0 + 8886e49 commit 5d9023e
Show file tree
Hide file tree
Showing 14 changed files with 313 additions and 162 deletions.
103 changes: 51 additions & 52 deletions README.md

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,6 @@ client.token = config.discord.token;
client.commands = new Collection();
client.cooldowns = new Collection();

// Discord Player Setup
const { DefaultExtractors } = require("@discord-player/extractor");
const { Player } = require("discord-player");
const player = new Player(client);
(async () => {
await player.extractors.loadMulti(DefaultExtractors);
})();

// Load Handlers
let count = 0;
post(
Expand Down
10 changes: 3 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "radio-bot",
"version": "0.0.0-discord-player",
"version": "0.0.0",
"description": "This is an advanced radio bot for Discord voice channels, allowing users to enjoy a wide variety of trending online radios with high quality and seamless performance.",
"main": "index.js",
"scripts": {
Expand All @@ -9,18 +9,14 @@
"author": "Sobhan-SRZA (mr.sinre) && Persian Caesar",
"license": "BSD-3-Clause",
"dependencies": {
"@discord-player/extractor": "^7.0.0-dev.3",
"@discordjs/voice": "^0.17.0",
"cli-color": "^2.0.4",
"discord-player": "^7.0.0-dev.3",
"discord.js": "^14.16.2",
"dotenv": "^16.4.5",
"ffmpeg-static": "^5.2.0",
"libsodium-wrappers": "^0.7.14",
"mediaplex": "^1.0.0",
"libsodium-wrappers": "^0.7.15",
"opusscript": "^0.0.8",
"prism-media": "^1.3.5",
"quick.db": "^9.1.7",
"write-file-atomic": "^5.0.1"
}
}
}
95 changes: 95 additions & 0 deletions src/commands/Music/resume.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@

const
{
ApplicationCommandType,
PermissionFlagsBits,
ApplicationCommandOptionType,
PermissionsBitField
} = require("discord.js"),
radio = require("../../functions/player"),
response = require("../../functions/response"),
selectLanguage = require("../../functions/selectLanguage"),
config = require("../../../config"),
ephemeral = selectLanguage(config.source.default_language).replies.ephemeral,
defaultLanguage = selectLanguage(config.source.default_language).commands.resume,
database = require("../../functions/database"),
checkPlayerPerms = require("../../functions/checkPlayerPerms");

module.exports = {
data: {
name: "resume",
description: defaultLanguage.description,
type: ApplicationCommandType.ChatInput,
default_member_permissions: new PermissionsBitField([PermissionFlagsBits.SendMessages]),
default_bot_permissions: new PermissionsBitField([
PermissionFlagsBits.SendMessages,
PermissionFlagsBits.EmbedLinks,
PermissionFlagsBits.Connect,
PermissionFlagsBits.Speak
]),
dm_permission: false,
nsfw: false,
options: [
{
name: "ephemeral",
description: ephemeral.description,
type: ApplicationCommandOptionType.String,
choices: [
{
name: ephemeral.choices.yes,
value: "true"
},
{
name: ephemeral.choices.no,
value: "false"
}
],
required: false
}
]
},
category: "music",
cooldown: 5,
aliases: ["re"],
only_owner: false,
only_slash: true,
only_message: true,

/**
*
* @param {import("discord.js").Client} client
* @param {import("discord.js").CommandInteraction} interaction
* @param {Array<string>} args
* @returns {void}
*/
run: async (client, interaction, args) => {
const
db = new database(client.db),
databaseNames = {
language: `language.${interaction.guild.id}`
},
lang = await db.has(databaseNames.language) ? await db.get(databaseNames.language) : config.source.default_language,
language = selectLanguage(lang).commands.resume;

// Check perms
if (await checkPlayerPerms(interaction))
return;

// resume Player
const queue = new radio(interaction);
queue.resume();

return await response(interaction, {
content: language.replies.resumed
});
},
};
/**
* @copyright
* Coded by Sobhan-SRZA (mr.sinre) | https://github.com/Sobhan-SRZA
* @copyright
* Work for Persian Caesar | https://dsc.gg/persian-caesar
* @copyright
* Please Mention Us "Persian Caesar", When Have Problem With Using This Code!
* @copyright
*/
12 changes: 6 additions & 6 deletions src/commands/Music/volume.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ module.exports = {
if (await checkPlayerPerms(interaction))
return;

if (queue.isConnection(interaction.guildId))
// Stop The Player
const queue = new radio(interaction);
const input = interaction.user ? interaction.options.getNumber("input") : args[0];
if (!queue.isConnection(interaction.guildId))
return await sendError(
{
interaction,
Expand All @@ -95,9 +98,6 @@ module.exports = {
}
)

// Stop The Player
const queue = new radio(interaction);
const input = interaction.user ? interaction.options.getNumber("input") : args[0];
if (!input) {
const embed = new EmbedBuilder()
.setColor(data.color.theme)
Expand Down Expand Up @@ -125,10 +125,10 @@ module.exports = {
log: language.replies.invalidInput
});

queue.setVolume(Number(input));
const volume = queue.setVolume(Number(input));
return await response(interaction, {
content: replaceValues(language.replies.success, {
volume: input
volume
})
});
}
Expand Down
16 changes: 9 additions & 7 deletions src/events/radio/ready.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ module.exports = async (client) => {
channel = await db.get(databaseNames.afk),
station = await db.get(databaseNames.station) || "Lofi Radio";

if (await db.has(databaseNames.afk))
if (await db.has(databaseNames.afk))
return await new player()
.setData({
channelId: channel,
guildId: guild.id,
adapterCreator: guild.voiceAdapterCreator
})
.setData(
{
channelId: channel,
guildId: guild.id,
adapterCreator: guild.voiceAdapterCreator
}
)
.radio(radiostation[station]);

})
} catch (e) {
error(e)
Expand Down
17 changes: 8 additions & 9 deletions src/events/radio/voiceStateUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,16 @@ module.exports = async (client, oldState, newState) => {
if (oldState.member.id === client.user.id && !newState.channelId)
if (await db.has(databaseNames.afk)) {
return await player
.setData({
channelId: channel,
guildId: oldState.guild.id,
adapterCreator: oldState.guild.voiceAdapterCreator
})
.setData(
{
channelId: channel,
guildId: oldState.guild.id,
adapterCreator: oldState.guild.voiceAdapterCreator
}
)
.radio(radiostation[station]);
} else
if (player.isConnection(oldState.guild.id))
return await player
.stop();

}
} catch (e) {
error(e)
}
Expand Down
43 changes: 43 additions & 0 deletions src/functions/editButtonIdEmote.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const
{
ButtonBuilder,
ActionRowBuilder
} = require("discord.js"),
error = require("./error");

/**
*
* @param {import("discord.js").ButtonInteraction} interaction
* @param {string} id
* @param {string} emote
* @returns {Array<import("discord.js").ActionRow<import("discord.js").ButtonBuilder>>}
*/
module.exports = async function (interaction, id, emote) {
try {
const components = interaction.message.components.map(oldActionRow => {
const updatedActionRow = new ActionRowBuilder()
.addComponents(
oldActionRow.components.map(buttonComponent => {
const newButton = ButtonBuilder.from(buttonComponent)
if (interaction.component.customId == buttonComponent.customId)
newButton.setCustomId(id).setEmoji(emote);

return newButton;
})
)
return updatedActionRow;
});
return components;
} catch (e) {
error(e);
}
}
/**
* @copyright
* Coded by Sobhan-SRZA (mr.sinre) | https://github.com/Sobhan-SRZA
* @copyright
* Work for Persian Caesar | https://dsc.gg/persian-caesar
* @copyright
* Please Mention Us "Persian Caesar", When Have Problem With Using This Code!
* @copyright
*/
Loading

0 comments on commit 5d9023e

Please sign in to comment.