#Making Variables Types Dependent On Roles

1 messages · Page 1 of 1 (latest)

frigid phoenixBOT
#

property roles```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.11)") of [`Role`](https://docs.disnake.dev/page/api.html#disnake.Role "disnake.Role") that the member belongs to. Note that the first element of this list is always the default [‘@everyone](mailto:'%40everyone)’ role.

These roles are sorted by their position in the role hierarchy.
vale rapids
#

you'll want to collect your args and check them, if it looks like its a moderator level command you check their permissions/roles and either deny them or execute as normal.

#

discord does not give us a convenient way to list what automod violations a member has incurred. So you're either gonna have to monitor the event and log it internally when it happens, or cross reference the audit log. A combination of the two most likely.
IE when you start up the bot you peruse the audit logs to see if the bot missed anything, adding whatever is new. then starts listening for automod events and logging it to your database.

#

poor wording then x) However, if you're capable of implementing your own robust automod than making a simple prefix command should be easy in comparison.

#

yes, you want 1 command. >warnings that all can use.
but if args is numerical you only want moderators to use it. thats like 1 if statement

#

you could use the new match() function to decide

#

lets you write sort of RE cases, and getting it to react on numbers only is simple enough.
otherwise you have this
https://www.w3schools.com/python/ref_string_isnumeric.asp

#

you basically need to getch it from disnake, if its a user you get something usable returned, otherwise its None

#

but you want a Member, not a User in this case, so you need to refference the guild's members

#

Member is the guild specific version of a User.

#

Have you considered slash commands instead? x)

vale rapids
#
def warnings(ctx, *args):
    match(args):
        case []:
            #Normal warnings
            print("Normal Warning")
            return
        case ['--a']:
            #Automod warnings
            print("Automod Warning")
            return
    if args[0].isnumeric():
        print("Some number: ",int(args[0]))

warnings(1,"--a")
warnings(None)
warnings(None,"1234")
Automod Warning
Normal Warning
Some number:  1234
#

Don't really remember the syntax for prefix commands as they're more or less dying. so just made it a normal function.

#

Couldn't find a way to match if a string was numeric

#

might be possible, no idea

vale rapids
#

Short answer is ofc yes x) But you're gonna have to do some fancy searching on the text. Why do you want to know?

#

custom emojis you're probably going to need to use RE

#

Regular Expressions yea, or Regex for short

#

something something find all pairs of : : containing some characters inbetween

#

yes

#

+source #1081676706449997874 message

knotty flareBOT
#

deny_mark Unknown message

#

deny_mark Unknown message

vale rapids
#

+help

knotty flareBOT
#

Missing required argument: command
Usage: +help <command>

vale rapids
#

+help source

knotty flareBOT
vale rapids
#

+source 1081708933133107260

knotty flareBOT
#

deny_mark Unknown message

vale rapids
#

Wai

knotty flareBOT
#

deny_mark Unknown message

#

Too many arguments, expected 1
Usage: +source <message>

vale rapids
#
{
  "id": "1081709605467467816",
  "content": "![kek](https://cdn.discordapp.com/emojis/893598745910980628.webp?size=128 "kek") ![catsip](https://cdn.discordapp.com/emojis/936257393141112862.webp?size=128 "catsip") :no_data:",
  "attachments": [],
  "embeds": [],
  "stickers": [],
  "components": []
}
#

there we go

#

so you're sort of screwed.

#

the first two emojis are in this server so you get the !catsip notation, but !no_data is not from this server

#

so you're gonna have to check for both. and theres no way to make it abuse proof

#

but any abuse would just lead to warnings so who cares