Skip to content

Commit 64eb9a3

Browse files
committed
Add PlayFile.js
1 parent 60c19a5 commit 64eb9a3

File tree

7 files changed

+72
-21
lines changed

7 files changed

+72
-21
lines changed

commands/Music/247.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ module.exports = {
99
category: "Music",
1010
run: async (client, interaction) => {
1111
await interaction.deferReply({ ephemeral: false });
12-
13-
const queue = client.distube.getQueue(interaction);
14-
if (!queue) return interaction.editReply(`There is nothing in the queue right now!`);
12+
1513
const { channel } = interaction.member.voice;
1614
if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply("You need to be in a same/voice channel.")
1715

commands/Music/NowPlaying.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,19 @@ module.exports = {
2525
.setAuthor({ name: queue.songs[0].playing ? 'Song Pause...' : 'Now Playing...', iconURL: "https://cdn.discordapp.com/emojis/741605543046807626.gif"})
2626
.setColor(client.color)
2727
.setDescription(`**[${queue.songs[0].name}](${queue.songs[0].url})**`)
28-
.setThumbnail(`${queue.songs[0].thumbnail}`)
29-
.addFields({ name: 'Uploader:', value: `[${queue.songs[0].uploader.name}](${queue.songs[0].uploader.url})`, inline: true })
28+
.setThumbnail(`${queue.songs[0].thumbnail || client.user.displayAvatarURL()}`)
29+
.addFields({ name: 'Uploader:', value: `[${queue.songs[0].uploader.name || "Anonymous"}](${queue.songs[0].uploader.url || "https://www.github.com/Adivise"})`, inline: true })
3030
.addFields({ name: 'Requester:', value: `${queue.songs[0].user}`, inline: true })
3131
.addFields({ name: 'Volume:', value: `${queue.volume}%`, inline: true })
32-
.addFields({ name: 'Views', value: `${queue.songs[0].views}`, inline: true })
33-
.addFields({ name: 'Likes:', value: `${queue.songs[0].likes}`, inline: true })
32+
.addFields({ name: 'Views', value: `${queue.songs[0].views || "0"}`, inline: true })
33+
.addFields({ name: 'Likes:', value: `${queue.songs[0].likes || "0"}`, inline: true })
3434
.addFields({ name: 'Filters:', value: `${queue.filters.names.join(', ') || "Normal"}`, inline: true })
35-
.addFields({ name: `Current Duration: \`[${queue.formattedCurrentTime} / ${queue.songs[0].formattedDuration}]\``, value: `\`\`\`${uni} ${'─'.repeat(part) + '🎶' + '─'.repeat(30 - part)}\`\`\``, inline: false })
3635
.setTimestamp()
37-
36+
if (!part == "Infinity") {
37+
embed.addFields({ name: `Current Duration: \`[${queue.formattedCurrentTime} / ${queue.songs[0].formattedDuration}]\``, value: `\`\`\`${uni} ${'─'.repeat(part) + '🎶' + '─'.repeat(30 - part)}\`\`\``, inline: false })
38+
} else {
39+
embed.addFields({ name: `Current Duration: \`[0:00 / ${queue.songs[0].formattedDuration}]\``, value:`\`\`\`🔴 | 🎶──────────────────────────────\`\`\``, inline: false })
40+
}
3841
interaction.editReply({ embeds: [embed] });
3942
}
4043
}

commands/Music/PlayFile.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
const { PermissionsBitField, ApplicationCommandOptionType } = require("discord.js");
2+
const { Database } = require("st.db");
3+
4+
const GSetup = new Database("./settings/models/setup.json", { databaseInObject: true });
5+
6+
module.exports = {
7+
name: ["playfile"],
8+
description: "Play file with mp3/wav/ogg",
9+
category: "Music",
10+
options: [
11+
{
12+
name: "file",
13+
type: ApplicationCommandOptionType.Attachment,
14+
description: "file with mp3/wav/ogg.",
15+
required: true,
16+
}
17+
],
18+
run: async (client, interaction) => {
19+
try {
20+
if (interaction.options.getAttachment("file")) {
21+
const db = await GSetup.get(interaction.guild.id);
22+
if (db.setup_enable === true) return interaction.reply("Command is disable already have song request channel!");
23+
24+
await interaction.reply(`🔍 **Loading...** \`${interaction.options.getAttachment("file").name}\``);
25+
26+
const message = await interaction.fetchReply();
27+
await client.createPlay(interaction, message.id);
28+
29+
const { channel } = interaction.member.voice;
30+
if (!channel) return interaction.editReply("You need to be in voice channel.")
31+
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!`);
32+
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!`);
33+
34+
try {
35+
const string = interaction.options.getAttachment("file").url;
36+
37+
const options = {
38+
member: interaction.member,
39+
textChannel: interaction.channel,
40+
interaction,
41+
}
42+
43+
await client.distube.play(interaction.member.voice.channel, string, options);
44+
} catch (e) {
45+
//
46+
}
47+
}
48+
} catch (e) {
49+
//
50+
}
51+
}
52+
}

