Skip to content

Commit

Permalink
[Enhancement] check for djrole if it exists for the guild
Browse files Browse the repository at this point in the history
  • Loading branch information
naseif committed Nov 2, 2021
1 parent c439457 commit f40c175
Show file tree
Hide file tree
Showing 9 changed files with 277 additions and 3 deletions.
30 changes: 30 additions & 0 deletions commands/Music/clear.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ module.exports = {
});
}

const checkdj = await client.db.get(`djRole_${message.guildId}`);
const userRoles = await message.member.roles.cache.map((role) => role.id);

if (checkdj && !userRoles.includes(checkdj)) {
return await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`You are not allowed to use this command.\n This command is only available for users with the DJ Role: <@&${checkdj}>`
),
],
});
}

try {
if (queue) {
await queue.clear();
Expand Down Expand Up @@ -64,6 +78,22 @@ module.exports = {
});
}

const checkdj = await client.db.get(`djRole_${interaction.guildId}`);
const userRoles = await interaction.member.roles.cache.map(
(role) => role.id
);

if (checkdj && !userRoles.includes(checkdj)) {
return await interaction.followUp({
embeds: [
embedMessage(
"#9dcc37",
`You are not allowed to use this command.\n This command is only available for users with the DJ Role: <@&${checkdj}>`
),
],
});
}

try {
if (queue) {
await queue.clear();
Expand Down
42 changes: 39 additions & 3 deletions commands/Music/disconnect.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,27 @@ module.exports = {
)
return await message.channel.send({
embeds: [
embedMessage("#9dcc37", `❌ | You must be in my voice channel to disconnect me!`),
embedMessage(
"#9dcc37",
`❌ | You must be in my voice channel to disconnect me!`
),
],
});

const checkdj = await client.db.get(`djRole_${message.guildId}`);
const userRoles = await message.member.roles.cache.map((role) => role.id);

if (checkdj && !userRoles.includes(checkdj)) {
return await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`You are not allowed to use this command.\n This command is only available for users with the DJ Role: <@&${checkdj}>`
),
],
});
}

try {
if (queue) {
await queue.connection.disconnect();
Expand Down Expand Up @@ -70,14 +87,33 @@ module.exports = {

if (
interaction.guild.me.voice.channelId &&
interaction.member.voice.channelId !== interaction.guild.me.voice.channelId
interaction.member.voice.channelId !==
interaction.guild.me.voice.channelId
)
return await interaction.followUp({
embeds: [
embedMessage("#9dcc37", `❌ | You must be in my voice channel to disconnect me!`),
embedMessage(
"#9dcc37",
`❌ | You must be in my voice channel to disconnect me!`
),
],
});

const checkdj = await client.db.get(`djRole_${interaction.guildId}`);
const userRoles = await interaction.member.roles.cache.map(
(role) => role.id
);

if (checkdj && !userRoles.includes(checkdj)) {
return await interaction.followUp({
embeds: [
embedMessage(
"#9dcc37",
`You are not allowed to use this command.\n This command is only available for users with the DJ Role: <@&${checkdj}>`
),
],
});
}

try {
if (queue) {
Expand Down
30 changes: 30 additions & 0 deletions commands/Music/jump.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ module.exports = {
],
});

const checkdj = await client.db.get(`djRole_${message.guildId}`);
const userRoles = await message.member.roles.cache.map((role) => role.id);

if (checkdj && !userRoles.includes(checkdj)) {
return await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`You are not allowed to use this command.\n This command is only available for users with the DJ Role: <@&${checkdj}>`
),
],
});
}

if (!args[0])
return await message.channel.send({
embeds: [
Expand Down Expand Up @@ -67,6 +81,22 @@ module.exports = {
],
});

const checkdj = await client.db.get(`djRole_${interaction.guildId}`);
const userRoles = await interaction.member.roles.cache.map(
(role) => role.id
);

if (checkdj && !userRoles.includes(checkdj)) {
return await interaction.followUp({
embeds: [
embedMessage(
"#9dcc37",
`You are not allowed to use this command.\n This command is only available for users with the DJ Role: <@&${checkdj}>`
),
],
});
}

try {
if (queue) {
await queue.jump(Number(position));
Expand Down
30 changes: 30 additions & 0 deletions commands/Music/pause.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ module.exports = {
],
});

const checkdj = await client.db.get(`djRole_${message.guildId}`);
const userRoles = await message.member.roles.cache.map((role) => role.id);

if (checkdj && !userRoles.includes(checkdj)) {
return await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`You are not allowed to use this command.\n This command is only available for users with the DJ Role: <@&${checkdj}>`
),
],
});
}

try {
if (queue) {
await queue.setPaused(true);
Expand Down Expand Up @@ -52,6 +66,22 @@ module.exports = {
],
});

const checkdj = await client.db.get(`djRole_${interaction.guildId}`);
const userRoles = await interaction.member.roles.cache.map(
(role) => role.id
);

