Skip to content

Conversation

@coleminer0112
Copy link
Contributor

We had a few use cases for these functions come up, so https://github.com/R3site created these, and I applied some modifications so they'd be suitable for general use.

Usage:

  • exports['Badger_Discord_API']:FindGuildForRole(roleId): returns guild ID of the guild which has the provided role (if one exists).
  • exports['Badger_Discord_API']:RoleNameFromId(roleid,guild): returns the role name of given role ID. The guild argument is optional and if not included will use FindGuildForRole to seek that role name.

function FindGuildForRole(roleId)
local roleFound
local tempGuildList = Config.Guilds
tempGuildList["main_guild_abcd1010"] = Config.Guild_ID
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol, what is the need for this arbitrary key in the table?

Copy link
Contributor Author

@coleminer0112 coleminer0112 Oct 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly to make it unlikely that a user would overwrite that key in the config by 'injecting' the main guild ID in a nonsensical key

return roleFound
end

function RoleNameFromId(id, guild)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guild should be an optional parameter?

Copy link
Contributor Author

@coleminer0112 coleminer0112 Oct 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is - looking below the case of guild == nil is handled by defaulting to searching for the guild. Providing the guild would just make it more efficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants