question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get Guilds, users and channels from ids

See original GitHub issue

methods to get DIscordGuilds, Discord Users, and Discord Channels from their ulong Id without the need of another object would be very useful. Like this:

DiscordGuild GetGuild(ulong id)
DiscordUser GetUser(ulong id)
DiscordChannel GetChannel(ulong id)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
Kiritsucommented, Apr 25, 2019

Make a request to the API

DiscordChannel DiscordClient#GetChannelAsync(ulong id)
DiscordGuild DiscordClient#GetGuildAsync(ulong id)
DiscordUser DiscordClient#GetUserAsync(ulong id)
DiscordChannel DiscordGuild#GetChannelAsync(ulong id)
DiscordMember DiscordGuild#GetMemberAsync(ulong id)

Pull from cache

DiscordGuild DiscordClient#Guilds.TryGetValue(id, out var guild)
DiscordChannel DiscordClient#Guilds.Values.SelectMany(x => x.Channels).FirstOrDefault(x => x.Id == id)

DiscordMember DiscordClient#Guilds.Values.SelectMany(x => x.Members).FirstOrDefault(x => x.Id == id)
//This one will return the first member matching the id in the first guild he's in!
DiscordChannel DiscordGuild#GetChannel(ulong id)
DiscordMember DiscordGuild#Members.FirstOrDefault(x => x.Id == id)

DiscordMember objects can be casted into DiscordUser objects.

So yes. As Emzi just said, everything is in the doc, and you even have a fancy great search bar. https://dsharpplus.github.io/

(there are probably other ways to do it)

5reactions
Emzi0767commented, Apr 25, 2019

Have you bothered reading the documentation? Because these exist already.


From: OmegaRogue notifications@github.com Sent: Thursday, April 25, 2019 11:44:56 AM To: DSharpPlus/DSharpPlus Cc: Subscribed Subject: [DSharpPlus/DSharpPlus] Get Guilds, users and channels from ids (#423)

methods to get DIscordGuilds, Discord Users, and Discord Channels from their ulong Id without the need of another object would be very useful. Like this:

DiscordGuild GetGuild(ulong id) DiscordUser GetUser(ulong id) DiscordChannel GetChannel(ulong id)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/DSharpPlus/DSharpPlus/issues/423, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAF7QQGZAMQN345E67I3S7TPSF4RRANCNFSM4HILOWLQ.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get guild id and all channel's id in that guild
1 Answer 1 · How can I see this is working or not? invite my bot to my channel and see the changes...
Read more >
Guild - Developer Portal
Guild Resource​​ Guilds in Discord represent an isolated collection of users and channels, and are often referred to as "servers" in the UI....
Read more >
V12 Fetch IDs for all guilds my bot is in. : r/Discordjs
I want my bot to fetch the ID for every server that it is in. and maybe also fetch a random channel ID...
Read more >
Frequently asked Questions | discord.js Guide
Currently, the only way to get tag ids is programmatically through ForumChannel#availableTags open in new window. const channel = client.
Read more >
Fetching Discord API for Guild Channels - YouTube
Comments5 · Discord Bot Dashboard #28 - Fetch & Render Guild Channels in React · Discord Bot Dashboard #19 - Fetching User &...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found