Skip to content

Commit 79f57ba

Browse files
committed
🐛 various fixes and improvements
* Added error message when subcommands are not given * Fixed `warning remove` command * Now using keyword arguments (`async def command(self, context, *, message):`) for kick/ban reason, message to sent, etc.
1 parent 2d0f342 commit 79f57ba

File tree

10 files changed

+43
-21
lines changed

10 files changed

+43
-21
lines changed

UPDATES.md

+6
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.2.1 (04 October 2022)
6+
7+
* Added error message when subcommands are not given
8+
* Fixed `warning remove` command
9+
* Now using keyword arguments (`async def command(self, context, *, message):`) for kick/ban reason, message to sent, etc.
10+
511
### Vesion 5.2 (30 September 2022)
612

713
* Added `load`, `reload` and `unload` commands.

bot.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
""""
1+
"""
22
Copyright © Krypton 2022 - https://github.com/kkrypt0nn (https://krypton.ninja)
33
Description:
44
This is a template to create your own discord bot in python.
55
6-
Version: 5.2
6+
Version: 5.2.1
77
"""
88

99
import asyncio

cogs/fun.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
Description:
44
This is a template to create your own discord bot in python.
55
6-
Version: 5.2
6+
Version: 5.2.1
77
"""
88

99
import random
1010

1111
import aiohttp
1212
import discord
13-
from discord import app_commands
1413
from discord.ext import commands
1514
from discord.ext.commands import Context
1615
from helpers import checks

cogs/general.py

+1-1
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.2
6+
Version: 5.2.1
77
"""
88

99
import platform

cogs/moderation.py

+19-8
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.2
6+
Version: 5.2.1
77
"""
88

99
import discord
@@ -24,7 +24,7 @@ def __init__(self, bot):
2424
@commands.has_permissions(kick_members=True)
2525
@checks.not_blacklisted()
2626
@app_commands.describe(user="The user that should be kicked.", reason="The reason why the user should be kicked.")
27-
async def kick(self, context: Context, user: discord.User, reason: str = "Not specified") -> None:
27+
async def kick(self, context: Context, user: discord.User, *, reason: str = "Not specified") -> None:
2828
"""
2929
Kick a user out of the server.
3030
@@ -75,7 +75,7 @@ async def kick(self, context: Context, user: discord.User, reason: str = "Not sp
7575
@commands.has_permissions(manage_nicknames=True)
7676
@checks.not_blacklisted()
7777
@app_commands.describe(user="The user that should have a new nickname.", nickname="The new nickname that should be set.")
78-
async def nick(self, context: Context, user: discord.User, nickname: str = None) -> None:
78+
async def nick(self, context: Context, user: discord.User, *, nickname: str = None) -> None:
7979
"""
8080
Change the nickname of a user on a server.
8181
@@ -107,7 +107,7 @@ async def nick(self, context: Context, user: discord.User, nickname: str = None)
107107
@commands.has_permissions(ban_members=True)
108108
@checks.not_blacklisted()
109109
@app_commands.describe(user="The user that should be banned.", reason="The reason why the user should be banned.")
110-
async def ban(self, context: Context, user: discord.User, reason: str = "Not specified") -> None:
110+
async def ban(self, context: Context, user: discord.User, *, reason: str = "Not specified") -> None:
111111
"""
112112
Bans a user from the server.
113113
@@ -156,7 +156,18 @@ async def ban(self, context: Context, user: discord.User, reason: str = "Not spe
156156
@commands.has_permissions(manage_messages=True)
157157
@checks.not_blacklisted()
158158
async def warning(self, context: Context) -> None:
159-
pass
159+
"""
160+
Manage warnings of a user on a server.
161+
162+
:param context: The hybrid command context.
163+
"""
164+
if context.invoked_subcommand is None:
165+
embed = discord.Embed(
166+
title="Error!",
167+
description="Please specify a subcommand.\n\n**Subcommands:**\n`add` - Add a warning to a user.\n`remove` - Remove a warning from a user.\n`list` - List all warnings of a user.",
168+
color=0xE02B2B
169+
)
170+
await context.send(embed=embed)
160171

161172
@warning.command(
162173
name="add",
@@ -165,7 +176,7 @@ async def warning(self, context: Context) -> None:
165176
@checks.not_blacklisted()
166177
@commands.has_permissions(manage_messages=True)
167178
@app_commands.describe(user="The user that should be warned.", reason="The reason why the user should be warned.")
168-
async def warning_add(self, context: Context, user: discord.User, reason: str = "Not specified") -> None:
179+
async def warning_add(self, context: Context, user: discord.User, *, reason: str = "Not specified") -> None:
169180
"""
170181
Warns a user in his private messages.
171182
@@ -199,7 +210,7 @@ async def warning_add(self, context: Context, user: discord.User, reason: str =
199210
@checks.not_blacklisted()
200211
@commands.has_permissions(manage_messages=True)
201212
@app_commands.describe(user="The user that should get their warning removed.", warn_id="The ID of the warning that should be removed.")
202-
async def warning_add(self, context: Context, user: discord.User, warn_id: int) -> None:
213+
async def warning_remove(self, context: Context, user: discord.User, warn_id: int) -> None:
203214
"""
204215
Warns a user in his private messages.
205216
@@ -273,7 +284,7 @@ async def purge(self, context: Context, amount: int) -> None:
273284
@commands.has_permissions(ban_members=True)
274285
@checks.not_blacklisted()
275286
@app_commands.describe(user_id="The user ID that should be banned.", reason="The reason why the user should be banned.")
276-
async def hackban(self, context: Context, user_id: str, reason: str = "Not specified") -> None:
287+
async def hackban(self, context: Context, user_id: str, *, reason: str = "Not specified") -> None:
277288
"""
278289
Bans a user without the user having to be in the server.
279290

cogs/owner.py

+10-4
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.2
6+
Version: 5.2.1
77
"""
88

99
import json
@@ -216,7 +216,7 @@ async def shutdown(self, context: Context) -> None:
216216
)
217217
@app_commands.describe(message="The message that should be repeated by the bot")
218218
@checks.is_owner()
219-
async def say(self, context: Context, message: str) -> None:
219+
async def say(self, context: Context, *, message: str) -> None:
220220
"""
221221
The bot will say anything you want.
222222
@@ -231,7 +231,7 @@ async def say(self, context: Context, message: str) -> None:
231231
)
232232
@app_commands.describe(message="The message that should be repeated by the bot")
233233
@checks.is_owner()
234-
async def embed(self, context: Context, message: str) -> None:
234+
async def embed(self, context: Context, *, message: str) -> None:
235235
"""
236236
The bot will say anything you want, but using embeds.
237237
@@ -255,7 +255,13 @@ async def blacklist(self, context: Context) -> None:
255255
256256
:param context: The hybrid command context.
257257
"""
258-
pass
258+
if context.invoked_subcommand is None:
259+
embed = discord.Embed(
260+
title="Blacklist",
261+
description="You need to specify a subcommand.\n\n**Subcommands:**\n`add` - Add a user to the blacklist.\n`remove` - Remove a user from the blacklist.",
262+
color=0xE02B2B
263+
)
264+
await context.send(embed=embed)
259265

260266
@blacklist.command(
261267
base="blacklist",

cogs/template.py

+1-1
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.2
6+
Version: 5.2.1
77
"""
88

99
from discord.ext import commands

exceptions/__init__.py

+1-1
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.2
6+
Version: 5.2.1
77
"""
88

99
from discord.ext import commands

helpers/checks.py

+1-1
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.2
6+
Version: 5.2.1
77
"""
88

99
import json

helpers/db_manager.py

+1-1
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.2
6+
Version: 5.2.1
77
"""
88

99
import sqlite3

0 commit comments

Comments
 (0)