mirror of
https://github.com/RGBCube/minearchy-bot
synced 2025-07-27 08:57:46 +00:00
Add check for permissions and make it case insensitive
This commit is contained in:
parent
f04df06a45
commit
8b7be6b886
1 changed files with 9 additions and 3 deletions
|
@ -69,17 +69,23 @@ class Miscellaneous(
|
||||||
async def on_message(self, message: Message) -> None:
|
async def on_message(self, message: Message) -> None:
|
||||||
name = message.author.display_name
|
name = message.author.display_name
|
||||||
|
|
||||||
if not name.startswith("[AFK]"):
|
if not name.lower().startswith("[AFK]"):
|
||||||
return
|
return
|
||||||
|
|
||||||
await message.author.edit(nick=name.removeprefix("[AFK]"))
|
await message.author.edit(nick=name[5:])
|
||||||
await message.channel.send(f"Welcome back {escape_markdown(message.author.mention)}! I've unset your AFK status.")
|
await message.channel.send(
|
||||||
|
f"Welcome back {escape_markdown(message.author.mention)}! I've unset your AFK status.")
|
||||||
|
|
||||||
@command(
|
@command(
|
||||||
brief="Sets you as AFK.",
|
brief="Sets you as AFK.",
|
||||||
help="Sets you as AFK.",
|
help="Sets you as AFK.",
|
||||||
)
|
)
|
||||||
async def afk(self, ctx: Context) -> None:
|
async def afk(self, ctx: Context) -> None:
|
||||||
|
if ctx.me.top_role.position <= ctx.author.top_role.position:
|
||||||
|
await ctx.reply(
|
||||||
|
"I cannot set you as AFK because my role is lower than yours. You can edit your nickname to set yourself as AFK (Add [AFK] to the start of it.).")
|
||||||
|
return
|
||||||
|
|
||||||
await ctx.author.edit(nick=f"[AFK] {ctx.author.display_name}")
|
await ctx.author.edit(nick=f"[AFK] {ctx.author.display_name}")
|
||||||
await ctx.reply("Set your status to AFK. You can now touch grass freely 🌲.")
|
await ctx.reply("Set your status to AFK. You can now touch grass freely 🌲.")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue