Hello this is probably a basic question. What I am trying to do is organise my small bot project. Right now I have 3 files. One bot "settings" script and 2 "game" scripts. The bot "settings" script is the one I am using to initialize my bot and the other 2 scripts are just 2 simple games which are waiting for some user to type $game or $game1. The thing is I don't know where to put client.run() inside this structure. If I put it on the bot then only the message of the bot will work and the games won't run if the user presses game or game1. If I put it in either game then only those games will work and my bot hello message won't work.
I read in the documentation that you must put the client.run() on the end of the script but what happens if you split your program into seperate files?
Here is my current structure:
bot.py:
import discord
import asyncio
from casinogames import on_message
from casinotestgames import on_message"""
DISCORD BOT SETTINGS
"""
client = discord.Client()Startup Message
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print ('Bot working properly')
print('------')
casinogames.py:
import discord
import random
import asyncio
import collections
from random import randintclient = discord.Client()
game here
casinotestgames.py:
Same as above with the client.run() in the end.
With this configuration when I run bot the prints won't show up but the game on casinotestgames will run. If I put the client.run() on casinogames then that game will run. What I want is when I run the bot is to be able to "listen" to all 3 scripts. How would I go about doing that?
See the cogs example.
Just came to answer that I found a solution by doing
from casinogames import *
and it works. Your solution seems a lot better though will look into it thanks for the input!
Most helpful comment
See the cogs example.