disspace.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ module.exports = MainClient;
6363

6464
function checkSpotify(client) {
6565
if (client.config.SPOTIFY_TRACKS) {
66-
console.log("[INFO] You're (Enabled) Spotify More Tracks Support!");
66+
// console.log("[INFO] You're (Enabled) Spotify More Tracks Support!");
6767
return spotifyOn(client);
6868
} else {
69-
console.log("[INFO] You're (Not Enabled) Spotify More Tracks Support!");
69+
// console.log("[INFO] You're (Not Enabled) Spotify More Tracks Support!");
7070
return spotifyOff();
7171
}
7272
}

events/distube/addSong.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = async (client, queue, song) => {
1212
const msg = await queue.textChannel.messages.cache.get(data.message_id);
1313

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

1818
await msg.edit({ content: " ", embeds: [embed] })

events/distube/playSong.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = async (client, queue, track) => {
1212
if (db.setup_enable === true) return;
1313

1414
var newQueue = client.distube.getQueue(queue.id)
15-
var data = disspace(newQueue, track)
15+
var data = disspace(newQueue, track ,client)
1616

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

@@ -176,7 +176,7 @@ module.exports = async (client, queue, track) => {
176176
const str = songStrings.slice(i * 10, i * 10 + 10).join('');
177177
const embed = new EmbedBuilder()
178178
.setAuthor({ name: `Queue - ${message.guild.name}`, iconURL: message.guild.iconURL({ dynamic: true })})
179-
.setThumbnail(queue.songs[0].thumbnail)
179+
.setThumbnail(queue.songs[0].thumbnail || client.user.displayAvatarURL())
180180
.setColor(client.color)
181181
.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 }`)
182182
.setFooter({ text: `Page • ${i + 1}/${pagesNum} | ${queue.songs.length} • Songs | ${queue.formattedDuration} • Total duration`});
@@ -196,13 +196,13 @@ module.exports = async (client, queue, track) => {
196196
});
197197
}
198198

199-
function disspace(nowQueue, nowTrack) {
199+
function disspace(nowQueue, nowTrack, client) {
200200
const embed = new EmbedBuilder()
201201
.setAuthor({ name: `Starting Playing...`, iconURL: 'https://cdn.discordapp.com/emojis/741605543046807626.gif' })
202-
.setThumbnail(nowTrack.thumbnail)
202+
.setThumbnail(nowTrack.thumbnail || client.user.displayAvatarURL())
203203
.setColor('#000001')
204204
.setDescription(`**[${nowTrack.name}](${nowTrack.url})**`)
205-
.addFields({ name: `Uploader:`, value: `**[${nowTrack.uploader.name}](${nowTrack.uploader.url})**`, inline: true })
205+
.addFields({ name: `Uploader:`, value: `**[${nowTrack.uploader.name || "Anonymous"}](${nowTrack.uploader.url || "https://www.github.com/Adivise"})**`, inline: true })
206206
.addFields({ name: `Requester:`, value: `${nowTrack.user}`, inline: true })
207207
.addFields({ name: `Current Volume:`, value: `${nowQueue.volume}%`, inline: true })
208208
.addFields({ name: `Filters:`, value: `${nowQueue.filters.names.join(", ") || "Normal"}`, inline: true })

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "disspacex",
3-
"version": "6.0.0",
3+
"version": "6.3.0",
44
"description": "✈ Join Discord: https://discord.gg/SNG3dh3MbR",
55
"main": "index.js",
66
"scripts": {
@@ -24,14 +24,12 @@
2424
"distube-apple-music": "^0.1.0",
2525
"distube-tidal": "^0.1.0",
2626
"dotenv": "^16.4.5",
27-
"ffmpeg-static": "^5.2.0",
2827
"figlet": "^1.8.0",
29-
"libsodium-wrappers": "^0.7.15",
3028
"lyrics-finder": "^21.7.0",
31-
"opusscript": "^0.0.8",
3229
"path": "^0.12.7",
3330
"plsargs": "^0.1.6",
3431
"recursive-readdir": "^2.2.3",
32+
"sodium-native": "^4.2.1",
3533
"st.db": "^5.1.4",
3634
"stuffs": "^0.1.42"
3735
}

0 commit comments

Comments
 (0)