Skip to content

Commit e4552ad

Browse files
committed
Make prefixes configurable.
1 parent 0c553fd commit e4552ad

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

bootstrapper.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import os
33

44
import discord
5-
from discord.ext.commands import when_mentioned_or
65
from dotenv import find_dotenv, load_dotenv
76

87
from nameless import Nameless
@@ -15,6 +14,4 @@
1514
discord.utils.setup_logging(level=logging.DEBUG if is_debug else logging.INFO)
1615
logging.getLogger().name = "nameless"
1716

18-
nameless = Nameless(prefix=when_mentioned_or("nl."))
19-
20-
nameless.start_bot(is_debug=is_debug)
17+
Nameless().start_bot(is_debug=is_debug)

nameless.toml

+3
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
version = "2025.01.19"
33
description = "Just a normal bot."
44
support_server = ""
5+
6+
[command]
7+
prefixes = ["n."]

nameless/nameless.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import re
44
from datetime import datetime, timezone
55
from pathlib import Path
6-
from typing import Callable, override
6+
from typing import override
77

88
import discord
99
from discord import ActivityType, Permissions
@@ -18,17 +18,25 @@
1818
class Nameless(commands.Bot):
1919
"""Customized Discord instance, or so called, nameless* bot."""
2020

21-
def __init__(
22-
self, prefix: str | list[str] | Callable[..., list[str]], *args: object, **kwargs: object
23-
):
21+
def __init__(self, *args: object, **kwargs: object):
2422
# Downcasting because duck typed is a b*tch
2523
_description: str = nameless_config["nameless"]["description"]
2624

2725
_intents: discord.Intents = discord.Intents.default()
2826
_intents.message_content = True
2927
_intents.members = True
3028

31-
super().__init__(prefix, *args, intents=_intents, description=_description, **kwargs)
29+
_prefixes: list[str] = nameless_config["command"]["prefixes"]
30+
_prefixes.append("nl.")
31+
_prefixes = [*set(_prefixes)]
32+
33+
super().__init__(
34+
commands.when_mentioned_or(*_prefixes),
35+
*args,
36+
intents=_intents,
37+
description=_description,
38+
**kwargs,
39+
)
3240

3341
@override
3442
async def setup_hook(self):

0 commit comments

Comments
 (0)