-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
51 lines (39 loc) · 1.3 KB
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import hikari
import lightbulb
import os
import sqlite3
from lightbulb import commands
from plugins import map
from utils.type_enforcer import TypeEnforcementError
with open('secrets/client', 'r') as client_file:
token = client_file.read().strip()
bot = lightbulb.BotApp(
token=token,
intents=hikari.Intents.ALL,
default_enabled_guilds=(),
logs={
"version": 1,
"incremental": True,
"loggers": {
"hikari": {"level": "INFO"},
"lightbulb": {"level": "DEBUG"},
},
},
prefix="=",
)
bot.add_plugin(map.plugin)
@bot.listen(lightbulb.CommandErrorEvent)
async def on_error(event: lightbulb.CommandErrorEvent) -> None:
if isinstance(event.exception, lightbulb.CommandInvocationError):
raise event.exception
if isinstance(event.exception, lightbulb.errors.CommandNotFound):
return
if isinstance(event.exception, TypeEnforcementError):
return
if isinstance(event.exception, lightbulb.CommandIsOnCooldown):
await event.context.respond(f"Command is on cooldown for {event.exception.retry_after} seconds", flags=hikari.MessageFlag.EPHEMERAL)
return
# Unwrap the exception to get the original cause
exception = event.exception.__cause__ or event.exception
raise exception
bot.run()