disgm

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2024 License: MIT Imports: 14 Imported by: 0

README

Disgm

Disgm(discord-guild-manager) routes WebSocket events from the Discord API to a registered client, ensuring real-time delivery of events like messages, member updates, and role changes. Additionally, it handles REST API requests from the client, managing actions such as sending messages or modifying guild settings. This system ensures smooth communication between the Discord API and the client, providing efficient event routing and API request management.

Installation

go get -u github.com/rif223/disgm

Documentation

--> Here!!!

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddGuildBan

func AddGuildBan(c *fiber.Ctx, s *discordgo.Session) error

AddGuildBan adds a ban to a user in a Discord guild.

This function bans a member from a guild by using the guild ID and user ID. It also allows for specifying a reason and the number of days of message history to delete.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Request Parameters:

  • userid: The ID of the user to be banned.

Request Context:

  • ID: The ID of the guild is stored in the Fiber context under the key "ID".

Request Body:

  • The request body should contain a JSON object with the fields "reason" (string) and "delete_message_days" (int).

Returns:

  • On success, it returns HTTP status 204 (No Content).
  • On failure, it returns an HTTP status 400 (Bad Request) if the request body is invalid, or HTTP status 500 (Internal Server Error) if the ban creation fails.

@Summary Add Guild Ban @Description Ban a user from the guild. @Tags Bans @Param userid path string true "User ID" @Success 204 @Failure 500 {object} error @Router /api/guild/bans/{userid} [put]

func AddMemberRole

func AddMemberRole(c *fiber.Ctx, s *discordgo.Session) error

AddMemberRole adds a role to a guild member.

This function extracts the guild ID, member ID, and role ID from the Fiber context and request parameters. It uses the DiscordGo session to add the specified role to the member.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Returns:

  • On success, it returns HTTP status 204 (No Content).
  • On failure, it returns an HTTP status 500 and an error message if the role cannot be added.

@Summary Add Member Role @Description Add a role to a specific member in the guild. @Tags Roles @Param memberid path string true "Member ID" @Param roleid path string true "Role ID" @Success 204 @Failure 500 {object} error @Router /api/guild/members/{memberid}/roles/{roleid} [put]

func BulkBanMembers

func BulkBanMembers(c *fiber.Ctx, s *discordgo.Session) error

BulkBanMembers bans multiple members from a Discord guild.

This function bans multiple users at once in a guild. The user IDs are provided in the request body as an array, and each user is banned using the DiscordGo session.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Request Context:

  • ID: The ID of the guild is stored in the Fiber context under the key "ID".

Request Body:

  • The body should contain an array of user IDs (strings) to be banned.

Returns:

  • On success, it returns HTTP status 204 (No Content).
  • On failure, it returns an HTTP status 400 (Bad Request) if the request body is invalid, or HTTP status 500 (Internal Server Error) if banning any user fails.

@Summary Bulk Ban Members @Description Ban multiple users in the guild at once. @Tags Bans @Success 204 @Failure 500 {object} error @Router /api/guild/bulk-ban [post]

func CreateGuildApplicationCommand

func CreateGuildApplicationCommand(c *fiber.Ctx, s *discordgo.Session) error

CreateGuildApplicationCommand registers a new application command for a specific guild.

This function creates a new application command in the specified guild by providing the command data in the request body. The command is associated with the bot's application ID.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Request Context:

  • ID: The guild ID is stored in the Fiber context under the key "ID".

Request Body:

  • The request body should contain the application command data in JSON format.

Returns:

  • On success, it returns the newly created application command as JSON.
  • On failure, it returns an HTTP status 400 (Bad Request) if the request body is invalid, or an HTTP status 500 (Internal Server Error) if command creation fails.

@Summary Create Guild Application Command @Description Create a new guild application command. @Tags Commands @Success 201 {object} models.ApplicationCommand @Failure 500 {object} error @Router /api/guild/commands [post]

func CreateGuildChannel

func CreateGuildChannel(c *fiber.Ctx, s *discordgo.Session) error

CreateGuildChannel creates a new channel in the specified guild.

This function creates a new text, voice, or category channel in a guild based on the channel creation data provided in the request body. The guild ID is obtained from the Fiber context.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Request Context:

  • ID: The guild ID is stored in the Fiber context under the key "ID".

Request Body:

  • The request body should contain the channel creation data in JSON format.

Returns:

  • On success, it returns the newly created channel as JSON.
  • On failure, it returns an HTTP status 400 (Bad Request) if the request body is invalid, or an HTTP status 500 (Internal Server Error) if channel creation fails.

@Summary Create Guild Channel @Description Create a new channel in the guild. @Tags Channels @Success 201 {object} models.Channel @Failure 500 {object} error @Router /api/guild/channels [post]

