Heimdallr/Heimdallr.py

73 lines
1.8 KiB
Python
Raw Normal View History

2022-07-21 21:27:47 +02:00
from os import getenv
from naff import (
Client,
Intents,
listen,
slash_command,
InteractionContext,
)
from naff.api.events.discord import MessageCreate
from naff.models.discord.embed import (
Embed,
EmbedAuthor,
EmbedField,
EmbedFooter,
)
from dotenv import load_dotenv
bot = Client(intents=Intents.ALL, debug_scope=387153131378835456)
@listen()
async def on_ready():
print(f"Bot '{bot.user.username}' is ready!")
print(f"This bot is owned by {bot.owner}")
@listen()
async def on_message_create(event: MessageCreate):
print(f"{event.message.author.username}: {event.message.content}")
@slash_command(name="ping", description="Ping the bot")
async def ping_command(ctx: InteractionContext):
ctx.ephemeral = True
await ctx.send("Pong!")
2022-07-21 21:27:47 +02:00
@slash_command(name="bot-info", description="Get info about the bot")
async def bot_info_command(ctx: InteractionContext):
await ctx.send(
ephemeral=True,
embed=Embed(
title=f"{bot.user.username}",
description=f"This bot is owned by {bot.owner}",
2022-07-21 21:27:47 +02:00
color=0x00FF00,
timestamp=bot.user.created_at,
url=bot.user.avatar.as_url(),
author=EmbedAuthor(
name=bot.user.username,
icon_url=bot.user.avatar.as_url(),
),
footer=EmbedFooter(
text=f"Created at {bot.user.created_at}",
icon_url=bot.user.avatar.as_url(),
),
fields=[
EmbedField(
name="**Extensions**",
value=f"{len(bot.extensions)}",
)
2022-07-21 21:27:47 +02:00
],
),
)
if __name__ == "__main__":
load_dotenv()
bot.load_extension("commands.quote")
bot.load_extension("commands.infractions")
bot.start(getenv("DISCORD_TOKEN"))