๐
pasted-code-1784927411152.txt
txt
345 lines
โถ
Create a professional, powerful, and feature-rich Discord bot focused entirely on server moderation, security, automation, and community management. The bot should work directly inside Discord using slash commands, buttons, menus, and interactive embeds. It should not include any VPS, hosting, Minecraft, or external dashboard features.
The goal is to create an all-in-one Discord management solution that can replace multiple separate bots by combining moderation, protection, support, and engagement features into one clean and easy-to-use bot.
๐ก๏ธ 1. Advanced Moderation System
Create a complete moderation system that helps staff control and manage their Discord server.
Features:
Warning System
Allow moderators to warn members.
Store warning history for every user.
Show previous warnings using commands.
Automatically punish users after reaching a warning limit.
Example:
/warn @user Spamming
Bot response:
User warned successfully.
Reason: Spamming
Total warnings: 2/5
Punishment System
Include moderation commands:
/warn โ Give warnings
/warnings โ View user warnings
/mute โ Temporarily remove speaking permissions
/timeout โ Discord timeout system
/kick โ Remove members
/ban โ Permanently ban users
/unban โ Remove bans
/clear โ Delete messages
Allow admins to customize:
Default punishment duration
Warning limits
Required moderator roles
๐จ 2. Anti-Raid & Server Protection System
Create a security system that protects Discord servers from attacks.
Anti-Raid Protection:
Detect suspicious activity like:
Many users joining quickly
New accounts joining during attacks
Mass message sending
Spam waves
Actions:
Automatically lock channels
Remove suspicious users
Alert moderators
Enable emergency protection mode
Anti-Nuke Protection:
Protect important server settings from malicious users.
Monitor:
Channel deletion
Role deletion
Mass bans
Permission changes
Webhook creation
Server setting changes
If someone tries to damage the server:
Example:
User banned 50 members
Bot automatically:
Stops the action
Removes dangerous permissions
Logs the event
Alerts staff
๐ 3. Verification System
Create a member verification system to stop bots and fake accounts.
Features:
Verification button
Verification roles
Account age checking
New account restrictions
Verified member logs
Example:
New user joins:
Welcome!
Please verify yourself to access the server.
[ Verify ]
After clicking:
Verification completed.
You now have Member access.
๐ซ 4. Advanced Ticket System
Create a complete support ticket system inside Discord.
Ticket Features:
Create ticket panels
Multiple ticket categories
Staff claiming system
Private ticket channels
Ticket closing buttons
Ticket transcripts
Ticket logs
Example categories:
๐ซ Support
๐ฐ Purchase Help
โ ๏ธ Report User
๐ฉ Partnership
Staff can:
Claim tickets
Close tickets
Add/remove members
View ticket history
โ๏ธ 5. Automation System
Reduce manual server management with automated features.
Welcome System:
Automatically send welcome messages.
Example:
Welcome @User to our community!
Read:
#rules
#announcements
Goodbye System:
Send goodbye messages when users leave.
Example:
Goodbye @User.
We hope to see you again!
Auto Role System:
Automatically assign roles.
Examples:
Member role
Verified role
New user role
Reaction Roles:
Allow users to select roles by clicking buttons.
Example:
Choose your role:
๐ฎ Gamer
๐จ Designer
๐ป Developer
๐ข 6. Server Announcement Tools
Create tools for better communication.
Features:
Scheduled announcements
Custom embed messages
News broadcasts
Event reminders
Example:
/announce
Title:
Server Update
Message:
New features have been released!
๐ 7. Community Engagement Features
Help Discord servers become more active.
Giveaway System
Features:
Create giveaways
Set winners
Automatic ending
Giveaway reroll
Example:
/giveaway start
Prize:
Nitro Classic
Duration:
24 hours
Winners:
3
Leveling System
Reward active members.
Features:
XP system
Level roles
Leaderboards
Rank cards
Example:
User reached Level 10
Reward:
Active Member Role
Economy System
Add a virtual currency system.
Features:
Earn coins by chatting
Daily rewards
User balance
Leaderboards
Shop system
Example:
/balance
Coins:
500
๐ก 8. Suggestion & Feedback System
Allow members to submit ideas.
Features:
Suggestion channels
Voting buttons
Staff responses
Approval/rejection system
Example:
Suggestion:
Add more events
๐ 50
๐ 5
๐ 9. Logging System
Create detailed logs for server actions.
Log:
Messages deleted
Messages edited
Members joining/leaving
Moderation actions
Role changes
Channel changes
Security alerts
Example:
Moderation Log
Moderator:
Admin
Action:
Banned User
Reason:
Rule violation
๐ค 10. User Management System
Create detailed member management tools.
Features:
User information command
Join date
Roles
Warning history
Activity tracking
Reputation system
Example:
/userinfo @user
Shows:
Username:
Join Date:
Roles:
Warnings:
Level:
๐จ Design Requirements
The bot should have:
Premium Discord-style embeds
Modern buttons and menus
Clean command responses
Fast performance
Easy setup process
Multi-server support
Secure database
Permission-based commands
Professional error handling
Final Goal:
Create a complete Discord server operating system that combines moderation, security, automation, support, and community features into one powerful bot.
The bot should feel like a premium alternative to popular Discord bots such as Dyno, Carl-bot, MEE6, and Wick, but with more customization, better organization, and a complete set of tools managed directly inside Discord.
bot is not starting this is my token <redacted>
That Discord bot token is exposed and must be revoked immediately. In the Discord Developer Portal:
Open Developer Portal โ Your Application โ Bot.
Click Reset Token, then copy the new token.
Do not send the new token here.
Create a .env file in the same folder as bot.py:
DISCORD_TOKEN=PASTE_THE_NEW_TOKEN_HERE
DATABASE_PATH=guardian.sqlite3
Then install dependencies and start the bot:
python -m pip install -r requirements.txt
python bot.py
Also enable these under Developer Portal โ Bot โ Privileged Gateway Intents:
Server Members Intent
Message Content Intent
If it still fails, paste the complete terminal traceback here, but remove the token and any other secrets. Common errors:
DISCORD_TOKEN is not configuredโ.envis missing, misnamed, or in the wrong folder.Improper token has been passedโ the token was copied incorrectly or has been reset.PrivilegedIntentsRequiredโ the required intents are not enabled.ModuleNotFoundErrorโ run the dependency installation command again.
๐
pasted-code-1784928002339.txt
txt
39 lines
โถ
Loading bot files...
Creating a super duper secure sandbox...
Sandbox created, starting bot...
2026-07-24 21:19:54,984 | WARNING | discord.client | PyNaCl is not installed, voice will NOT be supported
[2026-07-24 21:19:54] [INFO ] discord.client: logging in using static token
2026-07-24 21:19:54,985 | INFO | discord.client | logging in using static token
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/discord/http.py", line 816, in static_login
data = await self.request(Route('GET', '/users/@me'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/discord/http.py", line 758, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/root/bot.py", line 86, in
bot.run(settings.token)
File "/usr/local/lib/python3.12/site-packages/discord/client.py", line 869, in run
asyncio.run(runner())
File "/usr/local/lib/python3.12/asyncio/runners.py", line 195, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 691, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/discord/client.py", line 858, in runner
await self.start(token, reconnect=reconnect)
File "/usr/local/lib/python3.12/site-packages/discord/client.py", line 786, in start
await self.login(token)
File "/usr/local/lib/python3.12/site-packages/discord/client.py", line 620, in login
data = await self.http.static_login(token)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/discord/http.py", line 820, in static_login
raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.
Bot process crashed
The bot is reaching Discord successfully, but Discord is rejecting the token:
401 Unauthorized
discord.errors.LoginFailure: Improper token has been passed.
The PyNaCl warning is unrelated; it only disables voice support.
Because the token was exposed, immediately:
Go to Discord Developer Portal โ Your Application โ Bot.
Click Reset Token.
Copy the new token. Do not post it here.
Update the token in your hosting panel or
.envfile.Restart/redeploy the bot.
Your .env should contain the new token without quotes or extra spaces:
DISCORD_TOKEN=your_new_token_here
If your code uses settings.token, verify that it loads the same environment variable:
import os
from dotenv import load_dotenv
load_dotenv()
token = os.getenv("DISCORD_TOKEN")
if not token:
raise RuntimeError("DISCORD_TOKEN is not configured")
bot.run(token)
Also check that:
The variable is named exactly
DISCORD_TOKEN.The hosting service has been restarted after changing it.
You pasted the bot token, not the application ID, public key, or client secret.
No leading/trailing spaces or accidental line breaks were included.
Do not try to reuse the token that was posted; resetting it invalidates the exposed token.
<redacted>
That token is exposed. Reset it immediatelyโdo not use or share it again.
Go to Discord Developer Portal โ Your Application โ Bot.
Click Reset Token and copy the new token privately.
Update your hosting environment or
.env:
DISCORD_TOKEN=your_new_token_here
Restart the bot.
Make sure the value has no quotes, spaces, or line breaks. The previous token should be considered compromised and invalidated.
fix this
๐
pasted-code-1784928906751.txt
txt
27 lines
โถ
D:\Website\bot>python bot.py
Traceback (most recent call last):
File "D:\Website\bot\bot.py", line 3, in
import discord
File "C:\Users\SubhanZahid\AppData\Roaming\Python\Python314\site-packages\discord\__init__.py", line 23, in
from .client import *
File "C:\Users\SubhanZahid\AppData\Roaming\Python\Python314\site-packages\discord\client.py", line 51, in
from .sku import SKU, Entitlement
File "C:\Users\SubhanZahid\AppData\Roaming\Python\Python314\site-packages\discord\sku.py", line 31, in
from .app_commands import MissingApplicationID
File "C:\Users\SubhanZahid\AppData\Roaming\Python\Python314\site-packages\discord\app_commands\__init__.py", line 12, in
from .commands import *
File "C:\Users\SubhanZahid\AppData\Roaming\Python\Python314\site-packages\discord\app_commands\commands.py", line 53, in
from .models import Choice
File "C:\Users\SubhanZahid\AppData\Roaming\Python\Python314\site-packages\discord\app_commands\models.py", line 44, in
from ..member import Member
File "C:\Users\SubhanZahid\AppData\Roaming\Python\Python314\site-packages\discord\member.py", line 33, in
import discord.abc
File "C:\Users\SubhanZahid\AppData\Roaming\Python\Python314\site-packages\discord\abc.py", line 59, in
from .voice_client import VoiceClient, VoiceProtocol
File "C:\Users\SubhanZahid\AppData\Roaming\Python\Python314\site-packages\discord\voice_client.py", line 35, in
from .player import AudioPlayer, AudioSource
File "C:\Users\SubhanZahid\AppData\Roaming\Python\Python314\site-packages\discord\player.py", line 29, in
import audioop
ModuleNotFoundError: No module named 'audioop'
D:\Website\bot>t
Add the Python 3.13+
audioopcompatibility package to the dependencies.Reinstall dependencies in the same Python 3.14 environment and restart the bot.
The error is caused by Python 3.14 removing audioop, while your installed discord.py version still imports it.
Updated requirements.txt to include:
audioop-lts>=0.2.1; python_version >= "3.13"
PyNaCl>=1.5.0
From D:\Website\bot, run:
py -3.14 -m pip install --upgrade -r requirements.txt
py -3.14 bot.py
If audioop-lts does not install correctly on Python 3.14, use Python 3.12 instead:
py -3.12 -m pip install -r requirements.txt
py -3.12 bot.py
The PyNaCl package removes the voice-support warning. It is not required for normal text, moderation, slash-command, or interaction features.
remove audioloop
Removed audioop-lts from requirements.txt.
Reinstall dependencies:
py -3.14 -m pip install --upgrade -r requirements.txt
However, Python 3.14 may still fail because discord.py==2.4.0 imports the removed audioop module. If that happens, use Python 3.12:
py -3.12 -m pip install -r requirements.txt
py -3.12 bot.py
๐
pasted-code-1784929523481.txt
txt
42 lines
โถ
(.venv) PS D:\Website\bot> python bot.py
2026-07-25 02:44:51,042 | WARNING | discord.client | PyNaCl is not installed, voice will NOT be supported
2026-07-25 02:44:51,044 | WARNING | discord.client | davey is not installed, voice will NOT be supported
2026-07-25 02:44:51 INFO discord.client logging in using static token
2026-07-25 02:44:51,047 | INFO | discord.client | logging in using static token
Traceback (most recent call last):
File "D:\Website\bot\.venv\Lib\site-packages\discord\http.py", line 844, in static_login
data = await self.request(Route('GET', '/users/@me'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Website\bot\.venv\Lib\site-packages\discord\http.py", line 778, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\Website\bot\bot.py", line 86, in
bot.run(settings.token)
~~~~~~~^^^^^^^^^^^^^^^^
File "D:\Website\bot\.venv\Lib\site-packages\discord\client.py", line 933, in run
asyncio.run(runner())
~~~~~~~~~~~^^^^^^^^^^
File "C:\Program Files\Python314\Lib\asyncio\runners.py", line 204, in run
return runner.run(main)
~~~~~~~~~~^^^^^^
File "C:\Program Files\Python314\Lib\asyncio\runners.py", line 127, in run
return self._loop.run_until_complete(task)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "C:\Program Files\Python314\Lib\asyncio\base_events.py", line 719, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "D:\Website\bot\.venv\Lib\site-packages\discord\client.py", line 922, in runner
await self.start(token, reconnect=reconnect)
File "D:\Website\bot\.venv\Lib\site-packages\discord\client.py", line 850, in start
await self.login(token)
File "D:\Website\bot\.venv\Lib\site-packages\discord\client.py", line 679, in login
data = await self.http.static_login(token)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Website\bot\.venv\Lib\site-packages\discord\http.py", line 848, in static_login
raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.
(.venv) PS D:\Website\bot>
The bot code is starting correctly. The failure is only authentication:
401 Unauthorized
discord.errors.LoginFailure: Improper token has been passed.
All tokens previously posted must be considered compromised. Reset the bot token again in:
Discord Developer Portal โ Application โ Bot โ Reset Token
Then update your .env file with the new token:
DISCORD_TOKEN=your_new_token_here
Use the raw bot token onlyโdo not include Bot , quotes, spaces, or line breaks.
In PowerShell, make sure an old environment variable is not overriding .env:
Get-ChildItem Env:DISCORD_TOKEN
If an old value appears, replace it temporarily:
$env:DISCORD_TOKEN="your_new_token_here"
python bot.py
Your code should ultimately pass the raw value:
bot.run(settings.token)
or:
import os
from dotenv import load_dotenv
load_dotenv()
token = os.getenv("DISCORD_TOKEN")
if not token:
raise RuntimeError("DISCORD_TOKEN is missing")
bot.run(token)
The PyNaCl and davey messages are only voice-support warnings; they are unrelated to the login failure.
๐
pasted-code-1784929570065.txt
txt
38 lines
โถ
.venv) PS D:\Website\bot> $env:DISCORD_TOKEN=""
>> python bot.py
2026-07-25 02:45:55,506 | WARNING | discord.client | PyNaCl is not installed, voice will NOT be supported
2026-07-25 02:45:55,507 | WARNING | discord.client | davey is not installed, voice will NOT be supported
2026-07-25 02:45:55 INFO discord.client logging in using static token
2026-07-25 02:45:55,509 | INFO | discord.client | logging in using static token
Traceback (most recent call last):
File "D:\Website\bot\bot.py", line 86, in
bot.run(settings.token)
~~~~~~~^^^^^^^^^^^^^^^^
File "D:\Website\bot\.venv\Lib\site-packages\discord\client.py", line 933, in run
asyncio.run(runner())
~~~~~~~~~~~^^^^^^^^^^
File "C:\Program Files\Python314\Lib\asyncio\runners.py", line 204, in run
return runner.run(main)
~~~~~~~~~~^^^^^^
File "C:\Program Files\Python314\Lib\asyncio\runners.py", line 127, in run
return self._loop.run_until_complete(task)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "C:\Program Files\Python314\Lib\asyncio\base_events.py", line 719, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "D:\Website\bot\.venv\Lib\site-packages\discord\client.py", line 922, in runner
await self.start(token, reconnect=reconnect)
File "D:\Website\bot\.venv\Lib\site-packages\discord\client.py", line 850, in start
await self.login(token)
File "D:\Website\bot\.venv\Lib\site-packages\discord\client.py", line 693, in login
await self.setup_hook()
File "D:\Website\bot\bot.py", line 48, in setup_hook
synced = await self.tree.sync()
^^^^^^^^^^^^^^^^^^^^^^
File "D:\Website\bot\.venv\Lib\site-packages\discord\app_commands\tree.py", line 1121, in sync
raise CommandSyncFailure(e, commands) from None
discord.app_commands.errors.CommandSyncFailure: Failed to upload commands to Discord (HTTP status 400, error code 50035)
In command 'unban' defined in function 'Moderation.unban'
In parameter 'user_id'
max_value: int53 value should be less than or equal to 9007199254740991.
(.venv) PS D:\Website\bot>
Fixed the command-sync error in cogs/moderation.py.
Discord only accepts integer slash-command bounds up to:
9007199254740991
The /unban parameter now uses that valid maximum instead of 10**20.
Restart the bot:
python bot.py
The PyNaCl and davey messages are only voice warnings and do not prevent startup. Also reset the token you posted publicly before restarting.
๐
pasted-code-1784929618694.txt
txt
38 lines
โถ
(.venv) PS D:\Website\bot> $env:DISCORD_TOKEN=""
>> python bot.py
2026-07-25 02:46:45,518 | WARNING | discord.client | PyNaCl is not installed, voice will NOT be supported
2026-07-25 02:46:45,519 | WARNING | discord.client | davey is not installed, voice will NOT be supported
2026-07-25 02:46:45 INFO discord.client logging in using static token
2026-07-25 02:46:45,521 | INFO | discord.client | logging in using static token
Traceback (most recent call last):
File "D:\Website\bot\bot.py", line 86, in
bot.run(settings.token)
~~~~~~~^^^^^^^^^^^^^^^^
File "D:\Website\bot\.venv\Lib\site-packages\discord\client.py", line 933, in run
asyncio.run(runner())
~~~~~~~~~~~^^^^^^^^^^
File "C:\Program Files\Python314\Lib\asyncio\runners.py", line 204, in run
return runner.run(main)
~~~~~~~~~~^^^^^^
File "C:\Program Files\Python314\Lib\asyncio\runners.py", line 127, in run
return self._loop.run_until_complete(task)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "C:\Program Files\Python314\Lib\asyncio\base_events.py", line 719, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "D:\Website\bot\.venv\Lib\site-packages\discord\client.py", line 922, in runner
await self.start(token, reconnect=reconnect)
File "D:\Website\bot\.venv\Lib\site-packages\discord\client.py", line 850, in start
await self.login(token)
File "D:\Website\bot\.venv\Lib\site-packages\discord\client.py", line 693, in login
await self.setup_hook()
File "D:\Website\bot\bot.py", line 48, in setup_hook
synced = await self.tree.sync()
^^^^^^^^^^^^^^^^^^^^^^
File "D:\Website\bot\.venv\Lib\site-packages\discord\app_commands\tree.py", line 1121, in sync
raise CommandSyncFailure(e, commands) from None
discord.app_commands.errors.CommandSyncFailure: Failed to upload commands to Discord (HTTP status 400, error code 50035)
In command 'unban' defined in function 'Moderation.unban'
In parameter 'user_id'
max_value: int53 value should be less than or equal to 9007199254740991.
(.venv) PS D:\Website\bot>
Fixed /unban by removing the invalid max_value constraint that Discord was still rejecting.
Restart the bot:
python bot.py
The PyNaCl and davey messages are unrelated voice-support warnings.
Also, the token shown in your command is exposed and must be reset in the Discord Developer Portal before using the bot again.
๐
pasted-code-1784929667807.txt
txt
37 lines
โถ
(.venv) PS D:\Website\bot> python bot.py
2026-07-25 02:47:32,226 | WARNING | discord.client | PyNaCl is not installed, voice will NOT be supported
2026-07-25 02:47:32,226 | WARNING | discord.client | davey is not installed, voice will NOT be supported
2026-07-25 02:47:32 INFO discord.client logging in using static token
2026-07-25 02:47:32,228 | INFO | discord.client | logging in using static token
Traceback (most recent call last):
File "D:\Website\bot\bot.py", line 86, in
bot.run(settings.token)
~~~~~~~^^^^^^^^^^^^^^^^
File "D:\Website\bot\.venv\Lib\site-packages\discord\client.py", line 933, in run
asyncio.run(runner())
~~~~~~~~~~~^^^^^^^^^^
File "C:\Program Files\Python314\Lib\asyncio\runners.py", line 204, in run
return runner.run(main)
~~~~~~~~~~^^^^^^
File "C:\Program Files\Python314\Lib\asyncio\runners.py", line 127, in run
return self._loop.run_until_complete(task)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "C:\Program Files\Python314\Lib\asyncio\base_events.py", line 719, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "D:\Website\bot\.venv\Lib\site-packages\discord\client.py", line 922, in runner
await self.start(token, reconnect=reconnect)
File "D:\Website\bot\.venv\Lib\site-packages\discord\client.py", line 850, in start
await self.login(token)
File "D:\Website\bot\.venv\Lib\site-packages\discord\client.py", line 693, in login
await self.setup_hook()
File "D:\Website\bot\bot.py", line 48, in setup_hook
synced = await self.tree.sync()
^^^^^^^^^^^^^^^^^^^^^^
File "D:\Website\bot\.venv\Lib\site-packages\discord\app_commands\tree.py", line 1121, in sync
raise CommandSyncFailure(e, commands) from None
discord.app_commands.errors.CommandSyncFailure: Failed to upload commands to Discord (HTTP status 400, error code 50035)
In command 'unban' defined in function 'Moderation.unban'
In parameter 'user_id'
max_value: int53 value should be less than or equal to 9007199254740991.
(.venv) PS D:\Website\bot>
Change
/unbanโs ID option to text so Discord does not generate the invalid integermax_value.Convert and validate the ID inside the command before fetching the user.
Fixed /unban by changing user_id from an integer slash-command option to a text option. Discord will no longer generate the invalid max_value.
Restart the bot:
python bot.py
Use the command with a Discord ID, for example:
/unban user_id:123456789012345678 reason:Appeal approved
The ID is validated and converted inside the command. The voice warnings are unrelated. Reset the exposed bot token before running the bot again.
import logging
import discord
from discord import app_commands
from discord.ext import commands
from config import load_settings
from database import Database
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s | %(levelname)s | %(name)s | %(message)s",
)
class GuardianBot(commands.Bot):
def __init__(self, database: Database):
intents = discord.Intents.default()
intents.members = True
intents.message_content = True
intents.guilds = True
intents.moderation = True
super().__init__(
command_prefix="!",
intents=intents,
case_insensitive=True,
help_command=None,
)
self.db = database
async def setup_hook(self) -> None:
await self.db.connect()
extensions = (
"cogs.moderation",
"cogs.security",
"cogs.automation",
"cogs.tickets",
"cogs.community",
"cogs.utility",
)
for extension in extensions:
await self.load_extension(extension)
synced = await self.tree.sync()
logging.getLogger("guardian").info(
"Synchronized %d application commands.", len(synced)
)
async def close(self) -> None:
await self.db.close()
await super().close()
settings = load_settings()
bot = GuardianBot(Database(settings.database_path))
@bot.event
async def on_ready() -> None:
if bot.user:
logging.getLogger("guardian").info(
"Logged in as %s (%s)", bot.user, bot.user.id
)
@bot.tree.error
async def on_app_command_error(
interaction: discord.Interaction, error: app_commands.AppCommandError
) -> None:
logging.getLogger("guardian").exception("Application command error", exc_info=error)
message = "Something went wrong while processing that command."
if isinstance(error, app_commands.CommandOnCooldown):
message = "That command is being used too quickly. Please try again."
if interaction.response.is_done():
await interaction.followup.send(message, ephemeral=True)
else:
await interaction.response.send_message(message, ephemeral=True)
bot.run(settings.token)