Skip to content

Commit

Permalink
fixed bad message compose logic
Browse files Browse the repository at this point in the history
  • Loading branch information
BestMordaEver committed Aug 28, 2024
1 parent 049b38c commit 7542319
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Voice Manager v4.10.7
## Voice Manager v4.10.8

<a href="https://top.gg/bot/601347755046076427">
<img src="https://top.gg/api/widget/status/601347755046076427.svg" alt="Voice Manager" />
Expand Down
6 changes: 3 additions & 3 deletions libs/commands/exec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ return function (interaction)
end

local fn, syntaxError = load(interaction.option.value, "Bot", "t", sandbox)
if not fn then return "Syntax error", warningEmbed:compose(interaction)(code(syntaxError))() end
if not fn then return "Syntax error", warningEmbed:compose(interaction)("asIs", code(syntaxError))() end

local success, runtimeError = pcall(fn)
if not success then return "Runtime error", warningEmbed:compose(interaction)(code(runtimeError))() end
if not success then return "Runtime error", warningEmbed:compose(interaction)("asIs", code(runtimeError))() end

lines = table.concat(lines, '\n') -- bring all the lines together
return "Code executed", okEmbed(interaction)(code(lines))()
return "Code executed", okEmbed:compose(interaction)("asIs", code(lines))()
end
4 changes: 2 additions & 2 deletions libs/events/voiceChannelJoin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ local function roomJoin (member, channel)
}
}

member:setVoiceChannel(newChannel)
channels:store(newChannel.id, 3, member.user.id, channel.id, 0)
member:setVoiceChannel(newChannel)

return member.user:send(passwordEmbed(member.user, channel))
end
Expand Down Expand Up @@ -256,7 +256,6 @@ return function (member, channel)
if limit == -1 then
member:setVoiceChannel()
member.user:send(warningEmbed(member.user, "wait", retryIn))
processMutex:unlock()
return
end

Expand All @@ -266,6 +265,7 @@ return function (member, channel)
if not ok then error(string.format('failed to process a user %s joining lobby "%s"\n%s', member.user.id, channel.id, err)) end
end
elseif channels[channel.id] then
if channels[channel.id].parentType == 3 then return end
if channels[channel.id].host ~= member.user.id then roomJoin(member, channel) end
elseif guilds[channel.guild.id].permissions.bitfield.value ~= 0 then
channelJoin(member, channel)
Expand Down
6 changes: 4 additions & 2 deletions libs/handlers/embedHandler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ https://leovoel.github.io/embed-visualizer/
https://discord.com/developers/docs/resources/channel#embed-object
]]

local locale = "locale/runtime/localeHandler"
local locale = require "locale/runtime/localeHandler"

local wrapper = {
__call = function (self, ...)
return self.factory(...)
end
}

-- this is so ugly :/
local composeMeta = {
__call = function (self, msg, ...)
if msg then
table.insert(locale(self.locale, msg, ...))
table.insert(self.description, locale(self.locale, msg, ...))
return self
else
local embed = self.parentEmbed(self.locale, "none")
embed.embeds[1].description = table.concat(self.description)
Expand Down
1 change: 1 addition & 0 deletions libs/locale/runtime/en-US.lua
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ https://discord.gg/%s]],
embedWarning = "⚠ Warning",
embedError = "❗ Error",
newline = "\n",
asIs = "%s",

inCategory = "in %s category",

Expand Down
2 changes: 1 addition & 1 deletion libs/storage/channels.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ setmetatable(channels, {
if parent then
self[channelID] = setmetatable({
id = channelID,
guildID = parent.guild and parent.guild.id or parent.id,
guildID = parent.guild and parent.guild.id or parent.guildID or parent.id,
parentType = tonumber(parentType),
host = host,
parent = parent,
Expand Down

0 comments on commit 7542319

Please sign in to comment.