/ai-discord-bot

a simple discord bot replying using AI

Primary LanguagePython

ai-discord-bot

Discord bot in Python that makes a request to an external API server using a REST API and returns the response to Discord

Use the asyncio library to schedule tasks or set up background tasks. For example:

import asyncio

async def my_background_task():
    await client.wait_until_ready()
    counter = 0
    channel = client.get_channel(1234567890) # Replace with the ID of the channel you want to send the message to
    while not client.is_closed():
        counter += 1
        await channel.send(counter)
        await asyncio.sleep(60) # Send the message every 60 seconds

client.loop.create_task(my_background_task())

Use the argparse library to parse command-line arguments. This can be useful if you want to pass in variables to your bot's commands. For example:

import argparse

parser = argparse.ArgumentParser(description='My Discord Bot')
parser.add_argument('--variable', type=str, required=True, help='A variable that the bot should use')
args = parser.parse_args()

@client.command()
async def my_command(ctx):
    # Use the variable passed in through the command-line argument
    await ctx.send(args.variable)