func CreateGuildRole

func CreateGuildRole(c *fiber.Ctx, s *discordgo.Session) error

CreateGuildRole creates a new role in a guild.

This function extracts the guild ID from the Fiber context and parses the request body to get role parameters. It uses the DiscordGo session to create a new role in the guild.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Returns:

  • On success, it returns the created role as JSON with HTTP status 201.
  • On failure, it returns an HTTP status 500 and an error message if the role cannot be created.

@Summary Create a new role in a guild @Description Create a new role in a guild using the provided role parameters. @Tags Roles @Param body body models.RoleParams true "Role parameters" @Success 201 {object} models.Role @Failure 500 {object} error @Router /api/guild/roles [post]

func CreateInteractionCallback

func CreateInteractionCallback(c *fiber.Ctx, s *discordgo.Session) error

CreateInteractionCallback handles the creation of a response to a Discord interaction.

This function receives an interaction ID and interaction token from the request parameters, along with the interaction response data from the request body. It then sends the interaction response using the provided DiscordGo session.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Request Parameters:

  • interactionid: The ID of the interaction.
  • interactiontoken: The token of the interaction.

Request Body:

  • The body should contain a valid `discordgo.InteractionResponse` object in JSON format.

Returns:

  • On success, it returns HTTP status 204 (No Content).
  • On failure, it returns an HTTP status 400 (Bad Request) if the request body is invalid, or HTTP status 500 (Internal Server Error) if there is a problem sending the response.

@Summary Create Interaction Callback @Description Handle interaction callback for a specific interaction. @Tags Interactions @Param interactionid path string true "Interaction ID" @Param interactiontoken path string true "Interaction Token" @Success 204 @Failure 500 {object} error @Router /api/guild/interactions/{interactionid}/{interactiontoken}/callback [post]

func CreateMessageReaction

func CreateMessageReaction(c *fiber.Ctx, s *discordgo.Session) error

CreateMessageReaction adds a reaction to a specific message with a given emoji.

This function extracts the channel ID, message ID, and emoji ID from the Fiber context and request parameters. It uses the DiscordGo session to add a reaction to the specified message with the given emoji.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Returns:

  • On success, it returns HTTP status 204 (No Content) if the reaction is successfully added.
  • On failure, it returns an HTTP status 500 and an error message if the reaction cannot be added.

@Summary Create Message Reaction @Description Add a reaction to a specific message in a channel. @Tags Reactions @Param channelid path string true "Channel ID" @Param messageid path string true "Message ID" @Param emojiid path string true "Emoji ID" @Success 201 @Failure 500 {object} error @Router /api/guild/channels/{channelid}/messages/{messageid}/reactions/{emojiid} [put]

func DeleteAllMessageReaction

func DeleteAllMessageReaction(c *fiber.Ctx, s *discordgo.Session) error

DeleteAllMessageReaction removes all reactions from a message.

This function extracts the channel ID and message ID from the Fiber context and request parameters. It uses the DiscordGo session to remove all reactions from the specified message.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Returns:

  • On success, it returns HTTP status 204 (No Content) if all reactions are successfully removed.
  • On failure, it returns an HTTP status 500 and an error message if the reactions cannot be removed.

@Summary Delete All Message Reactions @Description Remove all reactions from a specific message in a channel. @Tags Reactions @Param channelid path string true "Channel ID" @Param messageid path string true "Message ID" @Success 204 @Failure 500 {object} error @Router /api/guild/channels/{channelid}/messages/{messageid}/reactions [delete]

func DeleteChannelMessage

func DeleteChannelMessage(c *fiber.Ctx, s *discordgo.Session) error

DeleteChannelMessage deletes a specific message from a Discord channel.

This function extracts the channel ID and message ID from the Fiber context and request parameters. It uses the DiscordGo session to delete the specified message from the given channel.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Returns:

  • On success, it returns HTTP status 204 (No Content) if the message is successfully deleted.
  • On failure, it returns an HTTP status 500 and an error message if the message cannot be deleted.

@Summary Delete Channel Message @Description Delete a specific message in a channel by ID. @Tags Messages @Param channelid path string true "Channel ID" @Param messageid path string true "Message ID" @Success 204 @Failure 500 {object} error @Router /api/guild/channels/{channelid}/messages/{messageid} [delete]

func DeleteChannelPermissions

func DeleteChannelPermissions(c *fiber.Ctx, s *discordgo.Session) error

DeleteChannelPermissions removes a permission overwrite for a channel.

This function deletes an existing permission overwrite for a channel using the channel ID and overwrite ID provided in the request parameters.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Request Parameters:

  • channelid: The ID of the channel where permissions will be deleted.
  • overwriteid: The ID of the user or role whose permission overwrite will be deleted.

