Python discord.ext.commands.cooldown() Examples
The following are 5
code examples of discord.ext.commands.cooldown().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
discord.ext.commands
, or try the search function
.
Example #1
Source File: utility.py From discord_bot with MIT License | 6 votes |
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')
Example #2
Source File: leveler.py From Maybe-Useful-Cogs with MIT License | 5 votes |
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
Example #3
Source File: leveler.py From Maybe-Useful-Cogs with MIT License | 5 votes |
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
Example #4
Source File: leveler.py From Maybe-Useful-Cogs with MIT License | 5 votes |
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)
Example #5
Source File: meta.py From EmoteCollector with GNU Affero General Public License v3.0 | 5 votes |
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') })