Skip to content

Commit

Permalink
add simple role command
Browse files Browse the repository at this point in the history
make colour required when specified
default colour is now random
  • Loading branch information
Techbot121 authored and Meta Construct committed May 8, 2024
1 parent 6c06376 commit 0fd3d67
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion app/services/discord/modules/commands/Role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const addRole = async (ctx: Discord.ChatInputCommandInteraction): Promise<any> =
const roleColor = Discord.resolveColor(
isRGB
? [parseInt(r), parseInt(g), parseInt(b)]
: <Discord.HexColorString>ctx.options.getString("hex", true)
: <Discord.HexColorString>ctx.options.getString("hex") ?? "Random"
);

const guild = ctx.guild;
Expand Down Expand Up @@ -190,6 +190,19 @@ export const SlashRoleCommand: SlashCommand = {
name: "role",
description: "Gives you a Custom Role.",
options: [
{
type: Discord.ApplicationCommandOptionType.Subcommand,
name: "add",
description: "Adds a custom role",
options: [
{
type: Discord.ApplicationCommandOptionType.String,
name: "name",
description: "The name of your role",
required: true,
},
],
},
{
type: Discord.ApplicationCommandOptionType.Subcommand,
name: "add_rgb",
Expand All @@ -207,20 +220,23 @@ export const SlashRoleCommand: SlashCommand = {
description: "The red component of your color 0 - 255",
min_value: 0,
max_value: 255,
required: true,
},
{
type: Discord.ApplicationCommandOptionType.Integer,
name: "green",
description: "The green component of your color 0 - 255",
min_value: 0,
max_value: 255,
required: true,
},
{
type: Discord.ApplicationCommandOptionType.Integer,
name: "blue",
description: "The blue component of your color 0 - 255",
min_value: 0,
max_value: 255,
required: true,
},
],
},
Expand All @@ -239,6 +255,7 @@ export const SlashRoleCommand: SlashCommand = {
type: Discord.ApplicationCommandOptionType.String,
name: "hex",
description: "Hex color value for example #465f83",
required: true,
},
],
},
Expand All @@ -256,11 +273,13 @@ export const SlashRoleCommand: SlashCommand = {
type: Discord.ApplicationCommandOptionType.String,
name: "image_url",
description: "the url for your role, please try to use a small image",
required: true,
},
{
name: "file",
type: Discord.ApplicationCommandOptionType.Attachment,
description: "image file",
required: true,
},
],
},
Expand Down Expand Up @@ -288,6 +307,7 @@ export const SlashRoleCommand: SlashCommand = {
await ctx.deferReply({ ephemeral: true });
const cmd = ctx.options.getSubcommand();
switch (cmd) {
case "add":
case "add_rgb":
case "add_hex":
await addRole(ctx);
Expand Down

0 comments on commit 0fd3d67

Please sign in to comment.