当前位置: 首页>>代码示例>>Python>>正文


Python commands.cooldown方法代码示例

本文整理汇总了Python中discord.ext.commands.cooldown方法的典型用法代码示例。如果您正苦于以下问题:Python commands.cooldown方法的具体用法?Python commands.cooldown怎么用?Python commands.cooldown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在discord.ext.commands的用法示例。


在下文中一共展示了commands.cooldown方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: profile

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import cooldown [as 别名]
def profile(self,ctx, *, user : discord.Member=None):
        """Displays a user profile."""
        if user == None:
            user = ctx.message.author
        channel = ctx.message.channel
        server = user.server
        curr_time = time.time()

        # creates user if doesn't exist
        await self._create_user(user, server)
        userinfo = db.users.find_one({'user_id':user.id})

        # check if disabled
        if server.id in self.settings["disabled_servers"]:
            await self.bot.say("**Leveler commands for this server are disabled!**")
            return

        # no cooldown for text only
        if "text_only" in self.settings and server.id in self.settings["text_only"]:
            em = await self.profile_text(user, server, userinfo)
            await self.bot.send_message(channel, '', embed = em)
        else:
            await self.draw_profile(user, server)
            await self.bot.send_typing(channel)
            await self.bot.send_file(channel, 'data/leveler/temp/{}_profile.png'.format(user.id), content='**User profile for {}**'.format(self._is_mention(user)))
            db.users.update_one({'user_id':user.id}, {'$set':{
                    "profile_block": curr_time,
                }}, upsert = True)
            try:
                os.remove('data/leveler/temp/{}_profile.png'.format(user.id))
            except:
                pass 
开发者ID:AznStevy,项目名称:Maybe-Useful-Cogs,代码行数:34,代码来源:leveler.py

示例2: rank

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import cooldown [as 别名]
def rank(self,ctx,user : discord.Member=None):
        """Displays the rank of a user."""
        if user == None:
            user = ctx.message.author
        channel = ctx.message.channel
        server = user.server
        curr_time = time.time()

        # creates user if doesn't exist
        await self._create_user(user, server)
        userinfo = db.users.find_one({'user_id':user.id})

        # check if disabled
        if server.id in self.settings["disabled_servers"]:
            await self.bot.say("**Leveler commands for this server are disabled!**")
            return

        # no cooldown for text only
        if "text_only" in self.settings and server.id in self.settings["text_only"]:
            em = await self.rank_text(user, server, userinfo)
            await self.bot.send_message(channel, '', embed = em)
        else:
            await self.draw_rank(user, server)
            await self.bot.send_typing(channel)
            await self.bot.send_file(channel, 'data/leveler/temp/{}_rank.png'.format(user.id), content='**Ranking & Statistics for {}**'.format(self._is_mention(user)))
            db.users.update_one({'user_id':user.id}, {'$set':{
                    "rank_block".format(server.id): curr_time,
                }}, upsert = True)
            try:
                os.remove('data/leveler/temp/{}_rank.png'.format(user.id))
            except:
                pass 
开发者ID:AznStevy,项目名称:Maybe-Useful-Cogs,代码行数:34,代码来源:leveler.py

示例3: _is_mention

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import cooldown [as 别名]
def _is_mention(self,user):
        if "mention" not in self.settings.keys() or self.settings["mention"]:
            return user.mention
        else:
            return user.name

    # @commands.cooldown(1, 10, commands.BucketType.user) 
开发者ID:AznStevy,项目名称:Maybe-Useful-Cogs,代码行数:9,代码来源:leveler.py

示例4: __init__

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import cooldown [as 别名]
def __init__(self):
		super().__init__(command_attrs={
			'cooldown': commands.Cooldown(1, 3.0, commands.BucketType.member),
			'help': _('Shows help about the bot, a command, or a category')
		}) 
开发者ID:EmoteBot,项目名称:EmoteCollector,代码行数:7,代码来源:meta.py

示例5: ping

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import cooldown [as 别名]
def ping(self, ctx):
        '''Misst die Response Time'''
        ping = ctx.message
        pong = await ctx.send('**:ping_pong:** Pong!')
        delta = pong.created_at - ping.created_at
        delta = int(delta.total_seconds() * 1000)
        await pong.edit(content=f':ping_pong: Pong! ({delta} ms)\n*Discord WebSocket Latenz: {round(self.bot.latency, 5)} ms*')

    # @commands.command()
    # @commands.cooldown(1, 2, commands.cooldowns.BucketType.guild)
    # async def github(self, ctx):
    #     '''In progress'''
    #     url = 'https://api.github.com/repos/Der-Eddy/discord_bot/stats/commit_activity'
    #     async with aiohttp.get(url) as r:
    #         if r.status == 200:
    #             content = await r.json()
    #             commitCount = 0
    #             for week in content:
    #                 commitCount += week['total']
    #
    #             embed = discord.Embed(title='GitHub Repo Stats', type='rich', color=0xf1c40f) #Golden
    #             embed.set_thumbnail(url='https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png')
    #             embed.add_field(name='Commits', value=commitCount, inline=True)
    #             embed.add_field(name='Link', value='https://github.com/Der-Eddy/discord_bot')
    #             await ctx.send(embed=embed)
    #         else:
    #             await ctx.send(':x: Konnte nicht aufs GitHub API zugreifen\nhttps://github.com/Der-Eddy/discord_bot') 
开发者ID:Der-Eddy,项目名称:discord_bot,代码行数:29,代码来源:utility.py


注:本文中的discord.ext.commands.cooldown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。