2023-08-01 02:39:20 +02:00
|
|
|
"""Bot base."""
|
2023-07-21 23:49:54 +02:00
|
|
|
|
|
|
|
import os
|
2023-07-23 23:57:41 +02:00
|
|
|
import nextcord
|
2023-07-25 03:39:17 +02:00
|
|
|
|
|
|
|
import chatbot
|
|
|
|
import embedder
|
2023-07-27 02:45:11 +02:00
|
|
|
import autochat
|
2023-08-01 02:39:20 +02:00
|
|
|
import accounts
|
2023-07-27 02:45:11 +02:00
|
|
|
import community
|
2023-08-01 02:39:20 +02:00
|
|
|
import credential_manager
|
2023-07-21 23:49:54 +02:00
|
|
|
|
|
|
|
from dotenv import load_dotenv
|
2023-07-23 23:57:41 +02:00
|
|
|
from nextcord.ext import commands
|
|
|
|
from nextcord import SlashOption
|
2023-07-21 23:49:54 +02:00
|
|
|
|
|
|
|
load_dotenv()
|
|
|
|
|
2023-08-01 02:39:20 +02:00
|
|
|
guild_ids = [int(guild_id) for guild_id in os.getenv('DISCORD_GUILD_IDS').split()]
|
|
|
|
|
2023-07-23 23:57:41 +02:00
|
|
|
bot = commands.Bot(
|
|
|
|
intents=nextcord.Intents.all(),
|
2023-08-01 02:39:20 +02:00
|
|
|
default_guild_ids=guild_ids # so slash commands work
|
2023-07-23 23:57:41 +02:00
|
|
|
)
|
2023-07-21 23:49:54 +02:00
|
|
|
|
|
|
|
@bot.event
|
|
|
|
async def on_ready():
|
|
|
|
print(f'Online as {bot.user} (ID: {bot.user.id})')
|
2023-07-23 23:57:41 +02:00
|
|
|
await bot.change_presence(activity=nextcord.Game(name='with fire'))
|
2023-07-21 23:49:54 +02:00
|
|
|
|
|
|
|
@bot.event
|
|
|
|
async def on_message(message):
|
2023-07-27 02:45:11 +02:00
|
|
|
if message.author.bot: # block bots
|
|
|
|
return
|
|
|
|
|
|
|
|
await autochat.process(message)
|
2023-07-21 23:49:54 +02:00
|
|
|
await bot.process_commands(message)
|
|
|
|
|
2023-08-01 02:39:20 +02:00
|
|
|
# @bot.slash_command(description='Chat with AI')
|
|
|
|
# async def chat(interaction: nextcord.Interaction,
|
|
|
|
# prompt: str = SlashOption(description='AI Prompt', required=True)
|
|
|
|
# ):
|
|
|
|
# await chatbot.respond(interaction, prompt)
|
2023-07-25 03:39:17 +02:00
|
|
|
|
|
|
|
@bot.slash_command(description='Sets your DMs up, so you can write the bot.')
|
2023-08-01 02:39:20 +02:00
|
|
|
async def dm_setup(interaction: nextcord.Interaction):
|
2023-07-25 03:39:17 +02:00
|
|
|
try:
|
|
|
|
await interaction.user.create_dm()
|
|
|
|
await embedder.info(interaction.user.dm_channel, 'Hello!')
|
|
|
|
except nextcord.Forbidden:
|
2023-07-27 02:45:11 +02:00
|
|
|
await embedder.error(interaction, text="""Please open this server\'s options,
|
|
|
|
go to `Privacy Settings` and enable `Direct Messages` as well as `Message Requests`.""")
|
2023-08-01 02:39:20 +02:00
|
|
|
|
|
|
|
else:
|
2023-07-25 03:39:17 +02:00
|
|
|
await embedder.ok(interaction, 'Great, DMs are set up successfully!')
|
|
|
|
|
2023-08-01 02:39:20 +02:00
|
|
|
@bot.slash_command(description='Create your account and get your API key.')
|
2023-07-27 02:45:11 +02:00
|
|
|
async def credentials(interaction: nextcord.Interaction):
|
2023-08-01 02:39:20 +02:00
|
|
|
return await credential_manager.get_credentials(interaction)
|
2023-07-23 23:57:41 +02:00
|
|
|
|
2023-07-27 02:45:11 +02:00
|
|
|
@bot.slash_command(description='Leaderboard.')
|
|
|
|
async def leaderboard(interaction: nextcord.Interaction):
|
2023-08-01 02:39:20 +02:00
|
|
|
return await community.leaderboard(interaction)
|
|
|
|
|
|
|
|
@bot.slash_command(description='Get info and stats about your NovaAI API account.')
|
|
|
|
async def account(interaction: nextcord.Interaction):
|
|
|
|
return await accounts.get_account(interaction)
|
2023-07-23 23:57:41 +02:00
|
|
|
|
2023-07-21 23:49:54 +02:00
|
|
|
bot.run(os.getenv('DISCORD_TOKEN'))
|