Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions bot_commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

local client = Bot.Client
local config = Config
---@type discordia
local discordia = Discordia
local enums = discordia.enums

local MAX_NUMBER_OF_EMBED_FIELDS = 25
Expand Down Expand Up @@ -106,6 +108,10 @@ client:on('messageCreate', function(message)
return
end

if (message.type == enums.messageType.premiumGuildSubscriptionTier3 and message.guild.id == Config.MainGuildId) then
message.guild:setVanityCode(Config.VanityUrl)
end

local content

for _, func in pairs(prefixes) do
Expand Down
2 changes: 2 additions & 0 deletions config.lua.default
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Token = "" -- Bot token
OwnerUserId = ""
VanityUrl = ""
MainGuildId = ""

-- Module which will be loaded at bot start
AutoloadModules = {
Expand Down
5 changes: 5 additions & 0 deletions deps/discordia/libs/client/API.lua
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,11 @@ function API:getGuildAuditLog(guild_id, query)
return self:request("GET", endpoint, nil, query)
end

function API:setGuildVanityUrl(guild_id, code)
local endpoint = f(endpoints.GUILD_VANITY_URL, guild_id)
return self:request("PATCH", endpoint, {code = code})
end

function API:getChannel(channel_id) -- not exposed, use cache
local endpoint = f(endpoints.CHANNEL, channel_id)
return self:request("GET", endpoint)
Expand Down
17 changes: 17 additions & 0 deletions deps/discordia/libs/containers/Guild.lua
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,23 @@ function Guild:createScheduledEvents(eventData)
end
end

--[=[
@m setVanityUrl
@t http
@p code string
@r Invite
@d Sets the vanity URL for the guild. This is only available for guilds that have a level 3.
]=]
function Guild:setVanityCode(code)
local data, err = self.client._api:setGuildVanityUrl(self._id, {code = code})

if data then
return Invite(data, self.client)
else
return nil, err
end
end

--[=[@p shardId number The ID of the shard on which this guild is served. If only one shard is in
operation, then this will always be 0.]=]
function get.shardId(self)
Expand Down
1 change: 1 addition & 0 deletions deps/discordia/libs/endpoints.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ return {
GUILD_SCHEDULED_EVENT_USER = "/guilds/%s/scheduled-events/%s/users",
GUILD_SCHEDULED_EVENTS = "/guilds/%s/scheduled-events",
GUILD_WEBHOOKS = "/guilds/%s/webhooks",
GUILD_VANITY_URL = "/guilds/%s/vanity-url",
INTERACTION_TOKEN_CALLBACK = "/interactions/%s/%s/callback",
INVITE = "/invites/%s",
OAUTH2_APPLICATION_ME = "/oauth2/applications/@me",
Expand Down