class DiscordMiddleware::Permissions
- DiscordMiddleware::Permissions
- Reference
- Object
Overview
This middleware evaluates the permissions of the calling message author.
If the message is from a guild, the guilds roles and the current channels
permissions will be taken into account according to the members roles.
Otherwise, DM_PERMISSIONS
will be considered.
If the client has a cache enabled, it will be used to fetch the guild and channel.
It can be initialized with a string that will be used as a canned response. The text "%permissions%" will be replaced with the required permissions if provided.
# Require that a user has permission to kick members to trigger this
# handler
perms = Discord::Permissions::KickMembers
client.on_message_create(
DiscordMiddleware::Prefix.new("!kick"),
DiscordMiddleware::Permissions.new(perms, "Permission Denied. Must have %permissions%")) do |payload, context|
# Kick 'em
end
Included Modules
Defined in:
discordcr-middleware/middleware/permissions.crConstant Summary
-
DM_PERMISSIONS =
Discord::Permissions.flags(ManageChannels, AddReactions, ReadMessages, SendMessages, SendTTSMessages, EmbedLinks, AttachFiles, ReadMessageHistory, MentionEveryone, UseExternalEmojis, Connect, Speak, UseVAD)
-
The permissions a user has in a direct message
Constructors
Instance Method Summary
-
#base_permissions_for(member, in guild)
Returns the member's base permissions on the guild :nodoc:
- #call(payload : Discord::Message, context : Discord::Context, &block)
-
#overwrites_for(member, in channel, with base_permissions)
Returns the applicable overwrite permissions :nodoc:
Constructor Detail
Instance Method Detail
Returns the member's base permissions on the guild :nodoc:
Returns the applicable overwrite permissions :nodoc: