Skip to content

Commit 4029b01

Browse files
Techbot121Meta Construct
authored andcommitted
add holographic option and one to remove it
1 parent 8d2988d commit 4029b01

File tree

1 file changed

+59
-16
lines changed
  • app/services/discord/modules/commands

1 file changed

+59
-16
lines changed

app/services/discord/modules/commands/Role.ts

Lines changed: 59 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ const removeRoleIcon = async (ctx: Discord.ChatInputCommandInteraction) => {
2424
await ctx.followUp(EphemeralResponse("Your icon is now gone."));
2525
};
2626

27-
const setRoleColorSpecial = async (ctx: Discord.ChatInputCommandInteraction) => {
27+
const setRoleColorSpecial = async (
28+
ctx: Discord.ChatInputCommandInteraction,
29+
options?: {
30+
holographic?: boolean;
31+
remove?: boolean;
32+
}
33+
) => {
2834
const possible = ctx.guild && ctx.guild.features.includes("ENHANCED_ROLE_COLORS" as any);
2935
if (!possible) {
3036
await ctx.followUp(
@@ -39,24 +45,46 @@ const setRoleColorSpecial = async (ctx: Discord.ChatInputCommandInteraction) =>
3945
}
4046
try {
4147
// super hacky but should work
42-
const primary = ctx.options.getString("primary_color");
48+
let colors = {};
49+
let reason: string;
50+
if (options?.remove) {
51+
reason = "Removed gradient via command";
52+
} else {
53+
const primary = ctx.options.getString("primary_color");
54+
const secondary = !options?.holographic
55+
? ctx.options.getString("secondary_color", true)
56+
: null;
4357

44-
const primaryColor = primary ? parseInt(primary.replace(/^#+/, ""), 16) : role.color;
45-
const secondaryColor = parseInt(
46-
ctx.options.getString("secondary_color", true).replace(/^#+/, ""),
47-
16
48-
);
58+
let primaryColor = primary ? parseInt(primary.replace(/^#+/, ""), 16) : role.color;
59+
let secondaryColor = secondary ? parseInt(secondary.replace(/^#+/, ""), 16) : null;
60+
let tertiary_color: number | null = null;
61+
62+
if (options?.holographic) {
63+
// for some reason only this one has a third colour option and it's static
64+
primaryColor = 11127295;
65+
secondaryColor = 16759788;
66+
tertiary_color = 16761760;
67+
}
68+
colors = {
69+
primary_color: primaryColor,
70+
secondary_color: secondaryColor,
71+
tertiary_color: tertiary_color,
72+
};
73+
reason = "Added/Changed gradient via command";
74+
}
4975

5076
await ctx.client.rest.patch(Discord.Routes.guildRole(ctx.guild.id, role.id), {
5177
body: {
52-
colors: {
53-
primary_color: primaryColor,
54-
secondary_color: secondaryColor,
55-
},
78+
colors,
5679
},
57-
reason: "Added gradient via command",
80+
reason,
5881
} as any);
59-
await ctx.followUp(EphemeralResponse("👍"));
82+
83+
await ctx.followUp(
84+
EphemeralResponse(
85+
`👍\nhere is your old role color if you want to change back: \`${role.hexColor}\``
86+
)
87+
);
6088
} catch (error) {
6189
console.error(error);
6290
await ctx.followUp(EphemeralResponse("Something went wrong trying to add the gradient :("));
@@ -293,6 +321,16 @@ export const SlashRoleCommand: SlashCommand = {
293321
},
294322
],
295323
},
324+
{
325+
type: Discord.ApplicationCommandOptionType.Subcommand,
326+
name: "set_holographic",
327+
description: "Sets the role color to holographic, if it's unlocked.",
328+
},
329+
{
330+
type: Discord.ApplicationCommandOptionType.Subcommand,
331+
name: "remove_gradient",
332+
description: "Sets your role color back to a single color.",
333+
},
296334
{
297335
type: Discord.ApplicationCommandOptionType.Subcommand,
298336
name: "set_icon",
@@ -339,18 +377,23 @@ export const SlashRoleCommand: SlashCommand = {
339377
case "set_color":
340378
await setRole(ctx);
341379
break;
380+
case "remove":
381+
await removeRole(ctx);
382+
break;
342383
case "set_gradient":
343384
await setRoleColorSpecial(ctx);
344385
break;
386+
case "set_holographic":
387+
await setRoleColorSpecial(ctx, { holographic: true });
388+
break;
389+
case "remove_gradient":
390+
await setRoleColorSpecial(ctx, { remove: true });
345391
case "set_emoji":
346392
await setRoleIcon(ctx, false);
347393
break;
348394
case "set_icon":
349395
await setRoleIcon(ctx, true);
350396
break;
351-
case "remove":
352-
await removeRole(ctx);
353-
break;
354397
case "remove_icon":
355398
await removeRoleIcon(ctx);
356399
break;

0 commit comments

Comments
 (0)