I'm very confused

I’m trying to make my bot loop statuses now, and everytime I fix all the errors literally nothing pops up in the console. I’ve waited around 10 minutes just in case. If you see any other errors/bugs in my code please tell me.
image
Here’s the code that makes it like that:

from discord import Client, Intents
import asyncio
import discord

intents = Intents.default()
intents.typing = False
intents.presences = False
intents.message_content = True

client = Client(intents=intents)

@client.event
async def on_message(message):
  if message.content == ("hi","hi!"):
    await message.reply("hi!")
    
@client.event
async def on_ready():
  await client.change_presence(status=discord.Status, activity=discord.Game('with your mom lol'))
  print("Status works! :D")
  await client.wait_until_ready()

statuses = ['status 1','status 2','status 3']

while not client.is_closed():
  async def status(status):
    status = random.choice(statuses)
    await client.change_presence(activity=discord.Game(name=status))
    await asyncio.sleep(0.5)
    print("Loop works! :O")

client.run("token")

You tried to stop and restart the repl?
Or you can try refreshing the repl in case your changed code have not yet been uploaded for the repl

I’ve tried both. Do you know what might be going on?

Would you mind sending us your repl link? I’m too lazy to search for your account lol

Okay, here: https://replit.com/@BobJingle/Bot#

Do you have any thoughts?

I am aware that random is defined. I don’t know how. I got this code off of a website. Do you know anyway to fix that?

You have some things that need to fix first, like, message.content == ("susman!") should be message.content == "susman!" . The way you are doing it, you’re comparing a string to a tuple.

You are runnning the flaskapp along with the bot, don’t do that (each of these processes do different things and need to be run independently of one another.). Create another file to run your FlaskApp like server.py and put your code there:

from flask import Flask
app = Flask(__name__)

@app.route('/')
def index():
  return "Bot up and running"

if __name__ == '__main__':
  app.run(host="0.0.0.0",debug=True,port=8080)

Another thing, this part is not necessary too: await client.wait_until_ready(), since the event on_ready() is only called after the client is already connected and ready (so that makes client.wait already true).

Last thing and the most important one:
Use the Secrets function, do not post your token in public.
You can find out more here: https://docs.replit.com/programming-ide/workspace-features/secrets

Obs.: when creating the new file remember to include import os in your main.py.

4 Likes

As far as python is concerned, that’s actually not a tuple. IIRC, python doesn’t count it as a tuple unless there’s more than one element, or it’s something like ("susman!",).

3 Likes

Damn you’re right, I’m so used to use more than one element that I actually forgot about the traling comma rule.

1 Like