Skip to content

Stark.admins

Note

This is in beta and not tested completely yet. Next version will be stable.

Python decorator of class Stark to allow only admins to you some commands.

This decorator is used to allow only admins to use a particular command.

Parameters:

Name Type Description Default
alias str

Permission to check for the user. Can be edit/can_be_edited or manage/can_manage_chat or delete/can_delete_messages or restrict/can_restrict_members or promote/can_promote_members or change/can_change_info invite/can_invite_users or pin/can_pin_messages or vc/can_manage_voice_chats

''

Examples:

from pystark import Stark


# Bot will only execute function, if user who sent `/del` command has admin right `can_delete_messages`.
@Stark.admins('delete')  # or @Stark.admins('can_delete_messages')
@Stark.cmd("del")
async def delete_message(bot, msg):
    await msg.reply_to_message.delete()


# Bot will only execute function, if user who sent `/kick` command has admin right `can_restrict_members`.
@Stark.admins('restrict')  # or @Stark.admins('can_restrict_members')
@Stark.cmd("kick")
async def kick_user(bot, msg):
    ...


# Bot will only execute function, if user who sent `/play` command has admin right `can_manage_voice_chats`.
@Stark.admins('vc')  # or @Stark.admins('can_manage_voice_chats')
@Stark.cmd("play")
async def play_song(bot, msg):
    ...
Back to top