33Description:
44This is a template to create your own discord bot in python.
55
6- Version: 5.3
6+ Version: 5.4
77"""
88
99import 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 :
0 commit comments