Skip to content

Commit

Permalink
Add PlayFile.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Adivise committed Nov 3, 2024
1 parent 60c19a5 commit 64eb9a3
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 21 deletions.
4 changes: 1 addition & 3 deletions commands/Music/247.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ module.exports = {
category: "Music",
run: async (client, interaction) => {
await interaction.deferReply({ ephemeral: false });

const queue = client.distube.getQueue(interaction);
if (!queue) return interaction.editReply(`There is nothing in the queue right now!`);

const { channel } = interaction.member.voice;
if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply("You need to be in a same/voice channel.")

Expand Down
15 changes: 9 additions & 6 deletions commands/Music/NowPlaying.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,19 @@ module.exports = {
.setAuthor({ name: queue.songs[0].playing ? 'Song Pause...' : 'Now Playing...', iconURL: "https://cdn.discordapp.com/emojis/741605543046807626.gif"})
.setColor(client.color)
.setDescription(`**[${queue.songs[0].name}](${queue.songs[0].url})**`)
.setThumbnail(`${queue.songs[0].thumbnail}`)
.addFields({ name: 'Uploader:', value: `[${queue.songs[0].uploader.name}](${queue.songs[0].uploader.url})`, inline: true })
.setThumbnail(`${queue.songs[0].thumbnail || client.user.displayAvatarURL()}`)
.addFields({ name: 'Uploader:', value: `[${queue.songs[0].uploader.name || "Anonymous"}](${queue.songs[0].uploader.url || "https://www.github.com/Adivise"})`, inline: true })
.addFields({ name: 'Requester:', value: `${queue.songs[0].user}`, inline: true })
.addFields({ name: 'Volume:', value: `${queue.volume}%`, inline: true })
.addFields({ name: 'Views', value: `${queue.songs[0].views}`, inline: true })
.addFields({ name: 'Likes:', value: `${queue.songs[0].likes}`, inline: true })
.addFields({ name: 'Views', value: `${queue.songs[0].views || "0"}`, inline: true })
.addFields({ name: 'Likes:', value: `${queue.songs[0].likes || "0"}`, inline: true })
.addFields({ name: 'Filters:', value: `${queue.filters.names.join(', ') || "Normal"}`, inline: true })
.addFields({ name: `Current Duration: \`[${queue.formattedCurrentTime} / ${queue.songs[0].formattedDuration}]\``, value: `\`\`\`${uni} ${'─'.repeat(part) + '🎶' + '─'.repeat(30 - part)}\`\`\``, inline: false })
.setTimestamp()

if (!part == "Infinity") {
embed.addFields({ name: `Current Duration: \`[${queue.formattedCurrentTime} / ${queue.songs[0].formattedDuration}]\``, value: `\`\`\`${uni} ${'─'.repeat(part) + '🎶' + '─'.repeat(30 - part)}\`\`\``, inline: false })
} else {
embed.addFields({ name: `Current Duration: \`[0:00 / ${queue.songs[0].formattedDuration}]\``, value:`\`\`\`🔴 | 🎶──────────────────────────────\`\`\``, inline: false })
}
interaction.editReply({ embeds: [embed] });
}
}
52 changes: 52 additions & 0 deletions commands/Music/PlayFile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const { PermissionsBitField, ApplicationCommandOptionType } = require("discord.js");
const { Database } = require("st.db");

const GSetup = new Database("./settings/models/setup.json", { databaseInObject: true });

module.exports = {
name: ["playfile"],
description: "Play file with mp3/wav/ogg",
category: "Music",
options: [
{
name: "file",
type: ApplicationCommandOptionType.Attachment,
description: "file with mp3/wav/ogg.",
required: true,
}
],
run: async (client, interaction) => {
try {
if (interaction.options.getAttachment("file")) {
const db = await GSetup.get(interaction.guild.id);
if (db.setup_enable === true) return interaction.reply("Command is disable already have song request channel!");

await interaction.reply(`🔍 **Loading...** \`${interaction.options.getAttachment("file").name}\``);

const message = await interaction.fetchReply();
await client.createPlay(interaction, message.id);

const { channel } = interaction.member.voice;
if (!channel) return interaction.editReply("You need to be in voice channel.")
if (!channel.permissionsFor(interaction.guild.members.me).has(PermissionsBitField.Flags.Connect)) return interaction.editReply(`I don't have perm \`CONNECT\` in ${channel.name} to join voice!`);
if (!channel.permissionsFor(interaction.guild.members.me).has(PermissionsBitField.Flags.Speak)) return interaction.editReply(`I don't have perm \`SPEAK\` in ${channel.name} to join voice!`);

try {
const string = interaction.options.getAttachment("file").url;

const options = {
member: interaction.member,
textChannel: interaction.channel,
interaction,
}

await client.distube.play(interaction.member.voice.channel, string, options);
} catch (e) {
//
}
}
} catch (e) {
//
}
}
}
4 changes: 2 additions & 2 deletions disspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ module.exports = MainClient;

function checkSpotify(client) {
if (client.config.SPOTIFY_TRACKS) {
console.log("[INFO] You're (Enabled) Spotify More Tracks Support!");
// console.log("[INFO] You're (Enabled) Spotify More Tracks Support!");
return spotifyOn(client);
} else {
console.log("[INFO] You're (Not Enabled) Spotify More Tracks Support!");
// console.log("[INFO] You're (Not Enabled) Spotify More Tracks Support!");
return spotifyOff();
}
}
Expand Down
2 changes: 1 addition & 1 deletion events/distube/addSong.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = async (client, queue, song) => {
const msg = await queue.textChannel.messages.cache.get(data.message_id);

const embed = new EmbedBuilder()
.setDescription(`**Queued • [${song.name}](${song.url})** \`${song.formattedDuration}\` • ${song.user}`)
.setDescription(`**Queued • [${song.name || "Anonymous"}](${song.url || "https://www.github.com/Adivise"})** \`${song.formattedDuration}\` • ${song.user}`)
.setColor('#000001')

await msg.edit({ content: " ", embeds: [embed] })
Expand Down
10 changes: 5 additions & 5 deletions events/distube/playSong.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = async (client, queue, track) => {
if (db.setup_enable === true) return;

var newQueue = client.distube.getQueue(queue.id)
var data = disspace(newQueue, track)
var data = disspace(newQueue, track ,client)

const nowplay = await queue.textChannel.send(data)

Expand Down Expand Up @@ -176,7 +176,7 @@ module.exports = async (client, queue, track) => {
const str = songStrings.slice(i * 10, i * 10 + 10).join('');
const embed = new EmbedBuilder()
.setAuthor({ name: `Queue - ${message.guild.name}`, iconURL: message.guild.iconURL({ dynamic: true })})
.setThumbnail(queue.songs[0].thumbnail)
.setThumbnail(queue.songs[0].thumbnail || client.user.displayAvatarURL())
.setColor(client.color)
.setDescription(`**Currently Playing:**\n**[${queue.songs[0].name}](${queue.songs[0].url})** \`[${queue.songs[0].formattedDuration}]\` • ${queue.songs[0].user}\n\n**Rest of queue**${str == '' ? ' Nothing' : '\n' + str }`)
.setFooter({ text: `Page • ${i + 1}/${pagesNum} | ${queue.songs.length} • Songs | ${queue.formattedDuration} • Total duration`});
Expand All @@ -196,13 +196,13 @@ module.exports = async (client, queue, track) => {
});
}

function disspace(nowQueue, nowTrack) {
function disspace(nowQueue, nowTrack, client) {
const embed = new EmbedBuilder()
.setAuthor({ name: `Starting Playing...`, iconURL: 'https://cdn.discordapp.com/emojis/741605543046807626.gif' })
.setThumbnail(nowTrack.thumbnail)
.setThumbnail(nowTrack.thumbnail || client.user.displayAvatarURL())
.setColor('#000001')
.setDescription(`**[${nowTrack.name}](${nowTrack.url})**`)
.addFields({ name: `Uploader:`, value: `**[${nowTrack.uploader.name}](${nowTrack.uploader.url})**`, inline: true })
.addFields({ name: `Uploader:`, value: `**[${nowTrack.uploader.name || "Anonymous"}](${nowTrack.uploader.url || "https://www.github.com/Adivise"})**`, inline: true })
.addFields({ name: `Requester:`, value: `${nowTrack.user}`, inline: true })
.addFields({ name: `Current Volume:`, value: `${nowQueue.volume}%`, inline: true })
.addFields({ name: `Filters:`, value: `${nowQueue.filters.names.join(", ") || "Normal"}`, inline: true })
Expand Down
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "disspacex",
"version": "6.0.0",
"version": "6.3.0",
"description": "✈ Join Discord: https://discord.gg/SNG3dh3MbR",
"main": "index.js",
"scripts": {
Expand All @@ -24,14 +24,12 @@
"distube-apple-music": "^0.1.0",
"distube-tidal": "^0.1.0",
"dotenv": "^16.4.5",
"ffmpeg-static": "^5.2.0",
"figlet": "^1.8.0",
"libsodium-wrappers": "^0.7.15",
"lyrics-finder": "^21.7.0",
"opusscript": "^0.0.8",
"path": "^0.12.7",
"plsargs": "^0.1.6",
"recursive-readdir": "^2.2.3",
"sodium-native": "^4.2.1",
"st.db": "^5.1.4",
"stuffs": "^0.1.42"
}
Expand Down

0 comments on commit 64eb9a3

Please sign in to comment.