Skip to content

Commit db4e21f

Browse files
committed
Version 1.2
1 parent 7ba1383 commit db4e21f

File tree

3 files changed

+66
-27
lines changed

3 files changed

+66
-27
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Python-Discord-Bot-Template
22
This repository is a template that everyone can use for the start of their discord bot.
33

4+
The list of update are available [here](UPDATES.md).
5+
46
## Bots who used this template
57

68
*DM Krypton#2188 to get yourself in this list*

UPDATES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Updates List
2+
Here is the list of all the updates that I made on this template.
3+
4+
### Version 1.2
5+
* Added blacklist command
6+
* Removed commands cooldown

bot.py

Lines changed: 58 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Copyright © Krypton 2019 - https://github.com/kkrypt0nn
33
Description:
44
This is a template to create your own discord bot in python.
5+
6+
Version: 1.2
57
"""
68

79
import discord
@@ -10,7 +12,6 @@
1012
import json
1113
from discord.ext.commands import Bot
1214
from random import randint
13-
from discord.ext.commands.cooldowns import BucketType
1415
from discord.ext import commands
1516
from platform import python_version
1617
import os
@@ -43,7 +44,6 @@ async def on_ready():
4344
print('-------------------')
4445

4546
@client.command(name='info', pass_context=True)
46-
@commands.cooldown(1, 5, BucketType.user)
4747
async def info(context):
4848
if context.message.author.id in BLACKLIST:
4949
embed = discord.Embed(title='You\'re blacklisted!', description='Ask the owner to remove from the list if it was unfair.', color=0x00FF00)
@@ -58,7 +58,6 @@ async def info(context):
5858
await context.message.channel.send(embed=e)
5959

6060
@client.command(name='serverinfo', pass_context=True)
61-
@commands.cooldown(1, 10, BucketType.user)
6261
async def serverinfo(context):
6362
if context.message.author.id in BLACKLIST:
6463
embed = discord.Embed(title='You\'re blacklisted!', description='Ask the owner to remove from the list if it was unfair.', color=0x00FF00)
@@ -85,9 +84,7 @@ async def serverinfo(context):
8584
embed.set_footer(text='Created at: %s' % time)
8685
await context.message.channel.send(embed=embed)
8786

88-
8987
@client.command(name='ping', pass_context=True)
90-
@commands.cooldown(1, 10, BucketType.user)
9188
async def ping(context):
9289
if context.message.author.id in BLACKLIST:
9390
embed = discord.Embed(title='You\'re blacklisted!', description='Ask the owner to remove from the list if it was unfair.', color=0x00FF00)
@@ -99,7 +96,6 @@ async def ping(context):
9996
await context.message.channel.send(embed=embed)
10097

10198
@client.command(name='invite', pass_context=True)
102-
@commands.cooldown(1, 5, BucketType.user)
10399
async def invite(context):
104100
if context.message.author.id in BLACKLIST:
105101
embed = discord.Embed(title='You\'re blacklisted!', description='Ask the owner to remove from the list if it was unfair.', color=0x00FF00)
@@ -110,7 +106,6 @@ async def invite(context):
110106

111107

112108
@client.command(name='server', pass_context=True)
113-
@commands.cooldown(1, 5, BucketType.user)
114109
async def server(context):
115110
if context.message.author.id in BLACKLIST:
116111
embed = discord.Embed(title='You\'re blacklisted!', description='Ask the owner to remove from the list if it was unfair.', color=0x00FF00)
@@ -120,7 +115,6 @@ async def server(context):
120115
await context.message.channel.send('Join my discord server by clicking here: https://discord.gg/Vddcy76')
121116

122117
@client.command(name='poll', pass_context=True)
123-
@commands.cooldown(1, 5, BucketType.user)
124118
async def poll(context, *args):
125119
mesg = ' '.join(args)
126120
if context.message.author.id in BLACKLIST:
@@ -136,7 +130,6 @@ async def poll(context, *args):
136130
await embed_message.add_reaction('🤷')
137131

138132
@client.command(name='8ball', pass_context=True)
139-
@commands.cooldown(1, 5, BucketType.user)
140133
async def eight_ball(context, *args):
141134
if context.message.author.id in BLACKLIST:
142135
embed = discord.Embed(title='You\'re blacklisted!',
@@ -153,7 +146,6 @@ async def eight_ball(context, *args):
153146
await context.message.channel.send(embed=embed)
154147

155148
@client.command(pass_context=True)
156-
@commands.cooldown(1, 5, BucketType.user)
157149
async def bitcoin(context):
158150
url = 'https://api.coindesk.com/v1/bpi/currentprice/BTC.json'
159151
async with aiohttp.ClientSession() as session: # Async HTTP request
@@ -166,7 +158,6 @@ async def bitcoin(context):
166158

167159

168160
@client.command(name='shutdown', pass_context=True)
169-
@commands.cooldown(1, 10, BucketType.user)
170161
async def shutdown(context):
171162
if context.message.author.id in BLACKLIST:
172163
embed = discord.Embed(title='You\'re blacklisted!',
@@ -215,7 +206,6 @@ async def embed(context, *args):
215206

216207

217208
@client.command(name='kick', pass_context=True)
218-
@commands.cooldown(1, 5, BucketType.user)
219209
async def kick(context, member: discord.Member, *args):
220210
if context.message.author.id in BLACKLIST:
221211
embed = discord.Embed(title='You\'re blacklisted!',
@@ -242,7 +232,6 @@ async def kick(context, member: discord.Member, *args):
242232
await context.message.channel.send(embed=embed)
243233

244234
@client.command(name='nick', pass_context=True)
245-
@commands.cooldown(1, 5, BucketType.user)
246235
async def nick(context, member: discord.Member, *, name : str):
247236
if context.message.author.id in BLACKLIST:
248237
embed = discord.Embed(title='You\'re blacklisted!', description='Ask the owner to remove from the list if it was unfair.', color=0x00FF00)
@@ -260,7 +249,6 @@ async def nick(context, member: discord.Member, *, name : str):
260249
await context.message.channel.send(embed=embed)
261250

262251
@client.command(name='ban', pass_context=True)
263-
@commands.cooldown(1, 5, BucketType.user)
264252
async def ban(context, member: discord.Member, *args):
265253
if context.message.author.id in BLACKLIST:
266254
embed = discord.Embed(title='You\'re blacklisted!',
@@ -289,7 +277,6 @@ async def ban(context, member: discord.Member, *args):
289277

290278

291279
@client.command(name='unban', pass_context=True)
292-
@commands.cooldown(1, 3, BucketType.user)
293280
async def unban(context, user: discord.Member):
294281
if context.message.author.id in BLACKLIST:
295282
embed = discord.Embed(title='You\'re blacklisted!',
@@ -311,7 +298,6 @@ async def unban(context, user: discord.Member):
311298

312299

313300
@client.command(name='warn', pass_context=True)
314-
@commands.cooldown(1, 5, BucketType.user)
315301
async def warn(context, member: discord.Member, *args):
316302
if context.message.author.id in BLACKLIST:
317303
embed = discord.Embed(title='You\'re blacklisted!',
@@ -335,7 +321,6 @@ async def warn(context, member: discord.Member, *args):
335321

336322

337323
@client.command(name='purge', pass_context=True)
338-
@commands.cooldown(1, 5, BucketType.user)
339324
async def purge(context, number):
340325
if context.message.author.id in BLACKLIST:
341326
embed = discord.Embed(title='You\'re blacklisted!',
@@ -356,16 +341,57 @@ async def purge(context, number):
356341
color=0x00FF00)
357342
await context.message.channel.send(embed=embed)
358343

344+
@client.command(name='blacklist', pass_context=True)
345+
async def blacklist(context, mode : str, user : discord.User = None):
346+
if context.message.author.id in BLACKLIST:
347+
embed = discord.Embed(title='You\'re blacklisted!',
348+
description='Ask the owner to remove from the list if it was unfair.', color=0x00FF00)
349+
await context.message.channel.send(embed=embed)
350+
else:
351+
if context.message.author.id in OWNERS:
352+
if (mode.lower() == "add"):
353+
userID = user.id
354+
try:
355+
BLACKLIST.append(userID)
356+
embed = discord.Embed(title="User Blacklisted", description='**{0}** has been successfully added to the blacklist'.format(user.name), color=0x00FF00)
357+
embed.set_footer(text='There are now {0} users in the blacklist'.format(len(BLACKLIST)))
358+
await context.message.channel.send(embed=embed)
359+
except:
360+
embed = discord.Embed(title=":x: Error!", description="An unknown error occurred when trying to add **{0}** to the blacklist.".format(user.name), color=0xFF0000)
361+
await context.message.channel.send(embed=embed)
362+
elif (mode.lower() == "remove"):
363+
userID = user.id
364+
try:
365+
BLACKLIST.remove(userID)
366+
embed = discord.Embed(title="User Unblacklisted",
367+
description='**{0}** has been successfully removed from the blacklist'.format(
368+
user.name), color=0x00FF00)
369+
embed.set_footer(text='There are now {0} users in the blacklist'.format(len(BLACKLIST)))
370+
await context.message.channel.send(embed=embed)
371+
except:
372+
embed = discord.Embed(title=":x: Error!",
373+
description="An unknown error occurred when trying to remove **{0}** from the blacklist.\nAre you sure the user is in the blacklist?".format(
374+
user.name), color=0xFF0000)
375+
await context.message.channel.send(embed=embed)
376+
elif (mode.lower() == "list"):
377+
embed = discord.Embed(title="There are currently {0} blacklisted IDs".format(len(BLACKLIST)),
378+
description="{0}".format(BLACKLIST),
379+
color=0x00FF00)
380+
await context.message.channel.send(embed=embed)
381+
else:
382+
embed = discord.Embed(title='Error!', description='You don\'t have the permission to use this command.',
383+
color=0xFF0000)
384+
await context.message.channel.send(embed=embed)
359385

360386
client.remove_command('help')
361387

362388
@client.command(name='help', description='Help HUD.', brief='HELPOOOO!!!', pass_context=True)
363-
@commands.cooldown(1, 5, BucketType.user)
364389
async def help(context):
365390
if context.message.author.id in BLACKLIST:
366391
embed = discord.Embed(title='You\'re blacklisted!', description='Ask the owner to remove from the list if it was unfair.', color=0x00FF00)
367392
await context.message.channel.send(embed=embed)
368393
else:
394+
# Note that commands made only for the owner of the bot are not listed here.
369395
embed = discord.Embed(title='Bot', description='List of commands are:', color=0x00FF00)
370396
embed.add_field(name='Invite - Invite the bot', value='Usage: YOUR_PREFIX_HERE invite', inline=False)
371397
embed.add_field(name='Server - Join my own server', value='Usage: YOUR_PREFIX_HERE server', inline=False)
@@ -394,64 +420,69 @@ async def on_command_error(context, error):
394420
await message.delete()
395421
raise error
396422

423+
@blacklist.error
424+
async def blacklist_error(context, error):
425+
embed = discord.Embed(title='**Command:** YOUR_PREFIX_HERE blacklist', description='**Description::** Prevents a user from using the bot \n **Usage:** YOUR_PREFIX_HERE blacklist [add/remove/list] [user] \n **Example:** YOUR_PREFIX_HERE blacklist add @RandomUser', color=0x00FF00)
426+
await context.message.channel.send(embed=embed)
427+
397428
@ban.error
398429
async def ban_error(context, error):
399-
embed = discord.Embed(title='**Command:** YOUR_PREFIX_HERE ban', description='**Description:** Bans a member \n **Cooldown:** 5 second(s) \n **Usage:** YOUR_PREFIX_HERE ban [user] [reason] \n **Example:** YOUR_PREFIX_HERE ban @RandomUser Get out!', color=0x00FF00)
430+
embed = discord.Embed(title='**Command:** YOUR_PREFIX_HERE ban', description='**Description:** Bans a member \n **Usage:** YOUR_PREFIX_HERE ban [user] [reason] \n **Example:** YOUR_PREFIX_HERE ban @RandomUser Get out!', color=0x00FF00)
400431
await context.message.channel.send(embed=embed)
401432

402433
@poll.error
403434
async def poll_error(context, error):
404-
embed = discord.Embed(title='**Command:** YOUR_PREFIX_HERE poll', description='**Description:** Create a pool to vote \n **Cooldown:** 5 second(s) \n **Usage:** YOUR_PREFIX_HERE poll [idea] \n **Example:** YOUR_PREFIX_HERE poll Add new emojis!', color=0x00FF00)
435+
embed = discord.Embed(title='**Command:** YOUR_PREFIX_HERE poll', description='**Description:** Create a pool to vote \n **Usage:** YOUR_PREFIX_HERE poll [idea] \n **Example:** YOUR_PREFIX_HERE poll Add new emojis!', color=0x00FF00)
405436
await context.message.channel.send(embed=embed)
406437

407438
@eight_ball.error
408439
async def eight_ball_error(context, error):
409-
embed = discord.Embed(title='**Command:** YOUR_PREFIX_HERE 8ball', description='**Description:** Get an answer to all of your questions \n **Cooldown:** 5 second(s) \n **Usage:** YOUR_PREFIX_HERE 8ball [question] \n **Example:** YOUR_PREFIX_HERE 8ball Is this bot cool?', color=0x00FF00)
440+
embed = discord.Embed(title='**Command:** YOUR_PREFIX_HERE 8ball', description='**Description:** Get an answer to all of your questions \n **Usage:** YOUR_PREFIX_HERE 8ball [question] \n **Example:** YOUR_PREFIX_HERE 8ball Is this bot cool?', color=0x00FF00)
410441
await context.message.channel.send(embed=embed)
411442

412443
@echo.error
413444
async def say_error(context, error):
414445
embed = discord.Embed(title='**Command:** YOUR_PREFIX_HERE say',
415-
description='**Description:** I say what you say \n **Cooldown:** 0 second(s) \n **Usage:** YOUR_PREFIX_HERE say [message] \n **Example:** YOUR_PREFIX_HERE say Hello!!',
446+
description='**Description:** I say what you say \n **Usage:** YOUR_PREFIX_HERE say [message] \n **Example:** YOUR_PREFIX_HERE say Hello!!',
416447
color=0x00FF00)
417448
await context.message.channel.send(embed=embed)
418449

419450

420451
@embed.error
421452
async def embed_error(context, error):
422453
embed = discord.Embed(title='**Command:** YOUR_PREFIX_HERE embed',
423-
description='**Description:** I say what you say as embed message \n **Cooldown:** 0 second(s) \n **Usage:** YOUR_PREFIX_HERE embed [message] \n **Example:** YOUR_PREFIX_HERE embed Hello!!',
454+
description='**Description:** I say what you say as embed message \n **Usage:** YOUR_PREFIX_HERE embed [message] \n **Example:** YOUR_PREFIX_HERE embed Hello!!',
424455
color=0x00FF00)
425456
await context.message.channel.send(embed=embed)
426457

427458

428459
@kick.error
429460
async def kick_error(context, error):
430461
embed = discord.Embed(title='**Command:** YOUR_PREFIX_HERE kick',
431-
description='**Description:** Kicks a member \n **Cooldown:** 5 second(s) \n **Usage:** YOUR_PREFIX_HERE kick [user] [reason] \n **Example:** YOUR_PREFIX_HERE kick @RandomUser Rejoin when you\'ll be smarter, like me!',
462+
description='**Description:** Kicks a member \n **Usage:** YOUR_PREFIX_HERE kick [user] [reason] \n **Example:** YOUR_PREFIX_HERE kick @RandomUser Rejoin when you\'ll be smarter, like me!',
432463
color=0x00FF00)
433464
await context.message.channel.send(embed=embed)
434465

435466

436467
@unban.error
437468
async def unban_error(context, error):
438469
embed = discord.Embed(title='**Command:** YOUR_PREFIX_HERE unban',
439-
description='**Description:** Unbans a member \n **Cooldown:** 3 second(s) \n **Usage:** YOUR_PREFIX_HERE unban [user] \n **Example:** YOUR_PREFIX_HERE unban @RandomUser',
470+
description='**Description:** Unbans a member \n **Usage:** YOUR_PREFIX_HERE unban [user] \n **Example:** YOUR_PREFIX_HERE unban @RandomUser',
440471
color=0x00FF00)
441472
await context.message.channel.send(embed=embed)
442473

443474
@warn.error
444475
async def warn_error(context, error):
445476
embed = discord.Embed(title='**Command:** YOUR_PREFIX_HERE warn',
446-
description='**Description:** Warns a member \n **Cooldown:** 5 second(s) \n **Usage:** YOUR_PREFIX_HERE warn [user] [reason] \n **Example:** YOUR_PREFIX_HERE warn @RandomUser Stop the caps, thanks!',
477+
description='**Description:** Warns a member \n **Usage:** YOUR_PREFIX_HERE warn [user] [reason] \n **Example:** YOUR_PREFIX_HERE warn @RandomUser Stop the caps, thanks!',
447478
color=0x00FF00)
448479
await context.message.channel.send(embed=embed)
449480

450481

451482
@purge.error
452483
async def purge_error(context, error):
453484
embed = discord.Embed(title='**Command:** YOUR_PREFIX_HERE purge',
454-
description='**Description:** Delete a certain amount of messages \n **Cooldown:** 5 second(s) \n **Usage:** YOUR_PREFIX_HERE purge [numer of messages] \n **Example:** YOUR_PREFIX_HERE purge 20',
485+
description='**Description:** Delete a certain amount of messages \n **Usage:** YOUR_PREFIX_HERE purge [numer of messages] \n **Example:** YOUR_PREFIX_HERE purge 20',
455486
color=0x00FF00)
456487
await context.message.channel.send(embed=embed)
457488

0 commit comments

Comments
 (0)