import discord from discord import app_commands from NarratorAi import setScene, setItem, setRollDice import random guild_id = 954201387770736751 intents = discord.Intents.default() intents.message_content = True client = discord.Client(intents=intents) tree = app_commands.CommandTree(client) @tree.command(name="roll_die", description="Ask NARC to roll dice for you with flair.", guild=discord.Object(id=guild_id) ) async def roll_die(interaction, num_sides: str): channel = client.get_channel(interaction.channel_id) person = interaction.user.display_name result = random.randint(1, int(num_sides)) await interaction.response.defer(ephemeral=False, thinking=False) scene = await setRollDice(person, num_sides, result) await channel.send(f"*{scene}*") await interaction.delete_original_response() @tree.command(name="give_item", description="Ask NARC for an item.", guild=discord.Object(id=guild_id) ) async def give_item(interaction, item: str): channel = client.get_channel(interaction.channel_id) person = interaction.user.display_name await interaction.response.defer(ephemeral=False, thinking=False) scene = await setItem(item, person) await channel.send(f"*{scene}*") await interaction.delete_original_response() @tree.command(name="set_scene", description="Provide a prompt for the narrator to set a scene", guild=discord.Object(id=guild_id) ) async def set_scene(interaction, prompt: str): channel = client.get_channel(interaction.channel_id) await interaction.response.defer(ephemeral=False, thinking=False) scene = await setScene(prompt=prompt) await channel.send(f"*{scene}*") await interaction.delete_original_response() @tree.command(name="narrate", description="This is a command to narrate", guild=discord.Object(id=guild_id)) async def narrate(interaction, text: str): channel = client.get_channel(interaction.channel_id) await interaction.response.defer(ephemeral=False, thinking=False) await channel.send(f"*{text}*") await interaction.delete_original_response() @client.event async def on_ready(): await tree.sync(guild=discord.Object(id=guild_id)) print(f'We have logged in as {client.user}') @client.event async def on_message(message): if message.author == client.user: return if message.content.startswith('$hello'): await message.channel.send('Hello!') token = "MTMyNzcxNDM3MTEyMzgxMDMwNA.GwLjEd.quGP0FA5gHRe1xLyuYq-ANuJ5cRuRQ6dhJiojI" client.run(token)