discord.Colors class question

Hello , kinda interested how should i go about this code :
.addStringOption((option) => option.setName("eventPlayerRoleColor").setDescription("Set Color for players in the event.").setChoices())
.addStringOption((option) => option.setName("eventPlayerRoleColor").setDescription("Set Color for players in the event.").setChoices())
How could i create setChoices with all colors inside discord.Colors class so i could get them all in my choices?
31 Replies
d.js toolkit
d.js toolkit17mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs17mo ago
guide Slash Commands: Autocomplete read more
shullex
shullexOP17mo ago
Yes i know that , i'd love to omit some colors as they're not so interesting option.setName isnt slash name , does it have to be lower case also ?M
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
shullex
shullexOP17mo ago
If i access Colors.Aqua How do i get the name itself ?: kinda dumb question i guess Also.. why would this command doesnt respond at all ?
import { EventType } from "@prisma/client";
import { Colors, CommandInteraction, SlashCommandBuilder } from "discord.js";

export const data = new SlashCommandBuilder()
.setName("event-create")
.setDescription("Creates event")
.addStringOption((option) => option
.setName("event-type-input")
.setChoices(
{
name: 'Meeting', value: EventType.Meeting,
},
{
name: 'League', value: EventType.League
},
{
name: 'Tournament', value: EventType.Tournament
})
.setDescription("Choose the type of event"))
.addStringOption((option) => option
.setName("event-name-input")
.setDescription("Choose name of the event"))
.addStringOption((option) => option
.setName("event-player-role-color")
.setDescription("Set Color for players in the event.")
.setChoices(
{
name: "Aqua", value: Colors.Aqua.toString()
}
))

export async function execute(interaction: CommandInteraction) {
return interaction.reply("Lol !");
}
import { EventType } from "@prisma/client";
import { Colors, CommandInteraction, SlashCommandBuilder } from "discord.js";

export const data = new SlashCommandBuilder()
.setName("event-create")
.setDescription("Creates event")
.addStringOption((option) => option
.setName("event-type-input")
.setChoices(
{
name: 'Meeting', value: EventType.Meeting,
},
{
name: 'League', value: EventType.League
},
{
name: 'Tournament', value: EventType.Tournament
})
.setDescription("Choose the type of event"))
.addStringOption((option) => option
.setName("event-name-input")
.setDescription("Choose name of the event"))
.addStringOption((option) => option
.setName("event-player-role-color")
.setDescription("Set Color for players in the event.")
.setChoices(
{
name: "Aqua", value: Colors.Aqua.toString()
}
))

export async function execute(interaction: CommandInteraction) {
return interaction.reply("Lol !");
}
this is my interaction.create handler
client.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isCommand()) {
return;
}
const { commandName } = interaction;
if (commands[commandName as keyof typeof commands]) {
await commands[commandName as keyof typeof commands].execute(interaction).catch(console.error);
}
});
client.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isCommand()) {
return;
}
const { commandName } = interaction;
if (commands[commandName as keyof typeof commands]) {
await commands[commandName as keyof typeof commands].execute(interaction).catch(console.error);
}
});
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
shullex
shullexOP17mo ago
Commented all of the in the slashcommandBuilder() except set name & description and it didnt just gave app didnt respond. if i use the same ping.ts command it works.
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
shullex
shullexOP17mo ago
import { EventType } from "@prisma/client";
import { Colors, CommandInteraction, SlashCommandBuilder } from "discord.js";

export const data = new SlashCommandBuilder()
.setName("event-create")
.setDescription("Creates event")
/* .addStringOption((option) => option
.setName("event-type-input")
.setChoices(
{
name: 'Meeting', value: EventType.Meeting,
},
{
name: 'League', value: EventType.League
},
{
name: 'Tournament', value: EventType.Tournament
})
.setDescription("Choose the type of event"))
.addStringOption((option) => option
.setName("event-name-input")
.setDescription("Choose name of the event"))
.addStringOption((option) => option
.setName("event-player-role-color")
.setDescription("Set Color for players in the event.")
.setChoices(
{
name: "Aqua", value: Colors.Aqua.toString()
}
)) */

export async function execute(interaction: CommandInteraction) {
return interaction.reply("Lol !");
}
import { EventType } from "@prisma/client";
import { Colors, CommandInteraction, SlashCommandBuilder } from "discord.js";

