0

I'm trying to code a Discord bot in lua at the moment and I've having some difficulties. I'm trying to create a bulk delete command for my bot, but it seems to not work and only returns "400 - Bad Request" upon typing the command. Am I doing something wrong? I've tried doing message.channel:bulkDelete(3) and it still doesn't work. (I am pretty new to coding Discord bots in lua.)

Code:

local discordia = require('discordia')
local client = discordia.Client()

local prefix = "+"
local adminid = 645671868728082432

client:on("ready", function() -- bot is ready
    print("Logged in")
end)

client:on("messageCreate", function(message)
    local content = message.content
    local member = message.member
    local author = message.author
    local memberid = member.id
    local args = content:split(" ")

    if args[1] == prefix.. "delete" then
        if not member:hasRole(adminid) then
            message:reply("<@" ..author.id.. ">**, you do not have permission to use this command.**")
            return
        end
        message.guild:getChannel(message.channel.id):bulkDelete(3)
    end
end)
Hazurii
  • 3
  • 1

1 Answers1

0

Because this method requires a table of MessageID-resolvable objects like Message object itself or its ID as string.

Read documentation here: https://github.com/SinisterRectus/Discordia/wiki/GuildTextChannel#bulkdeletemessages

Spar
  • 1,582
  • 9
  • 16
  • No it doesn't. You can just put in a number -- https://discord.js.org/#/docs/main/stable/class/TextChannel?scrollTo=bulkDelete – Doyousketch2 Nov 23 '20 at 17:23
  • 1
    the OP has `local discordia = require('discordia')` in the code. the link in this answer would indicate how `bulkDelete` is implemented in `discordia` which can differ from the `discord.js` implementation. – Nifim Nov 23 '20 at 18:52
  • 1
    @Doyousketch2 Yes it does. You can't just put in a number -- https://github.com/SinisterRectus/Discordia/blob/master/libs/containers/GuildTextChannel.lua#L71 – Spar Nov 23 '20 at 20:01
  • OK well, I didn't see that guild part. I had looked at https://github.com/SinisterRectus/Discordia/blob/master/libs/client/API.lua#L314 before posting that comment, and it didn't specify any distinction. – Doyousketch2 Nov 23 '20 at 20:23