How to detect if a string is a snowflake and check what type of snowflake it is?

I've been doing this but i want to know if there is an easier way
const snowflake = options.getString("snowflake");
const guildSearch = client.guilds.cache.find(server => server.id === snowflake);
const userSearch = guild.members.cache.find(member => member.id === snowflake);
const channelSearch = guild.channels.cache.find(channel => channel.id === snowflake);
const roleSearch = guild.roles.cache.find(role => role.id === snowflake);
const commandSearch = guild.commands.cache.find(command => command.id === snowflake);
const emojiSearch = guild.emojis.cache.find(emoji => emoji.id === snowflake);
const stickerSearch = guild.stickers.cache.find(sticker => sticker.id === snowflake);
const snowflake = options.getString("snowflake");
const guildSearch = client.guilds.cache.find(server => server.id === snowflake);
const userSearch = guild.members.cache.find(member => member.id === snowflake);
const channelSearch = guild.channels.cache.find(channel => channel.id === snowflake);
const roleSearch = guild.roles.cache.find(role => role.id === snowflake);
const commandSearch = guild.commands.cache.find(command => command.id === snowflake);
const emojiSearch = guild.emojis.cache.find(emoji => emoji.id === snowflake);
const stickerSearch = guild.stickers.cache.find(sticker => sticker.id === snowflake);
7 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs2y ago
Don't use the find method to query a Collection by key (mostly the associated id)
- someCollection.find(structure => structure.id === "348607796335607817")
+ someCollection.get("348607796335607817")
- someCollection.find(structure => structure.id === "348607796335607817")
+ someCollection.get("348607796335607817")
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
PAdventures
PAdventuresOP2y ago
ok do i have to provide a string shown in the example, or can i use a variable such as snowflake to get the object like normal
Squid
Squid2y ago
you should probably learn how variables work in javascript
PAdventures
PAdventuresOP2y ago
i do know how they work, it's just for looking to see if a user had a role you needed to provide a string and not a variable that stores a string thanks anyways
Want results from more Discord servers?
Add your server