Skip to content

Commit

Permalink
[New] Added DJ command, still not implemented.
Browse files Browse the repository at this point in the history
  • Loading branch information
naseif committed Nov 1, 2021
1 parent e47e425 commit fa4c4de
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
32 changes: 32 additions & 0 deletions commands/Config/dj.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { getRoleFromMention } = require("../../modules/getUserFromMention");

module.exports = {
name: "dj",
description: "Set DJ Role",
args: true,
usage: `dj set <role>`,
async run(message, args, client, defaultPrefix) {
if (!args[0]) {
return await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`Please choose whether you want to set or delete an existing role`
),
],
});
}

if (args[0] === "set" && args[1]) {
const test = await getRoleFromMention(args[1], message);
}
},
data: new SlashCommandBuilder()
.setName("dj")
.setDescription("Set DJ Role")
.addStringOption((option) =>
option.setName("role").setDescription("DJ Role").setRequired(true)
),
async execute(interaction, client) {},
};
20 changes: 20 additions & 0 deletions modules/getUserFromMention.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,23 @@ module.exports.getGuildUserFromMention = (mention, message) => {
return message.guild.members.cache.get(mention);
}
};
/**
* Gets the Role Object
* @param {mention} mention
* @param {message} message
* @returns Role Object
*/

module.exports.getRoleFromMention = async (mention, message) => {
if (!mention) return;

if (mention.startsWith("<@") && mention.endsWith(">")) {
mention = mention.slice(2, -1);

if (mention.startsWith("&")) {
mention = mention.slice(1);
}

return await message.guild.roles.fetch(mention);
}
};

0 comments on commit fa4c4de

Please sign in to comment.