-
Notifications
You must be signed in to change notification settings - Fork 0
/
grab.js
163 lines (160 loc) · 5.33 KB
/
grab.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
const { MessageEmbed } = require("discord.js");
const prettyMilliseconds = require("pretty-ms");
module.exports = {
name: "grab",
description: "Saves the current song to your Direct Messages",
usage: "",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
aliases: ["cmdsave"],
/**
*
* @param {import("../structures/DiscordMusicBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, message, args, { GuildDB }) => {
let player = await client.Manager.get(message.guild.id);
if (!player)
return client.sendTime(
message.channel,
"❌ | **Nothing is playing right now...**"
);
if (!player.playing)
return client.sendTime(
message.channel,
"❌ | **Nothing is playing right now...**"
);
if (!message.member.voice.channel)
return client.sendTime(
message.channel,
"❌ | **You must be in a voice channel to play something!**"
);
if (
message.guild.me.voice.channel &&
message.member.voice.channel.id !== message.guild.me.voice.channel.id
)
return client.sendTime(
message.channel,
":x: | **You must be in the same voice channel as me to use this command!**"
);
message.author
.send(
new MessageEmbed()
.setAuthor(
`Song saved`,
client.user.displayAvatarURL({
dynamic: true,
})
)
.setThumbnail(
`https://img.youtube.com/vi/${player.queue.current.identifier}/mqdefault.jpg`
)
.setURL(player.queue.current.uri)
.setColor(client.botconfig.EmbedColor)
.setTitle(`**${player.queue.current.title}**`)
.addField(
`⌛ Duration: `,
`\`${prettyMilliseconds(player.queue.current.duration, {
colonNotation: true,
})}\``,
true
)
.addField(`🎵 Author: `, `\`${player.queue.current.author}\``, true)
.addField(
`▶ Play it:`,
`\`${
GuildDB ? GuildDB.prefix : client.botconfig.DefaultPrefix
}play ${player.queue.current.uri}\``
)
.addField(`🔎 Saved in:`, `<#${message.channel.id}>`)
.setFooter(
`Requested by: ${player.queue.current.requester.tag}`,
player.queue.current.requester.displayAvatarURL({
dynamic: true,
})
)
)
.catch((e) => {
return message.channel.send("Allow me (DMs Disabled)");
});
client.sendTime(message.channel, "📥 | **Check your DMs!**");
},
SlashCommand: {
/**
*
* @param {import("../structures/DiscordMusicBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, interaction, args, { GuildDB }) => {
const guild = client.guilds.cache.get(interaction.guild_id);
const user = client.users.cache.get(interaction.member.user.id);
const member = guild.members.cache.get(interaction.member.user.id);
let player = await client.Manager.get(interaction.guild_id);
if (!player)
return client.sendTime(
interaction,
"❌ | **Nothing is playing right now...**"
);
if (!player.playing)
return client.sendTime(
interaction,
"❌ | **Nothing is playing right now...**"
);
if (!member.voice.channel)
return client.sendTime(
interaction,
"❌ | **You must be in a voice channel to use this command.**"
);
if (
guild.me.voice.channel &&
!guild.me.voice.channel.equals(member.voice.channel)
)
return client.sendTime(
interaction,
":x: | **You must be in the same voice channel as me to use this command!**"
);
try {
let embed = new MessageEmbed()
.setAuthor(`Song saved: `, client.user.displayAvatarURL())
.setThumbnail(
`https://img.youtube.com/vi/${player.queue.current.identifier}/mqdefault.jpg`
)
.setURL(player.queue.current.uri)
.setColor(client.botconfig.EmbedColor)
.setTimestamp()
.setTitle(`**${player.queue.current.title}**`)
.addField(
`⌛ Duration: `,
`\`${prettyMilliseconds(player.queue.current.duration, {
colonNotation: true,
})}\``,
true
)
.addField(`🎵 Author: `, `\`${player.queue.current.author}\``, true)
.addField(
`▶ Play it:`,
`\`${
GuildDB ? GuildDB.prefix : client.botconfig.DefaultPrefix
}play ${player.queue.current.uri}\``
)
.addField(`🔎 Saved in:`, `<#${interaction.channel_id}>`)
.setFooter(
`Requested by: ${player.queue.current.requester.tag}`,
player.queue.current.requester.displayAvatarURL({
dynamic: true,
})
);
user.send(embed);
} catch (e) {
return client.sendTime(interaction, "**:x: Your DMs are disabled**");
}
client.sendTime(interaction, "📥 | **Check your DMs!**");
},
},
};