Returns:

  • On success, it returns HTTP status 204 (No Content).
  • On failure, it returns an HTTP status 500 (Internal Server Error) with an error message.

@Summary Delete Channel Permissions @Description Delete a specific permission overwrite for a channel. @Tags Channels @Param channelid path string true "Channel ID" @Param overwriteid path string true "Overwrite ID" @Success 204 @Failure 500 {object} error @Router /api/guild/channels/{channelid}/permissions/{overwriteid} [delete]

func DeleteGuildApplicationCommand

func DeleteGuildApplicationCommand(c *fiber.Ctx, s *discordgo.Session) error

DeleteGuildApplicationCommand deletes a specific application command from a guild.

This function removes an existing application command from a guild, using the guild ID from the Fiber context and the command ID provided in the request parameters.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Request Parameters:

  • cmdid: The ID of the application command to delete.

Request Context:

  • ID: The guild ID is stored in the Fiber context under the key "ID".

Returns:

  • On success, it returns HTTP status 204 (No Content).
  • On failure, it returns an HTTP status 500 (Internal Server Error) with an error message.

@Summary Delete Guild Application Command @Description Delete a guild application command by ID. @Tags Commands @Param cmdid path string true "Command ID" @Success 204 @Failure 500 {object} error @Router /api/guild/commands/{cmdid} [delete]

func DeleteGuildChannel

func DeleteGuildChannel(c *fiber.Ctx, s *discordgo.Session) error

DeleteGuildChannel deletes a channel from a guild.

This function deletes a channel using the channel ID passed in the request parameters. Deleting a channel will also remove all associated messages within the channel.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Request Parameters:

  • channelid: The ID of the channel to delete.

Returns:

  • On success, it returns the details of the deleted channel as JSON.
  • On failure, it returns an HTTP status 500 (Internal Server Error) with an error message.

@Summary Delete Guild Channel @Description Delete a specific channel in the guild. @Tags Channels @Param channelid path string true "Channel ID" @Success 204 @Failure 500 {object} error @Router /api/guild/channels/{channelid} [delete]

func DeleteGuildRole

func DeleteGuildRole(c *fiber.Ctx, s *discordgo.Session) error

DeleteGuildRole deletes a specific role from a guild.

This function extracts the guild ID and role ID from the Fiber context and request parameters, and uses the DiscordGo session to delete the role from the guild.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Returns:

  • On success, it returns an HTTP status 204 (No Content).
  • On failure, it returns an HTTP status 500 and an error message if the role cannot be deleted.

@Summary Delete a role from a guild @Description Delete a specific role from a guild using its role ID. @Tags Roles @Param roleid path string true "ID of the role to delete" @Success 204 @Failure 500 {object} error @Router /api/guild/roles/{roleid} [delete]

func DeleteMessageReaction

func DeleteMessageReaction(c *fiber.Ctx, s *discordgo.Session) error

DeleteMessageReaction removes a specific user's reaction from a message.

This function extracts the channel ID, message ID, emoji ID, and user ID from the Fiber context and request parameters. It uses the DiscordGo session to remove a user's reaction to a message.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Returns:

  • On success, it returns HTTP status 204 (No Content) if the reaction is successfully removed.
  • On failure, it returns an HTTP status 500 and an error message if the reaction cannot be removed.

@Summary Delete Message Reaction @Description Delete a user's reaction from a specific message in a channel. @Tags Reactions @Param channelid path string true "Channel ID" @Param messageid path string true "Message ID" @Param emojiid path string true "Emoji ID" @Param userid path string true "User ID" @Success 204 @Failure 500 {object} error @Router /api/guild/channels/{channelid}/messages/{messageid}/reactions/{emojiid}/{userid} [delete]

func DeleteMessageReactionEmoji

func DeleteMessageReactionEmoji(c *fiber.Ctx, s *discordgo.Session) error

DeleteMessageReactionEmoji removes all reactions for a specific emoji from a message.

This function extracts the channel ID, message ID, and emoji ID from the Fiber context and request parameters. It uses the DiscordGo session to remove all reactions for the specified emoji from the message.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Returns:

  • On success, it returns HTTP status 204 (No Content) if all reactions for the emoji are successfully removed.
  • On failure, it returns an HTTP status 500 and an error message if the reactions cannot be removed.

@Summary Delete Message Reaction Emoji @Description Remove a specific emoji reaction from a message in a channel. @Tags Reactions @Param channelid path string true "Channel ID" @Param messageid path string true "Message ID" @Param emojiid path string true "Emoji ID" @Success 204 @Failure 500 {object} error @Router /api/guild/channels/{channelid}/messages/{messageid}/reactions/{emojiid} [delete]

func EditChannelMessage

