-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
47 lines (35 loc) · 1.21 KB
/
Copy pathmain.py
File metadata and controls
47 lines (35 loc) · 1.21 KB
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
import logging
import hikari
import lightbulb
from core.config import Config, config
bot = hikari.GatewayBot(config.abot.discord.bot_token)
client = lightbulb.client_from_app(bot)
logger = logging.getLogger(__name__)
bot.subscribe(hikari.StoppingEvent, client.stop)
@bot.listen(hikari.StartingEvent)
async def on_starting(_: hikari.StartingEvent):
client.di.registry_for(lightbulb.di.Contexts.DEFAULT).register_value(Config, config)
await client.load_extensions("commands.ping", "commands.account")
# Start the bot - make sure commands are synced properly
await client.start()
@bot.listen(hikari.StartedEvent)
async def on_started(_: hikari.StartedEvent):
await bot.update_presence(
activity=hikari.Activity(
type=hikari.ActivityType.COMPETING,
name="Wayhaven banking at aGroup",
)
)
@client.error_handler
async def global_error_handler(
exc: lightbulb.exceptions.ExecutionPipelineFailedException,
):
ctx = exc.context
cause = exc.__cause__
message = f"{type(cause).__name__} in /{ctx.command_data.qualified_name} invoked by {ctx.user.username}: {cause}"
match cause:
case _:
await ctx.respond(f"[ERROR] {cause}")
logger.warning(message)
return True
bot.run()