79 lines
2.0 KiB
Python
79 lines
2.0 KiB
Python
|
import re
|
||
|
from naff import (
|
||
|
Client,
|
||
|
Intents,
|
||
|
listen,
|
||
|
slash_command,
|
||
|
InteractionContext,
|
||
|
slash_option,
|
||
|
OptionTypes,
|
||
|
)
|
||
|
from naff.api.events.discord import MessageCreate
|
||
|
from naff.models.discord.enums import ButtonStyles, Permissions
|
||
|
from naff.models.discord.embed import (
|
||
|
Embed,
|
||
|
EmbedAttachment,
|
||
|
EmbedAuthor,
|
||
|
EmbedField,
|
||
|
EmbedFooter,
|
||
|
EmbedProvider,
|
||
|
)
|
||
|
from naff.models.discord.components import ActionRow, Button, Select, SelectOption
|
||
|
|
||
|
from dotenv import load_dotenv
|
||
|
from os import getenv
|
||
|
|
||
|
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!")
|
||
|
|
||
|
@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}",
|
||
|
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)}",
|
||
|
)
|
||
|
]
|
||
|
),
|
||
|
)
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
load_dotenv()
|
||
|
bot.load_extension("commands.quote")
|
||
|
bot.load_extension("commands.infractions")
|
||
|
bot.start(getenv("DISCORD_TOKEN"))
|
||
|
|