Skip to content

Commit 23e4b6a

Browse files
committed
🏷️ Template v5.4
1 parent 28a552c commit 23e4b6a

File tree

10 files changed

+30
-15
lines changed

10 files changed

+30
-15
lines changed

UPDATES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
Here is the list of all the updates that I made on this template.
44

5+
### Version 5.4 (8 December 2022)
6+
7+
* Added `@commands.bot_has_permissions()` checks and handle the exception for it
8+
* Fixed `purge` command
9+
* Removed `asyncio` from the requirements file
10+
511
### Version 5.3 (17 October 2022)
612

713
* Using `aiosqlite` instead of `sqlite3` for asynchronous database operations.

bot.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Description:
44
This is a template to create your own discord bot in python.
55
6-
Version: 5.3
6+
Version: 5.4
77
"""
88

99
import asyncio
@@ -190,6 +190,14 @@ async def on_command_error(context: Context, error) -> None:
190190
color=0xE02B2B
191191
)
192192
await context.send(embed=embed)
193+
elif isinstance(error, commands.BotMissingPermissions):
194+
embed = discord.Embed(
195+
title="Error!",
196+
description="I am missing the permission(s) `" + ", ".join(
197+
error.missing_permissions) + "` to fully perform this command!",
198+
color=0xE02B2B
199+
)
200+
await context.send(embed=embed)
193201
elif isinstance(error, commands.MissingRequiredArgument):
194202
embed = discord.Embed(
195203
title="Error!",

cogs/fun.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Description:
44
This is a template to create your own discord bot in python.
55
6-
Version: 5.3
6+
Version: 5.4
77
"""
88

99
import random

cogs/general.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Description:
44
This is a template to create your own discord bot in python.
55
6-
Version: 5.3
6+
Version: 5.4
77
"""
88

99
import platform

cogs/moderation.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Description:
44
This is a template to create your own discord bot in python.
55
6-
Version: 5.3
6+
Version: 5.4
77
"""
88

99
import discord
@@ -23,6 +23,7 @@ def __init__(self, bot):
2323
description="Kick a user out of the server.",
2424
)
2525
@commands.has_permissions(kick_members=True)
26+
@commands.bot_has_permissions(kick_members=True)
2627
@checks.not_blacklisted()
2728
@app_commands.describe(user="The user that should be kicked.", reason="The reason why the user should be kicked.")
2829
async def kick(self, context: Context, user: discord.User, *, reason: str = "Not specified") -> None:
@@ -74,6 +75,7 @@ async def kick(self, context: Context, user: discord.User, *, reason: str = "Not
7475
description="Change the nickname of a user on a server.",
7576
)
7677
@commands.has_permissions(manage_nicknames=True)
78+
@commands.bot_has_permissions(manage_nicknames=True)
7779
@checks.not_blacklisted()
7880
@app_commands.describe(user="The user that should have a new nickname.", nickname="The new nickname that should be set.")
7981
async def nick(self, context: Context, user: discord.User, *, nickname: str = None) -> None:
@@ -106,6 +108,7 @@ async def nick(self, context: Context, user: discord.User, *, nickname: str = No
106108
description="Bans a user from the server.",
107109
)
108110
@commands.has_permissions(ban_members=True)
111+
@commands.bot_has_permissions(ban_members=True)
109112
@checks.not_blacklisted()
110113
@app_commands.describe(user="The user that should be banned.", reason="The reason why the user should be banned.")
111114
async def ban(self, context: Context, user: discord.User, *, reason: str = "Not specified") -> None:
@@ -261,6 +264,7 @@ async def warning_list(self, context: Context, user: discord.User):
261264
description="Delete a number of messages.",
262265
)
263266
@commands.has_guild_permissions(manage_messages=True)
267+
@commands.bot_has_permissions(manage_messages=True)
264268
@checks.not_blacklisted()
265269
@app_commands.describe(amount="The amount of messages that should be deleted.")
266270
async def purge(self, context: Context, amount: int) -> None:
@@ -270,11 +274,11 @@ async def purge(self, context: Context, amount: int) -> None:
270274
:param context: The hybrid command context.
271275
:param amount: The number of messages that should be deleted.
272276
"""
273-
await context.send("Deleting messages...") # Bit of a hacky way to make sure the bot responds to the interaction and doens't get a "Unknown Interaction" response
277+
await context.send("Deleting messages...") # Bit of a hacky way to make sure the bot responds to the interaction and doens't get a "Unknown Interaction" response
274278
purged_messages = await context.channel.purge(limit=amount+1)
275279
embed = discord.Embed(
276280
title="Chat Cleared!",
277-
description=f"**{context.author}** cleared **{len(purged_messages-1)}** messages!",
281+
description=f"**{context.author}** cleared **{len(purged_messages)-1}** messages!",
278282
color=0x9C84EF
279283
)
280284
await context.channel.send(embed=embed)
@@ -284,6 +288,7 @@ async def purge(self, context: Context, amount: int) -> None:
284288
description="Bans a user without the user having to be in the server.",
285289
)
286290
@commands.has_permissions(ban_members=True)
291+
@commands.bot_has_permissions(ban_members=True)
287292
@checks.not_blacklisted()
288293
@app_commands.describe(user_id="The user ID that should be banned.", reason="The reason why the user should be banned.")
289294
async def hackban(self, context: Context, user_id: str, *, reason: str = "Not specified") -> None:

cogs/owner.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@
33
Description:
44
This is a template to create your own discord bot in python.
55
6-
Version: 5.3
6+
Version: 5.4
77
"""
88

9-
import json
10-
import os
11-
import sys
12-
139
import discord
1410
from discord import app_commands
1511
from discord.ext import commands

cogs/template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Description:
44
This is a template to create your own discord bot in python.
55
6-
Version: 5.3
6+
Version: 5.4
77
"""
88

99
from discord.ext import commands

exceptions/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Description:
44
This is a template to create your own discord bot in python.
55
6-
Version: 5.3
6+
Version: 5.4
77
"""
88

99
from discord.ext import commands

helpers/checks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Description:
44
This is a template to create your own discord bot in python.
55
6-
Version: 5.3
6+
Version: 5.4
77
"""
88

99
import json

helpers/db_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Description:
44
This is a template to create your own discord bot in python.
55
6-
Version: 5.3
6+
Version: 5.4
77
"""
88

99
import aiosqlite

0 commit comments

Comments
 (0)