func EditChannelMessage(c *fiber.Ctx, s *discordgo.Session) error

EditChannelMessage edits an existing message in a specific Discord channel.

This function extracts the channel ID and message ID from the Fiber context and request parameters. The new message content is provided in the request body and parsed into a `discordgo.MessageEdit` struct. It uses the DiscordGo session to edit the message in the specified channel.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Returns:

  • On success, it returns the edited message as JSON with HTTP status 200.
  • On failure, it returns an HTTP status 500 and an error message if the message cannot be edited.

@Summary Edit Channel Message @Description Edit a specific message in a channel by ID. @Tags Messages @Param channelid path string true "Channel ID" @Param messageid path string true "Message ID" @Success 200 {object} models.Message @Failure 500 {object} error @Router /api/guild/channels/{channelid}/messages/{messageid} [patch]

func EditChannelPermissions

func EditChannelPermissions(c *fiber.Ctx, s *discordgo.Session) error

EditChannelPermissions updates the permission overwrites for a channel.

This function modifies the permissions for a channel by applying permission overwrites for a specific user or role, using the channel ID and overwrite ID provided in the request parameters.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Request Parameters:

  • channelid: The ID of the channel where permissions will be edited.
  • overwriteid: The ID of the user or role whose permissions will be overwritten.

Request Body:

  • The request body should contain the permission overwrite details in JSON format.

Returns:

  • On success, it returns HTTP status 204 (No Content).
  • On failure, it returns an HTTP status 400 (Bad Request) if the request body is invalid, or an HTTP status 500 (Internal Server Error) if permission updates fail.

@Summary Edit Channel Permissions @Description Edit permissions for a specific channel in the guild. @Tags Channels @Param channelid path string true "Channel ID" @Param overwriteid path string true "Overwrite ID" @Success 204 @Failure 500 {object} error @Router /api/guild/channels/{channelid}/permissions/{overwriteid} [put]

func EventCall

func EventCall(id string, name string, data interface{}) error

EventCall is used to send an event to a specific client identified by the ID. It marshals the event data to JSON and sends it via WebSocket to the client.

func GetBotUser

func GetBotUser(c *fiber.Ctx, s *discordgo.Session) error

GetBotUser is a handler function that retrieves the bot's user information from the Discord API and returns it as a JSON response.

It uses the DiscordGo session (`s`) to fetch the bot's user object, which represents the bot account itself, identified by "@me".

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session that provides the connection to the Discord API.

Returns:

  • If successful, it returns the user object in JSON format with HTTP status 200.
  • If an error occurs while retrieving the bot user, it returns an HTTP status 500 with an error message. @Summary Get Bot User @Description Retrieve the bot's user information. @Tags User @Success 200 {object} User @Failure 500 {object} error @Router /api/user [get]

func GetChannelMessage

func GetChannelMessage(c *fiber.Ctx, s *discordgo.Session) error

GetChannelMessage retrieves a specific message from a Discord channel by its ID.

This function extracts the channel ID and message ID from the Fiber context and request parameters. It uses the DiscordGo session to retrieve the specified message from the given channel.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Returns:

  • On success, it returns the message as JSON with HTTP status 200.
  • On failure, it returns an HTTP status 500 and an error message if the message cannot be retrieved.

@Summary Get Channel Message @Description Retrieve a specific message by ID from a channel. @Tags Messages @Param channelid path string true "Channel ID" @Param messageid path string true "Message ID" @Success 200 {object} models.Message @Failure 500 {object} error @Router /api/guild/channels/{channelid}/messages/{messageid} [get]

func GetChannelMessages

func GetChannelMessages(c *fiber.Ctx, s *discordgo.Session) error

GetChannelMessages retrieves up to 100 messages from a specific Discord channel.

This function extracts the channel ID from the Fiber context and request parameters. It uses the DiscordGo session to retrieve the latest 100 messages from the specified channel.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Returns:

  • On success, it returns the list of messages as JSON with HTTP status 200.
  • On failure, it returns an HTTP status 500 and an error message if the messages cannot be retrieved.

@Summary Get Channel Messages @Description Retrieve all messages from a specific channel. @Tags Messages @Param channelid path string true "Channel ID" @Success 200 {array} Message @Failure 500 {object} error @Router /api/guild/channels/{channelid}/messages [get]

func GetGuild

func GetGuild(c *fiber.Ctx, s *discordgo.Session) error

GetGuild retrieves the details of a Discord guild.

This function fetches the guild information using the guild ID, which is extracted from the request context. It uses the DiscordGo session to request guild details from the Discord API.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Request Context:

  • ID: The ID of the guild is stored in the Fiber context under the key "ID".

