0

This is my first experience with python, but this is the first real issue I seem to have run into/wanted to fix. I am creating a silly discord bot that will periodically "cast a spell"/send a message in chat, but I am starting to add lots of sentences to my sentence variable bank and it is becoming a bit of a mess to look at and read. I am trying to see if I am able to condense my sentence bank into a .txt file and pull from there instead of writing out each sentence inside my script.

import asyncio
import random
import discord



intents = discord.Intents.all()
client = discord.Client(command_prefix='!', intents=intents)
 
sentences = ["FIREBALL!!!!! https://imgur.com/y7iIPso", "Big Buttify!", "I cast Undickify!"]
sentences2 = ["HAHA JUST KIDDING NO POTION FOR YOU", "Okay u may have a potion hehe!"]

activity = discord.Game(name="Casting!")

@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))
    await client.change_presence(activity=discord.Game(name="with my potions ")) #4th link
    while True:
        await asyncio.sleep(60 * 60) 
        sentence = random.choice(sentences)
        channel = client.get_channel(channelID)

        
@client.event
async def on_message(message):
    if message.author == client.user:
        return
 
    if message.content.startswith('i summon the wizard'):
        await message.channel.send('✨HUZZAH, I HAVE ARRIVED✨')
    
    if message.content.startswith('I summon the Wizard'):
        await message.channel.send('✨HUZZAH, I HAVE ARRIVED✨')

    if "favorite spell" in message.content.lower():
            await message.channel.send('FIREBALL!!!')
            await message.channel.send('https://imgur.com/y7iIPso')  

    if "burger" in message.content.lower():
            await message.channel.send('Instead of a burger, maybe you would like a fresh potion?')

    if "potion" in message.content.lower():
            sentence = random.choice(sentences2)
            await message.channel.send(sentence)

    if message.content.startswith('yo wizard'):
            await message.channel.send('What do you need?')
    
    if "zaza" in message.content.lower():
            await message.channel.send('Yuhhhhh for sure')
            await message.channel.send('https://imgur.com/dBha9pr')

    if "lizard wizard" in message.content.lower():
            await message.channel.send('https://soundcloud.com/drunkondamic/lizard-wizard?si=0b34ac7dabff4be7a2842c605fe45d11&utm_source=clipboard&utm_medium=text&utm_campaign=social_sharing')

    if "mark" in message.content.lower():
        await message.add_reaction('‍♂️')
        await message.add_reaction('‍♀️')

    if message.content.startswith('how did you become a wizard'):
        await message.channel.send('awhileagoplaceholder')


 
client.run('TOKEN')

I am currently using these 2 instances of sentence:

if "potion" in message.content.lower():
        sentence = random.choice(sentences2)
        await message.channel.send(sentence)


    await asyncio.sleep(60 * 60)
    sentence = random.choice(sentences)
    channel = client.get_channel(channelID)

Both of these have functioning variables in sentences and sentences2 with some stuff inside to grab from. I am unsure what code to add and where to place my .txt file to be grabbed from.

unhben
  • 1
  • 1

0 Answers0