feat(bot): ✨ Make prefixes allow up to 5 characters.
This commit is contained in:
+3
-3
@@ -271,16 +271,16 @@ class Payphone(commands.AutoShardedBot):
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
server (discord.Guild | models.Server | int): The server to update or it's ID.
|
server (discord.Guild | models.Server | int): The server to update or it's ID.
|
||||||
prefix (str, optional): The new prefix. It cannot be longer than 3 characters. Defaults
|
prefix (str, optional): The new prefix. It cannot be longer than 5 characters. Defaults
|
||||||
to "p.".
|
to "p.".
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
ValueError: The prefix provided is invalid.
|
ValueError: The prefix provided is invalid.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if len(prefix) > 3 or len(prefix) == 0:
|
if len(prefix) > 5 or len(prefix) == 0:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"The prefix must not be longer than 3 characters and must not be an empty string."
|
"The prefix must not be longer than 5 characters and must not be an empty string."
|
||||||
)
|
)
|
||||||
|
|
||||||
server_id = server if isinstance(server, int) else server.id
|
server_id = server if isinstance(server, int) else server.id
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
from tortoise import BaseDBAsyncClient
|
||||||
|
|
||||||
|
|
||||||
|
async def upgrade(db: BaseDBAsyncClient) -> str:
|
||||||
|
return """
|
||||||
|
ALTER TABLE "server" ALTER COLUMN "prefix" TYPE VARCHAR(5) USING "prefix"::VARCHAR(5);"""
|
||||||
|
|
||||||
|
|
||||||
|
async def downgrade(db: BaseDBAsyncClient) -> str:
|
||||||
|
return """
|
||||||
|
ALTER TABLE "server" ALTER COLUMN "prefix" TYPE VARCHAR(3) USING "prefix"::VARCHAR(3);"""
|
||||||
@@ -73,7 +73,7 @@ class Profile(models.Model):
|
|||||||
|
|
||||||
class Server(models.Model):
|
class Server(models.Model):
|
||||||
id: int = fields.BigIntField(primary_key=True)
|
id: int = fields.BigIntField(primary_key=True)
|
||||||
prefix: str = fields.CharField(max_length=3, default="p.")
|
prefix: str = fields.CharField(max_length=5, default="p.")
|
||||||
channels: fields.BackwardFKRelation["Channel"]
|
channels: fields.BackwardFKRelation["Channel"]
|
||||||
profiles: fields.BackwardFKRelation["Profile"]
|
profiles: fields.BackwardFKRelation["Profile"]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user