Returns:

  • On success, it returns the guild details as JSON.
  • On failure, it returns an HTTP status 500 (Internal Server Error) with an error message.

@Summary Get Guild @Description Retrieve the guild information. @Tags Guild @Success 200 {object} Guild @Failure 500 {object} error @Router /api/guild [get]

func GetGuildApplicationCommand

func GetGuildApplicationCommand(c *fiber.Ctx, s *discordgo.Session) error

GetGuildApplicationCommand retrieves a specific application command for a guild.

This function fetches details for a specific application command by its ID, using the guild ID from the Fiber context and the bot's application ID from the Discord API.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Request Parameters:

  • cmdid: The ID of the application command to retrieve.

Request Context:

  • ID: The guild ID is stored in the Fiber context under the key "ID".

Returns:

  • On success, it returns the application command details as JSON.
  • On failure, it returns an HTTP status 500 (Internal Server Error) with an error message.

@Summary Get Guild Application Command @Description Retrieve a specific guild application command by ID. @Tags Commands @Param cmdid path string true "Command ID" @Success 200 {object} models.ApplicationCommand @Failure 500 {object} error @Router /api/guild/commands/{cmdid} [get]

func GetGuildApplicationCommands

func GetGuildApplicationCommands(c *fiber.Ctx, s *discordgo.Session) error

GetGuildApplicationCommands retrieves all application commands for a specific guild.

This function fetches the list of application commands registered for a guild, using the guild ID from the Fiber context and the bot's application ID retrieved from the Discord API.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Request Context:

  • ID: The guild ID is stored in the Fiber context under the key "ID".

Returns:

  • On success, it returns a JSON list of application commands.
  • On failure, it returns an HTTP status 500 (Internal Server Error) with an error message.

@Summary Get Guild Application Commands @Description Retrieve all guild application commands. @Tags Commands @Success 200 {array} ApplicationCommandArray @Failure 500 {object} error @Router /api/guild/commands [get]

func GetGuildBan

func GetGuildBan(c *fiber.Ctx, s *discordgo.Session) error

GetGuildBan retrieves information about a specific banned member in a guild.

This function fetches the details of a specific ban using the guild ID and user ID, both of which are retrieved from the request parameters and context.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Request Parameters:

  • userid: The ID of the banned user.

Request Context:

  • ID: The ID of the guild is stored in the Fiber context under the key "ID".

Returns:

  • On success, it returns the details of the banned member as JSON.
  • On failure, it returns an HTTP status 500 (Internal Server Error) with an error message.

@Summary Get Guild Ban @Description Retrieve a specific banned user by user ID. @Tags Bans @Param userid path string true "User ID" @Success 200 {object} models.GuildBan @Failure 500 {object} error @Router /api/guild/bans/{userid} [get]

func GetGuildBans

func GetGuildBans(c *fiber.Ctx, s *discordgo.Session) error

GetGuildBans retrieves the list of bans for a Discord guild.

This function fetches a list of banned members from a guild by using the guild ID, which is stored in the request context. It returns up to 100 bans at a time.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Request Context:

  • ID: The ID of the guild is stored in the Fiber context under the key "ID".

Returns:

  • On success, it returns the list of bans as JSON.
  • On failure, it returns an HTTP status 500 (Internal Server Error) with an error message.

@Summary Get Guild Bans @Description Retrieve all banned users from the guild. @Tags Bans @Success 200 {array} models.GuildBan @Failure 500 {object} error @Router /api/guild/bans [get]

func GetGuildChannel

func GetGuildChannel(c *fiber.Ctx, s *discordgo.Session) error

GetGuildChannel retrieves a specific channel by its ID.

This function fetches the details of a specific guild channel using the channel ID passed in the request parameters.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Request Parameters:

  • channelid: The ID of the channel to retrieve.

Returns:

  • On success, it returns the channel details as JSON.
  • On failure, it returns an HTTP status 500 (Internal Server Error) with an error message.

@Summary Get Guild Channel @Description Retrieve a specific channel from the guild by ID. @Tags Channels @Param channelid path string true "Channel ID" @Success 200 {object} models.Channel @Failure 500 {object} error @Router /api/guild/channels/{channelid} [get]

func GetGuildChannels

func GetGuildChannels(c *fiber.Ctx, s *discordgo.Session) error

GetGuildChannels retrieves all channels for a specific guild.

This function fetches the list of all channels in a guild using the guild ID stored in the Fiber context. The channels include text, voice, and category channels.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Request Context:

  • ID: The guild ID is stored in the Fiber context under the key "ID".

Returns:

  • On success, it returns a JSON list of guild channels.
  • On failure, it returns an HTTP status 500 (Internal Server Error) with an error message.

