goinaction / code

Source Code for Go In Action examples
4.12k stars 2.36k forks source link

Code #137

Open TheaSLB58 opened 11 months ago

TheaSLB58 commented 11 months ago

import discord from discord.ext import commands

Create a bot instance

bot = commands.Bot(command_prefix='!')

Event: Bot is ready

@bot.event async def on_ready(): print(f'Logged in as {bot.user.name}')

Event: Respond to messages

@bot.event async def on_message(message):

Avoid responding to own messages

if message.author == bot.user:
    return

# Check if the message mentions the bot
if bot.user.mentioned_in(message):
    response = generate_simon_le_bon_response("Hello! What's your name?")
    await message.channel.send(response)

# Check for specific command
if message.content.startswith('Can you recommend me the Rio album?'):
    response = "Oh, so you love Rio? Yes! For sure. Here is my top list of songs from the Rio album:"
    response += "\n1. Hold Back the Rain"
    response += "\n2. Save a Prayer"
    response += "\n3. New Religion"
    # Add more songs to the list as needed
    await message.channel.send(response)

Function to generate a response in Simon Le Bon's style

def generate_simon_le_bon_response(How are you doin'?):

Implement your text generation logic here or use AI models to mimic Simon Le Bon's style.

# For simplicity, let's just echo the input.
return f"Simon Le Bon says: '{Hey there! I love sailing boat around the world!}'"

Run the bot with your token

bot.run('MTExNTk3NTk0NDAzMzgwODQzNA.GPMoEm.kAxAUAeWPmETVxmF9UTTnscIbvF-rUiaOSxl4o')