glyde/api/guild
The guild itself, its channels, active threads, bans, members and roles.
Everything here takes the guild major parameter, so two guilds get independent buckets for the same endpoint.
Types
Which way get_bans pages, by user id. One value, not two optional fields:
Discord’s Get Guild Bans table says before wins when both are sent, so a
before left over from the previous page would silently page backwards.
pub type BanCursor {
BansBefore(id.Id(id.User))
BansAfter(id.Id(id.User))
}
Constructors
-
Bans on users whose id sorts below this one.
-
Bans on users whose id sorts above this one.
Values
pub fn add_member_role(
guild: id.Id(id.Guild),
user: id.Id(id.User),
role: id.Id(id.Role),
) -> rest.Call(Nil)
pub fn create_ban(
guild: id.Id(id.Guild),
user: id.Id(id.User),
body: body.Body,
) -> rest.Call(Nil)
PUT /guilds/{guild.id}/bans/{user.id}. delete_message_seconds in the
body also deletes the user’s recent messages, up to seven days back.
pub fn create_channel(
guild: id.Id(id.Guild),
body: body.Body,
) -> rest.Call(channel.Channel)
pub fn edit_current_member(
guild: id.Id(id.Guild),
body: body.Body,
) -> rest.Call(member.GuildMember)
PATCH /guilds/{guild.id}/members/@me: nick, avatar, banner and bio, the
four payload/member.EditCurrentMember carries. @me is a literal, so
this is not the by-id bucket.
pub fn edit_member(
guild: id.Id(id.Guild),
user: id.Id(id.User),
body: body.Body,
) -> rest.Call(member.GuildMember)
PATCH /guilds/{guild.id}/members/{user.id}: nickname, roles, mute,
deafen, timeout, and moving them between voice channels.
pub fn edit_role(
guild: id.Id(id.Guild),
role: id.Id(id.Role),
body: body.Body,
) -> rest.Call(role.Role)
pub fn get_active_threads(
guild: id.Id(id.Guild),
) -> rest.Call(channel.ActiveThreads)
GET /guilds/{guild.id}/threads/active, every active thread the bot can
see. Unpaged, so the answer is an ActiveThreads and not a ThreadList.
pub fn get_ban(
guild: id.Id(id.Guild),
user: id.Id(id.User),
) -> rest.Call(guild.Ban)
GET /guilds/{guild.id}/bans/{user.id}, which answers 404 when the user
is not banned rather than an empty success.
pub fn get_bans(
guild: id.Id(id.Guild),
cursor cursor: option.Option(BanCursor),
limit limit: option.Option(Int),
) -> rest.Call(List(guild.Ban))
GET /guilds/{guild.id}/bans. Discord caps limit at 1000.
pub fn get_channels(
guild: id.Id(id.Guild),
) -> rest.Call(List(channel.Channel))
GET /guilds/{guild.id}/channels. Threads are not included.
pub fn get_guild(
guild: id.Id(id.Guild),
with_counts with_counts: Bool,
) -> rest.Call(guild.Guild)
GET /guilds/{guild.id}. with_counts adds approximate_member_count
and approximate_presence_count, absent without it.
pub fn get_members(
guild: id.Id(id.Guild),
after after: option.Option(id.Id(id.User)),
limit limit: option.Option(Int),
) -> rest.Call(List(member.GuildMember))
GET /guilds/{guild.id}/members, paged by user id. Without the privileged
GUILD_MEMBERS intent Discord answers 403, not a short list: the short list
is GUILD_CREATE’s behaviour, over on model/guild.GatewayCreate.members.
Discord caps limit at 1000 and defaults it to 1.
pub fn kick_member(
guild: id.Id(id.Guild),
user: id.Id(id.User),
) -> rest.Call(Nil)
DELETE /guilds/{guild.id}/members/{user.id}, a kick.
pub fn remove_member_role(
guild: id.Id(id.Guild),
user: id.Id(id.User),
role: id.Id(id.Role),
) -> rest.Call(Nil)
pub fn search_members(
guild: id.Id(id.Guild),
query search: String,
limit limit: option.Option(Int),
) -> rest.Call(List(member.GuildMember))
GET /guilds/{guild.id}/members/search, a prefix match on username or
nickname. Discord caps limit at 1000 and defaults it to 1.