if (checkdj && !userRoles.includes(checkdj)) {
return await interaction.followUp({
embeds: [
embedMessage(
"#9dcc37",
`You are not allowed to use this command.\n This command is only available for users with the DJ Role: <@&${checkdj}>`
),
],
});
}

try {
if (queue) {
await queue.setPaused(true);
Expand Down
30 changes: 30 additions & 0 deletions commands/Music/playskip.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ module.exports = {
],
});

const checkdj = await client.db.get(`djRole_${message.guildId}`);
const userRoles = await message.member.roles.cache.map((role) => role.id);

if (checkdj && !userRoles.includes(checkdj)) {
return await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`You are not allowed to use this command.\n This command is only available for users with the DJ Role: <@&${checkdj}>`
),
],
});
}

if (!songString)
return await message.channel.send({
embeds: [
Expand Down Expand Up @@ -152,6 +166,22 @@ module.exports = {
],
});

const checkdj = await client.db.get(`djRole_${interaction.guildId}`);
const userRoles = await interaction.member.roles.cache.map(
(role) => role.id
);

if (checkdj && !userRoles.includes(checkdj)) {
return await interaction.followUp({
embeds: [
embedMessage(
"#9dcc37",
`You are not allowed to use this command.\n This command is only available for users with the DJ Role: <@&${checkdj}>`
),
],
});
}

const songString = interaction.options.getString("song");
const searchSong = await client.player.search(songString, {
requestedBy: interaction.user,
Expand Down
30 changes: 30 additions & 0 deletions commands/Music/repeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ module.exports = {
});
}

const checkdj = await client.db.get(`djRole_${message.guildId}`);
const userRoles = await message.member.roles.cache.map((role) => role.id);

if (checkdj && !userRoles.includes(checkdj)) {
return await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`You are not allowed to use this command.\n This command is only available for users with the DJ Role: <@&${checkdj}>`
),
],
});
}

switch (mode) {
case "off":
await queue.setRepeatMode(0);
Expand Down Expand Up @@ -90,6 +104,22 @@ module.exports = {
});
}

const checkdj = await client.db.get(`djRole_${interaction.guildId}`);
const userRoles = await interaction.member.roles.cache.map(
(role) => role.id
);

if (checkdj && !userRoles.includes(checkdj)) {
return await interaction.followUp({
embeds: [
embedMessage(
"#9dcc37",
`You are not allowed to use this command.\n This command is only available for users with the DJ Role: <@&${checkdj}>`
),
],
});
}

switch (mode) {
case "0":
await queue.setRepeatMode(Number(mode));
Expand Down
30 changes: 30 additions & 0 deletions commands/Music/resume.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ module.exports = {
],
});

const checkdj = await client.db.get(`djRole_${message.guildId}`);
const userRoles = await message.member.roles.cache.map((role) => role.id);

if (checkdj && !userRoles.includes(checkdj)) {
return await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`You are not allowed to use this command.\n This command is only available for users with the DJ Role: <@&${checkdj}>`
),
],
});
}

try {
if (queue) {
await queue.setPaused(false);
Expand Down Expand Up @@ -53,6 +67,22 @@ module.exports = {
],
});

const checkdj = await client.db.get(`djRole_${interaction.guildId}`);
const userRoles = await interaction.member.roles.cache.map(
(role) => role.id
);

if (checkdj && !userRoles.includes(checkdj)) {
return await interaction.followUp({
embeds: [
embedMessage(
"#9dcc37",
`You are not allowed to use this command.\n This command is only available for users with the DJ Role: <@&${checkdj}>`
),
],
});
}

try {
if (queue) {
await queue.setPaused(false);
Expand Down
30 changes: 30 additions & 0 deletions commands/Music/skip.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ module.exports = {
],
});

const checkdj = await client.db.get(`djRole_${message.guildId}`);
const userRoles = await message.member.roles.cache.map((role) => role.id);

if (checkdj && !userRoles.includes(checkdj)) {
return await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`You are not allowed to use this command.\n This command is only available for users with the DJ Role: <@&${checkdj}>`
),
],
});
}

try {
const currnetSong = queue.current;
await queue.skip();
Expand Down Expand Up @@ -56,6 +70,22 @@ module.exports = {
],
});

const checkdj = await client.db.get(`djRole_${interaction.guildId}`);
const userRoles = await interaction.member.roles.cache.map(
(role) => role.id
);

if (checkdj && !userRoles.includes(checkdj)) {
return await interaction.followUp({
embeds: [
embedMessage(
"#9dcc37",
`You are not allowed to use this command.\n This command is only available for users with the DJ Role: <@&${checkdj}>`
),
],
});
}

try {
const currnetSong = queue.current;
await queue.skip();
Expand Down
Loading

0 comments on commit f40c175

Please sign in to comment.