Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn Module update + started documentation + added guild aware permission checking #29

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

GiregL
Copy link
Contributor

@GiregL GiregL commented Jan 23, 2021

Warn module:

  • added !popwarn command
  • added warn and unwarn roles (for permission checking)
  • added log channel in configuration
  • added logs for each action (excluding warnlist)

Documentation:

  • created summary
  • created Warn Module doc
  • API documentation will come later

Bot modification:

  • Added new field to modules: GuildAwarePrivilegeCheck
  • Made PrivilegeCheck and GuildAwarePrivilegeCheck complementary, both of them should pass to check privileges
  • GuildAwarePrivilegeCheck takes the guild and the member as parameters, enabling configuration dependent privilege checking

doc/index.md Outdated

- [Ban]() : Ban management module
- [Channel]() : Channel management module
- [Game]() :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Game is the global module handling bot status

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will recreate this PR, I made some mistakes.
(I will also update the Game description in the doc)

@@ -82,6 +142,18 @@ function Module:GetConfigTable()
Type = bot.ConfigType.Boolean,
Default = true
},
{
Name = "MinimalWarnRole",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why "minimal"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Higher roles have the permission to warn, same for unwarn and MinimalUnwarnRole

module_warn.lua Show resolved Hide resolved
module_warn.lua Outdated

function Module:GetWarnAmount(history, memberId)
local member = FindMember(history, memberId)
return table.length(member.Warns)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#member.Warns

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

module_warn.lua Outdated
if not memberHistory then
commandMessage:reply(string.format("The member **%s** (%d) already have zero warns.", targetMember.tag, targetMember.id))
else
local lastWarn = table.remove(memberHistory.Warns, #memberHistory.Warns)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for the second table.remove parameter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

module_warn.lua Outdated
timestamp
))
if not success then
self:LogInfo(errMessage)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LogError

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -124,7 +124,8 @@ client:on('messageCreate', function(message)

if (commandTable.PrivilegeCheck) then
local success, ret = Bot:ProtectedCall("Command " .. commandName .. " privilege check", commandTable.PrivilegeCheck, message.member)
if (not success) then

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed GuildAwarePrivilegeCheck

@@ -0,0 +1,39 @@
# Not a Bot - Discord Bot
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be part of this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants