Python 命令和特定日期运行命令的冷却

Python 命令和特定日期运行命令的冷却,python,python-3.x,discord,discord.py,discord.py-rewrite,Python,Python 3.x,Discord,Discord.py,Discord.py Rewrite,所以我为这个机器人写了代码,我想让它做两件事: 冷却15分钟 有一个只在星期五工作的命令 我不熟悉编码,所以discord文档没有帮助 我的导入内容: import discord, asyncio, time, discord.guild, random, os, youtube_dl import os import asyncio import math import random import youtube_dl import datetime import json from dis

所以我为这个机器人写了代码,我想让它做两件事:

  • 冷却15分钟
  • 有一个只在星期五工作的命令
  • 我不熟悉编码,所以discord文档没有帮助

    我的导入内容

    import discord, asyncio, time, discord.guild, random, os, youtube_dl
    import os
    import asyncio
    import math
    import random
    import youtube_dl
    import datetime
    import json
    from discord.ext import commands, tasks
    from discord.ext.commands import Bot, guild_only
    from itertools import cycle
    
    
    @client.command()
    async def beg(ctx):
        await open_account(ctx.author)
    
        users = await get_bank_data()
        
        user = ctx.author
    
        earn = random.randrange(6900)
    
        await ctx.send(f'Someone gave you {earn} coins!')
    
    
        users[str(user.id)]["wallet"] += earn
    
        with open('main code\economy.json', 'w') as f:
                json.dump(users,f)
    
    
    @client.command()
    async def friday(ctx):
        vid = '<URL>'
        
        await ctx.send(vid)
    
    15分钟冷却代码

    import discord, asyncio, time, discord.guild, random, os, youtube_dl
    import os
    import asyncio
    import math
    import random
    import youtube_dl
    import datetime
    import json
    from discord.ext import commands, tasks
    from discord.ext.commands import Bot, guild_only
    from itertools import cycle
    
    
    @client.command()
    async def beg(ctx):
        await open_account(ctx.author)
    
        users = await get_bank_data()
        
        user = ctx.author
    
        earn = random.randrange(6900)
    
        await ctx.send(f'Someone gave you {earn} coins!')
    
    
        users[str(user.id)]["wallet"] += earn
    
        with open('main code\economy.json', 'w') as f:
                json.dump(users,f)
    
    
    @client.command()
    async def friday(ctx):
        vid = '<URL>'
        
        await ctx.send(vid)
    
    仅在星期五工作的命令代码

    import discord, asyncio, time, discord.guild, random, os, youtube_dl
    import os
    import asyncio
    import math
    import random
    import youtube_dl
    import datetime
    import json
    from discord.ext import commands, tasks
    from discord.ext.commands import Bot, guild_only
    from itertools import cycle
    
    
    @client.command()
    async def beg(ctx):
        await open_account(ctx.author)
    
        users = await get_bank_data()
        
        user = ctx.author
    
        earn = random.randrange(6900)
    
        await ctx.send(f'Someone gave you {earn} coins!')
    
    
        users[str(user.id)]["wallet"] += earn
    
        with open('main code\economy.json', 'w') as f:
                json.dump(users,f)
    
    
    @client.command()
    async def friday(ctx):
        vid = '<URL>'
        
        await ctx.send(vid)
    
    
    @client.command()
    异步def星期五(ctx):
    vid=“”
    等待ctx发送(视频)
    
    15分钟冷却时间 使用

    @client.command()
    @命令。冷却时间(1900,命令。BucketType。用户)#15分钟是900秒
    异步def命令带冷却(ctx):
    ...  # 代码
    @命令\u与\u cooldown.error
    异步def冷却错误处理程序(ctx,错误):
    如果isinstance(错误,commands.CommandOnColdDown):
    等待ctx.send(“您只能每15分钟使用此命令一次!”)
    
    只有星期五 使用

    导入日期时间
    @client.command()
    异步def周五_命令(ctx):
    如果datetime.datetime.today().weekday()=4:#0是星期一,6是星期天
    ...  # 代码
    其他:
    等待ctx.send(“您只能在星期五使用此命令!”)