How to retrieve ID of guild bot is currently in? #1234
-
I'm writing a single-guild self hosted bot. In other words bot shall be disallowed to be in more than one guild at once and user will have to host bot on his own instead of "inviting" bot that is already hosted somewhere to the server. To save a hustle for end user I want to get guild id at runtime so, that user didn't have to do it manually. Also, I'll need guild ids to check on startup, if bot is already present in some guild. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Anyway, I've made a PR: #1235 |
Beta Was this translation helpful? Give feedback.
-
To get all guilds bot is currently in, you can use P.S. Not really sure why you're trying to implement this by yourself. Since the same functional can be achieved by toggling "Public bot" option in Developer Dashboard. |
Beta Was this translation helpful? Give feedback.
To get all guilds bot is currently in, you can use
Session.State.Ready.Guilds
(or justSession.State.Guild
).However I would recommend listening for
GuildCreate
event, which is fired each time bot joins a new guild.P.S. Not really sure why you're trying to implement this by yourself. Since the same functional can be achieved by toggling "Public bot" option in Developer Dashboard.