A
A
aikytr2021-07-18 20:00:46
Python
aikytr, 2021-07-18 20:00:46

What to do when setting up a python discord bot if an error pops up?

Mistake

Traceback (most recent call last):
File "/Users/имя компьютера/Desktop/testbot/bot.py", line 12, in
client.run('Токен')
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/client.py", line 692, in run
loop = self.loop
AttributeError: 'str' object has no attribute 'loop'

The code
import discord

class MyClient(discord.Client):
  async def on_ready(self):
    print('Logged on as{0}!'.format(self.user))

  async def on_message(self, message):
    print('Message from {0.author}: {0.content}'.format(message))


client = MyClient
client.run('ТОКЕН')

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
soremix, 2021-07-18
@SoreMix

client = MyClient()

S
StrangeDylan, 2021-07-19
@StrangeDylan

import discord
from discord.ext import commands

Bot = commands.Bot()

class MyClient(discord.Client):
  async def on_ready(self):
    print('Logged on as{0}!'.format(self.user))

  async def on_message(self, message):
    print('Message from {0.author}: {0.content}'.format(message))


Bot.run('ТОКЕН')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question