SinisterRectus / Discordia

Discord API library written in Lua for the Luvit runtime environment
MIT License
697 stars 143 forks source link

when i run my code this prints in console #342

Closed papaj2139 closed 2 years ago

papaj2139 commented 2 years ago

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

client:on('ready', function() print('Logged in as '.. client.user.username) end)

client:on('messageCreate', function(message) if message.author.bot then return end if message.content == '$ping' then message.channel:send('Pong!') end if message.content:sub(1, 4) == '$ban' then local author = message.guild:getMember(message.author.id) local member = message.mentionedUsers.first

    if not member then
      -- The user have not mentioned any member to be banned
      message:reply("Please mention a member to ban!")
      return
    elseif not author:hasPermission("banMembers") then
      -- The user does not have enough permissions
      message:reply("You do not have `banMembers` permissions!")
      return
    end

    for user in message.mentionedUsers:iter() do
      -- Check if mention isn't a reply
      if string.find(message.content, "<@[!]?" .. user.id .. ">") then
        member = message.guild:getMember(user.id)
        if author.highestRole.position > member.highestRole.position then
          member:ban()
        end
    end

end

client:run('My token')

error:lua: c:\Users\ojk\Desktop\discord\bots\minemaker\main.lua:37: 'end' expected (to close 'if' at line 13) near ''

GitSparTV commented 2 years ago

https://discord.gg/sinisterware

BrendtPark commented 2 years ago
    if not member then
      -- The user have not mentioned any member to be banned
      message:reply("Please mention a member to ban!")
      return
    elseif not author:hasPermission("banMembers") then
      -- The user does not have enough permissions
      message:reply("You do not have `banMembers` permissions!")
      return
    end

    for user in message.mentionedUsers:iter() do
      -- Check if mention isn't a reply
      if string.find(message.content, "<@[!]?" .. user.id .. ">") then
        member = message.guild:getMember(user.id)
        if author.highestRole.position > member.highestRole.position then
          member:ban()
        end
      end
     end
 You just forgot an end :) lmk if that fixed it!