@Summary Get Guild Channels @Description Retrieve all channels from the guild. @Tags Channels @Success 200 {array} ChannelArray @Failure 500 {object} error @Router /api/guild/channels [get]

func GetGuildMember

func GetGuildMember(c *fiber.Ctx, s *discordgo.Session) error

GetGuildMember retrieves a specific member from a Discord guild using their member ID.

This function extracts the guild ID from the Fiber context and the member ID from the request parameters. It uses the DiscordGo session to retrieve the member from the specified guild.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Returns:

  • On success, it returns the guild member as JSON with HTTP status 200.
  • On failure, it returns an HTTP status 500 and an error message if the member cannot be retrieved.

@Summary Get Guild Member @Description Retrieve a specific member from the guild by ID. @Tags Members @Param memberid path string true "Member ID" @Success 200 {object} models.Member @Failure 500 {object} error @Router /api/guild/members/{memberid} [get]

func GetGuildMembers

func GetGuildMembers(c *fiber.Ctx, s *discordgo.Session) error

GetGuildMembers retrieves a list of up to 1000 members from a specific Discord guild.

This function extracts the guild ID from the Fiber context and uses the DiscordGo session to retrieve the guild members. It fetches up to 1000 members from the specified guild.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Returns:

  • On success, it returns the list of guild members as JSON with HTTP status 200.
  • On failure, it returns an HTTP status 500 and an error message if the members cannot be retrieved.

@Summary Get Guild Members @Description Retrieve all members of the guild. @Tags Members @Success 200 {array} Member @Failure 500 {object} error @Router /api/guild/members [get]

func GetGuildRole

func GetGuildRole(c *fiber.Ctx, s *discordgo.Session) error

GetGuildRole retrieves a specific role from a guild.

This function extracts the guild ID and role ID from the Fiber context and request parameters, respectively, and uses the DiscordGo session to fetch the role.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Returns:

  • On success, it returns the role object as JSON with HTTP status 200.
  • On failure, it returns an HTTP status 500 and an error message if the role cannot be retrieved.

@Summary Get a specific role in a guild @Description Retrieve a specific role from a guild by its role ID. @Tags Roles @Param roleid path string true "ID of the role to retrieve" @Success 200 {object} models.Role @Failure 500 {object} error @Router /api/guild/roles/{roleid} [get]

func GetGuildRoles

func GetGuildRoles(c *fiber.Ctx, s *discordgo.Session) error

GetGuildRoles retrieves all roles of a specific guild.

This function extracts the guild ID from the Fiber context's locals and uses the DiscordGo session to fetch all roles in the guild.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Returns:

  • On success, it returns the roles as a JSON array with HTTP status 200.
  • On failure, it returns an HTTP status 500 and an error message if the roles cannot be retrieved.

@Summary Get all roles in a guild @Description Retrieve all roles of a specific guild using the guild ID. @Tags Roles @Success 200 {array} Role @Failure 500 {object} error @Router /api/guild/roles [get]

func GetMemberRoles

func GetMemberRoles(c *fiber.Ctx, s *discordgo.Session) error

GetMemberRoles retrieves the roles of a specific guild member.

This function extracts the guild ID and member ID from the Fiber context and request parameters. It uses the DiscordGo session to retrieve the member's roles in the specified guild.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Returns:

  • On success, it returns the list of roles assigned to the member as JSON with HTTP status 200.
  • On failure, it returns an HTTP status 500 and an error message if the member roles cannot be retrieved.

@Summary Get Member Roles @Description Retrieve all roles assigned to a specific member in the guild. @Tags Roles @Param memberid path string true "Member ID" @Success 200 {array} models.Role @Failure 500 {object} error @Router /api/guild/members/{memberid}/roles [get]

func GetMessageReactions

func GetMessageReactions(c *fiber.Ctx, s *discordgo.Session) error

GetMessageReactions retrieves the users who reacted to a specific message with a given emoji.

This function extracts the channel ID, message ID, and emoji ID from the Fiber context and request parameters. It uses the DiscordGo session to retrieve the list of users who reacted with the specified emoji.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Returns:

  • On success, it returns the list of users who reacted with the emoji as JSON with HTTP status 200.
  • On failure, it returns an HTTP status 500 and an error message if the reactions cannot be retrieved.

@Summary Get Message Reactions @Description Retrieve all reactions from a specific message in a channel. @Tags Reactions @Param channelid path string true "Channel ID" @Param messageid path string true "Message ID" @Param emojiid path string true "Emoji ID" @Success 200 {array} UserArray @Failure 500 {object} error @Router /api/guild/channels/{channelid}/messages/{messageid}/reactions/{emojiid} [get]

func KickMember

func KickMember(c *fiber.Ctx, s *discordgo.Session) error

KickMember removes a member from the guild.

This function extracts the guild ID and member ID from the Fiber context and request parameters. It uses the DiscordGo session to remove the specified member from the guild.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Returns:

  • On success, it returns HTTP status 204 (No Content).
  • On failure, it returns an HTTP status 500 and an error message if the member cannot be removed.

@Summary Kick Member @Description Remove a member from the specified guild. @Tags Members @Param memberid path string true "Member ID" @Success 204 @Failure 500 {object} error @Router /guilds/{guildid}/members/{memberid} [delete]

func NewInteractionRespond

func NewInteractionRespond(s *discordgo.Session, id string, token string, resp *discordgo.InteractionResponse, options ...discordgo.RequestOption) error

NewInteractionRespond sends a response to a Discord interaction.

This function sends an interaction response to the Discord API using the interaction ID and token. If the response contains files (attachments), it uses multipart form data to handle them.

Parameters:

  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.
  • id: string – The interaction ID.
  • token: string – The interaction token.
  • resp: *discordgo.InteractionResponse – The response data to be sent for the interaction.
  • options: (optional) Additional request options (e.g., custom headers).

Returns:

  • On success, it returns `nil`.
  • On failure, it returns an error if there is an issue preparing or sending the request.

func RemoveGuildBan

func RemoveGuildBan(c *fiber.Ctx, s *discordgo.Session) error

RemoveGuildBan removes a ban from a user in a Discord guild.

This function lifts the ban on a specific member by using the guild ID and user ID from the request parameters and context.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Request Parameters:

  • userid: The ID of the user whose ban should be removed.

Request Context:

  • ID: The ID of the guild is stored in the Fiber context under the key "ID".

Returns:

  • On success, it returns HTTP status 204 (No Content).
  • On failure, it returns an HTTP status 500 (Internal Server Error) with an error message.

@Summary Remove Guild Ban @Description Remove a ban for a user in the guild. @Tags Bans @Param userid path string true "User ID" @Success 204 @Failure 500 {object} error @Router /api/guild/bans/{userid} [delete]

func RemoveMemberRole

func RemoveMemberRole(c *fiber.Ctx, s *discordgo.Session) error

RemoveMemberRole removes a role from a guild member.

This function extracts the guild ID, member ID, and role ID from the Fiber context and request parameters. It uses the DiscordGo session to remove the specified role from the member.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Returns:

  • On success, it returns HTTP status 204 (No Content).
  • On failure, it returns an HTTP status 500 and an error message if the role cannot be removed.

@Summary Remove Member Role @Description Remove a role from a specific member in the guild. @Tags Roles @Param memberid path string true "Member ID" @Param roleid path string true "Role ID" @Success 204 @Failure 500 {object} error @Router /api/guild/members/{memberid}/roles/{roleid} [delete]

func Router

func Router(router fiber.Router, s *discordgo.Session)

func SendChannelMessage

func SendChannelMessage(c *fiber.Ctx, s *discordgo.Session) error

SendChannelMessage sends a message to a specific Discord channel.

This function extracts the channel ID from the Fiber context and request parameters. The message content is provided in the request body and parsed into a `discordgo.MessageSend` struct. It uses the DiscordGo session to send the message to the specified channel.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Returns:

  • On success, it returns the sent message as JSON with HTTP status 200.
  • On failure, it returns an HTTP status 500 and an error message if the message cannot be sent.

@Summary Send Channel Message @Description Send a new message to a specific channel. @Tags Messages @Param channelid path string true "Channel ID" @Success 201 {object} models.Message @Failure 500 {object} error @Router /api/guild/channels/{channelid}/messages [post]

func TokenMiddleware

func TokenMiddleware(disgm *Disgm, c *fiber.Ctx) error

func UpdateGuildChannel

func UpdateGuildChannel(c *fiber.Ctx, s *discordgo.Session) error

UpdateGuildChannel updates an existing guild channel.

This function updates the settings of a specific channel using the channel ID passed in the request parameters and the new channel settings provided in the request body.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Request Parameters:

  • channelid: The ID of the channel to update.

Request Body:

  • The request body should contain the new channel settings in JSON format.

Returns:

  • On success, it returns the updated channel as JSON.
  • On failure, it returns an HTTP status 400 (Bad Request) if the request body is invalid, or an HTTP status 500 (Internal Server Error) if the update fails.

@Summary Update Guild Channel @Description Update a specific channel in the guild. @Tags Channels @Param channelid path string true "Channel ID" @Success 200 {object} models.Channel @Failure 500 {object} error @Router /api/guild/channels/{channelid} [patch]

func UpdateGuildMember

func UpdateGuildMember(c *fiber.Ctx, s *discordgo.Session) error

UpdateGuildMember modifies the settings of a guild member.