export const data = new SlashCommandBuilder()
.setName("event-create")
.setDescription("Creates event")
/* .addStringOption((option) => option
.setName("event-type-input")
.setChoices(
{
name: 'Meeting', value: EventType.Meeting,
},
{
name: 'League', value: EventType.League
},
{
name: 'Tournament', value: EventType.Tournament
})
.setDescription("Choose the type of event"))
.addStringOption((option) => option
.setName("event-name-input")
.setDescription("Choose name of the event"))
.addStringOption((option) => option
.setName("event-player-role-color")
.setDescription("Set Color for players in the event.")
.setChoices(
{
name: "Aqua", value: Colors.Aqua.toString()
}
)) */

export async function execute(interaction: CommandInteraction) {
return interaction.reply("Lol !");
}
create-event.ts
import { CommandInteraction, SlashCommandBuilder } from "discord.js";

export const data = new SlashCommandBuilder()
.setName("ping")
.setDescription("Replies with Pong!");

export async function execute(interaction: CommandInteraction) {
return interaction.reply("Pong!");
}
import { CommandInteraction, SlashCommandBuilder } from "discord.js";

export const data = new SlashCommandBuilder()
.setName("ping")
.setDescription("Replies with Pong!");

export async function execute(interaction: CommandInteraction) {
return interaction.reply("Pong!");
}
ping.ts
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
shullex
shullexOP17mo ago
client.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isCommand()) {
return;
}
const { commandName } = interaction;
if (commands[commandName as keyof typeof commands]) {
commands[commandName as keyof typeof commands].execute(interaction).catch(console.error);
}
});
client.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isCommand()) {
return;
}
const { commandName } = interaction;
if (commands[commandName as keyof typeof commands]) {
commands[commandName as keyof typeof commands].execute(interaction).catch(console.error);
}
});
app.ts -> command handler Yes.
/// Fired upon we start our bot or he restarts ?
client.once(Events.ClientReady, async () => {

const guild = client.guilds.cache.get(config.GUILD_ID as string)?.id as string

console.log("Discord bot is ready! 🤖");
await deployCommands({ guildId: guild })
await AddUsersOrUpdateAll(client)
});
/// Fired upon we start our bot or he restarts ?
client.once(Events.ClientReady, async () => {

const guild = client.guilds.cache.get(config.GUILD_ID as string)?.id as string

console.log("Discord bot is ready! 🤖");
await deployCommands({ guildId: guild })
await AddUsersOrUpdateAll(client)
});
app.ts also Also got index.ts file inside commands folder to export all commands.
import * as ping from "./ping";
import * as createEvent from "./create-event";

export const commands = {
ping,
createEvent
};
import * as ping from "./ping";
import * as createEvent from "./create-event";

export const commands = {
ping,
createEvent
};
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
shullex
shullexOP17mo ago
Oh fucking hell. Not like i'd surpass it today as its 1:44 am Good to know anyways So i can register same cmd 1000000 times?
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs17mo ago
If you aren't getting any errors, try to place console.log checkpoints throughout your code to find out where execution stops. - Once you do, log relevant values and if-conditions - More sophisticated debugging methods are breakpoints and runtime inspections: learn more
shullex
shullexOP17mo ago
client.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isCommand()) {
return;
}
const { commandName } = interaction;
console.log(commandName);
if (commands[commandName as keyof typeof commands]) {
commands[commandName as keyof typeof commands].execute(interaction).catch(console.error);
}
});
client.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isCommand()) {
return;
}
const { commandName } = interaction;
console.log(commandName);
if (commands[commandName as keyof typeof commands]) {
commands[commandName as keyof typeof commands].execute(interaction).catch(console.error);
}
});
shullex
shullexOP17mo ago
So it gets called.
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
shullex
shullexOP17mo ago
Sorry.:D
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
shullex
shullexOP17mo ago
Will have to do so. Can i have few questions for u ? ds.js related not topic related also , not like i didnt asked something off-topic yet:D
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
shullex
shullexOP17mo ago
Well , its kinda hard to actually get answers from someone who knows ts
ask me
What the fuck am i doing
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
shullex
shullexOP17mo ago
dc.js related ts questions
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
shullex
shullexOP17mo ago
questions* 1. So basically , i'd love to know if u could point me to direction where i could somehow avoid using this in every file where i do use prisma const prisma = new PrismaClient(); Is there some sort of global declaractions in typescript? 2. Would it be efficient to create some sort of wrapper around my PrismaClient or its inefficient and just should keep using the default prismaclient => actually i've meant some sort of "API" which is accesible only inside my dc.js app. 3. Would have tons more but i think u'd love to sleep
1. Tried global.ts.d but it didnt work:(
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
shullex
shullexOP17mo ago
Oh. will try that. thanks a lot man for your time
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server