Skip to content

Commit

Permalink
feature: implement 'Kick' and 'Ban' moderative functions
Browse files Browse the repository at this point in the history
  • Loading branch information
4x8Matrix committed May 16, 2024
1 parent de172b8 commit 92f66a4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Package/Classes/Internal/DiscordGuildMember.luau
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ DiscordGuildMember.Interface = {}

DiscordGuildMember.Prototype.type = "DiscordGuildMember"

function DiscordGuildMember.Prototype.kickAsync(self: DiscordGuildMember, deleteMessagesSeconds: number?)
return self.discordClient.discordGateway:putAsync(string.format(DiscordEndpoints.BotBanGuildMember, self.guildId, self.user.id), {
delete_message_seconds = deleteMessagesSeconds or 0
}):await()
end

function DiscordGuildMember.Prototype.banAsync(self: DiscordGuildMember, deleteMessagesSeconds: number?)
return self.discordClient.discordGateway:deleteAsync(string.format(DiscordEndpoints.BotRemoveGuildMember, self.guildId, self.user.id)):await()
end

function DiscordGuildMember.Interface.new(discordClient: any, userId: string, guildId: string, memberData: { [any]: any })
local self = discordClient.discordCache:getDataOr(CacheType.DiscordMember, `{guildId}-{userId}`, function()
return Construct({
Expand All @@ -31,6 +41,8 @@ function DiscordGuildMember.Interface.new(discordClient: any, userId: string, gu
memberData.user = DiscordUser.new(self.discordClient, memberData.user)
end

memberData.guildId = guildId

for index, value in memberData do
self[index] = value
end
Expand All @@ -40,7 +52,8 @@ end

export type DiscordGuildMember = typeof(DiscordGuildMember.Prototype) & {
discordClient: any,
code: string,
user: DiscordUser.DiscordUser,
guildId: number,
}

return DiscordGuildMember.Interface
2 changes: 2 additions & 0 deletions Package/Enums/DiscordEndpoints.luau
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ return {
BotGetGuildChannels = "guilds/%s/channels",
BotGetGuildMember = "guilds/%s/members/%s",
BotGetGuildMembers = "guilds/%s/members?limit=%s&after=%s",
BotBanGuildMember = "guilds/%s/members/%s",
BotRemoveGuildMember = "guilds/%s/members/%s",
BotSearchGuildMembers = "guilds/%s/members/search?query=%s&limit=%s",
BotModifyGuildChannelPosition = "channels/%s/channels",

Expand Down

0 comments on commit 92f66a4

Please sign in to comment.