简体   繁体   中英

(discord.py) How do I make it so that the bot automatically changes a specific user's nickname at a fixed time everyday?

The nickname has a number that increases by 1 everyday. I'm familiar with creating a command to change a user's nickname that I have to type out to work, but I have no idea how to make the bot automatically do it everyday without me having to type out the command. I experimented with making the bot type out the command but I'm having trouble figuring out the increasing number.

Use the command at the time you want and it will repeat it every 12 hours.

import discord
from discord.ext import commands,tasks

client=commands.Bot(command_prefix="!")

@tasks.loop(hours=12)
async def chnick(ctx, member: discord.Member, nick):
    await member.edit(nick=nick)
    
@client.command
async def start_nick_change(ctx,member:discord.Member,nick):
  chnick.start(ctx,member,nick)

client.run(your_token)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM