简体   繁体   中英

How to make a command to change channel cooldown discord.py

I just wanted to ask how can i make a command, that will change channel sending messages cooldown. That's all.

You can use slowmode_delay .

No cogs:

@client.command()
@commands.has_permissions(manage_messages=True) # Permission to use command
async def slowmode(self, ctx, seconds: int): # seconds
     await ctx.channel.edit(slowmode_delay=seconds) # Edits the channel, (slowmode_delay = channel slowmode.
     await ctx.send(f"I've set the slowmode to **{seconds}** seconds in {ctx.channel.mention}!") # Message sent after the slowmode is set.

Cogs:

@commands.command()
    @commands.has_permissions(manage_messages=True)
    async def slowmode(self, ctx, seconds: int):
     await ctx.channel.edit(slowmode_delay=seconds)
     await ctx.send(f"I've set the slowmode to **{seconds}** seconds in {ctx.channel.mention}!")

Command Example

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