This function extracts the guild ID and member ID from the Fiber context and request parameters. It parses the request body into a `discordgo.GuildMemberParams` struct and uses it to update the member's settings (e.g., nickname, roles, mute, etc.).

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Returns:

  • On success, it returns the updated guild member as JSON with HTTP status 200.
  • On failure, it returns an HTTP status 500 and an error message if the member cannot be updated.

@Summary Update Guild Member @Description Update a specific member in the guild. @Tags Members @Param memberid path string true "Member ID" @Success 200 {object} models.Member @Failure 500 {object} error @Router /api/guild/members/{memberid} [patch]

func UpdateGuildRole

func UpdateGuildRole(c *fiber.Ctx, s *discordgo.Session) error

UpdateGuildRole updates a specific role in a guild.

This function extracts the guild ID and role ID from the Fiber context and request parameters, and parses the request body for role data. It uses the DiscordGo session to update the role.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Returns:

  • On success, it returns the updated role as JSON with HTTP status 200.
  • On failure, it returns an HTTP status 500 and an error message if the role cannot be updated.

@Summary Update a specific role in a guild @Description Update a specific role in a guild using the provided role data. @Tags Roles @Param roleid path string true "ID of the role to update" @Param body body models.RoleParams true "Updated role parameters" @Success 200 {object} models.Role @Failure 500 {object} error @Router /api/guild/roles/{roleid} [patch]

func UpdateGuildRolePositions

func UpdateGuildRolePositions(c *fiber.Ctx, s *discordgo.Session) error

UpdateGuildRolePositions reorders the roles in a guild.

This function extracts the guild ID from the Fiber context and parses the request body for the new role positions. It uses the DiscordGo session to update the role positions in the guild.

Parameters:

  • c: *fiber.Ctx – The Fiber context used to handle HTTP requests and responses.
  • s: *discordgo.Session – The DiscordGo session used to interact with the Discord API.

Returns:

  • On success, it returns the updated roles as JSON with HTTP status 200.
  • On failure, it returns an HTTP status 500 and an error message if the role positions cannot be updated.

@Summary Update role positions in a guild @Description Reorder the roles in a guild based on the provided positions. @Tags Roles @Param body body []models.Role true "New role positions" @Success 200 {array} models.Role @Failure 500 {object} error @Router /api/guild/roles [patch]

func WebSocket

func WebSocket(conn *websocket.Conn, id string)

WebSocket function manages the lifecycle of a WebSocket connection. It registers the client, sends a welcome message, and listens for incoming messages.

Types

type ApplicationCommandArray

type ApplicationCommandArray = []models.ApplicationCommand

type ChannelArray

type ChannelArray = []models.Channel

type Disgm

type Disgm struct {
	// contains filtered or unexported fields
}

Disgm is the main structure for the package, containing the Discord session and the Fiber server.

func New

func New(s *discordgo.Session, options ...Options) (d *Disgm, err error)

@title Discord Guild Management API @version 1.0 @description API for managing Discord guilds using DiscordGo and Fiber. @host localhost:90

func (*Disgm) Listen

func (d *Disgm) Listen(port ...string) (err error)

Listen starts the Fiber server on the specified port.

This method belongs to the `Disgm` type and initializes an HTTP server using the Fiber framework. By default, the port is set to ":90" if no other port is specified.

Parameters:

  • port (string): The port on which the server should listen. Defaults to ":90" if left empty.

Return:

  • error: Returns an error if the server fails to start.

Functionality:

  • Starts the server in a separate goroutine using Fiber (`app.Listen(port)`) to avoid blocking execution and logs any errors encountered during startup.
  • On success, logs a message indicating the actual port the server is listening on.

func (*Disgm) RegisterApiRouter

func (d *Disgm) RegisterApiRouter()

Register Api Router

func (*Disgm) RegisterWebSocket

func (d *Disgm) RegisterWebSocket()

@Summary Register WebSocket @Description Sets up the WebSocket connection to handle Discord events and messages. @Tags WebSocket @Produce json @Router /ws [get]

type Event

type Event struct {
	Name string      `json:"name"`
	Data interface{} `json:"data"`
}

Event struct defines the structure of an event that is sent to clients over WebSocket. It contains the event name and the associated data.

type Guild

type Guild = models.Guild

type Member

type Member = models.Member

type Message

type Message = models.Message

type Options

type Options struct {
	DisableStartupMessage bool
	DisableLogger         bool
	TokenStore            store.TokenStore // A map of valid tokens for authentication.
}

Options contains the configuration for the disgm package.

type Role

type Role = models.Role

type User

type User = models.User

type UserArray

type UserArray = []models.User

Directories

Path Synopsis
Package docs Code generated by swaggo/swag.
Package docs Code generated by swaggo/swag.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL