Skip to content

Commit

Permalink
🐛 various fixes and improvements
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
kkrypt0nn committed Oct 4, 2022
1 parent 2d0f342 commit 79f57ba
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 21 deletions.
6 changes: 6 additions & 0 deletions UPDATES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

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

### Version 5.2.1 (04 October 2022)

* 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.

### Vesion 5.2 (30 September 2022)

* Added `load`, `reload` and `unload` commands.
Expand Down
4 changes: 2 additions & 2 deletions bot.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
""""
"""
Copyright © Krypton 2022 - https://github.com/kkrypt0nn (https://krypton.ninja)
Description:
This is a template to create your own discord bot in python.
Version: 5.2
Version: 5.2.1
"""

import asyncio
Expand Down
3 changes: 1 addition & 2 deletions cogs/fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
Description:
This is a template to create your own discord bot in python.
Version: 5.2
Version: 5.2.1
"""

import random

import aiohttp
import discord
from discord import app_commands
from discord.ext import commands
from discord.ext.commands import Context
from helpers import checks
Expand Down
2 changes: 1 addition & 1 deletion cogs/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Description:
This is a template to create your own discord bot in python.
Version: 5.2
Version: 5.2.1
"""

import platform
Expand Down
27 changes: 19 additions & 8 deletions cogs/moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Description:
This is a template to create your own discord bot in python.
Version: 5.2
Version: 5.2.1
"""

import discord
Expand All @@ -24,7 +24,7 @@ def __init__(self, bot):
@commands.has_permissions(kick_members=True)
@checks.not_blacklisted()
@app_commands.describe(user="The user that should be kicked.", reason="The reason why the user should be kicked.")
async def kick(self, context: Context, user: discord.User, reason: str = "Not specified") -> None:
async def kick(self, context: Context, user: discord.User, *, reason: str = "Not specified") -> None:
"""
Kick a user out of the server.
Expand Down Expand Up @@ -75,7 +75,7 @@ async def kick(self, context: Context, user: discord.User, reason: str = "Not sp
@commands.has_permissions(manage_nicknames=True)
@checks.not_blacklisted()
@app_commands.describe(user="The user that should have a new nickname.", nickname="The new nickname that should be set.")
async def nick(self, context: Context, user: discord.User, nickname: str = None) -> None:
async def nick(self, context: Context, user: discord.User, *, nickname: str = None) -> None:
"""
Change the nickname of a user on a server.
Expand Down Expand Up @@ -107,7 +107,7 @@ async def nick(self, context: Context, user: discord.User, nickname: str = None)
@commands.has_permissions(ban_members=True)
@checks.not_blacklisted()
@app_commands.describe(user="The user that should be banned.", reason="The reason why the user should be banned.")
async def ban(self, context: Context, user: discord.User, reason: str = "Not specified") -> None:
async def ban(self, context: Context, user: discord.User, *, reason: str = "Not specified") -> None:
"""
Bans a user from the server.
Expand Down Expand Up @@ -156,7 +156,18 @@ async def ban(self, context: Context, user: discord.User, reason: str = "Not spe
@commands.has_permissions(manage_messages=True)
@checks.not_blacklisted()
async def warning(self, context: Context) -> None:
pass
"""
Manage warnings of a user on a server.
:param context: The hybrid command context.
"""
if context.invoked_subcommand is None:
embed = discord.Embed(
title="Error!",
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.",
color=0xE02B2B
)
await context.send(embed=embed)

@warning.command(
name="add",
Expand All @@ -165,7 +176,7 @@ async def warning(self, context: Context) -> None:
@checks.not_blacklisted()
@commands.has_permissions(manage_messages=True)
@app_commands.describe(user="The user that should be warned.", reason="The reason why the user should be warned.")
async def warning_add(self, context: Context, user: discord.User, reason: str = "Not specified") -> None:
async def warning_add(self, context: Context, user: discord.User, *, reason: str = "Not specified") -> None:
"""
Warns a user in his private messages.
Expand Down Expand Up @@ -199,7 +210,7 @@ async def warning_add(self, context: Context, user: discord.User, reason: str =
@checks.not_blacklisted()
@commands.has_permissions(manage_messages=True)
@app_commands.describe(user="The user that should get their warning removed.", warn_id="The ID of the warning that should be removed.")
async def warning_add(self, context: Context, user: discord.User, warn_id: int) -> None:
async def warning_remove(self, context: Context, user: discord.User, warn_id: int) -> None:
"""
Warns a user in his private messages.
Expand Down Expand Up @@ -273,7 +284,7 @@ async def purge(self, context: Context, amount: int) -> None:
@commands.has_permissions(ban_members=True)
@checks.not_blacklisted()
@app_commands.describe(user_id="The user ID that should be banned.", reason="The reason why the user should be banned.")
async def hackban(self, context: Context, user_id: str, reason: str = "Not specified") -> None:
async def hackban(self, context: Context, user_id: str, *, reason: str = "Not specified") -> None:
"""
Bans a user without the user having to be in the server.
Expand Down
14 changes: 10 additions & 4 deletions cogs/owner.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Description:
This is a template to create your own discord bot in python.
Version: 5.2
Version: 5.2.1
"""

import json
Expand Down Expand Up @@ -216,7 +216,7 @@ async def shutdown(self, context: Context) -> None:
)
@app_commands.describe(message="The message that should be repeated by the bot")
@checks.is_owner()
async def say(self, context: Context, message: str) -> None:
async def say(self, context: Context, *, message: str) -> None:
"""
The bot will say anything you want.
Expand All @@ -231,7 +231,7 @@ async def say(self, context: Context, message: str) -> None:
)
@app_commands.describe(message="The message that should be repeated by the bot")
@checks.is_owner()
async def embed(self, context: Context, message: str) -> None:
async def embed(self, context: Context, *, message: str) -> None:
"""
The bot will say anything you want, but using embeds.
Expand All @@ -255,7 +255,13 @@ async def blacklist(self, context: Context) -> None:
:param context: The hybrid command context.
"""
pass
if context.invoked_subcommand is None:
embed = discord.Embed(
title="Blacklist",
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.",
color=0xE02B2B
)
await context.send(embed=embed)

@blacklist.command(
base="blacklist",
Expand Down
2 changes: 1 addition & 1 deletion cogs/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Description:
This is a template to create your own discord bot in python.
Version: 5.2
Version: 5.2.1
"""

from discord.ext import commands
Expand Down
2 changes: 1 addition & 1 deletion exceptions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Description:
This is a template to create your own discord bot in python.
Version: 5.2
Version: 5.2.1
"""

from discord.ext import commands
Expand Down
2 changes: 1 addition & 1 deletion helpers/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Description:
This is a template to create your own discord bot in python.
Version: 5.2
Version: 5.2.1
"""

import json
Expand Down
2 changes: 1 addition & 1 deletion helpers/db_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Description:
This is a template to create your own discord bot in python.
Version: 5.2
Version: 5.2.1
"""

import sqlite3
Expand Down

0 comments on commit 79f57ba

Please sign in to comment.