Home python Do not run a bot Discord

Do not run a bot Discord

Author

Date

Category

ID:

import discord
client = discord.Client ()
@ client.event
async def on_ready ():
 print ( 'We have logged in as')
@ client.event
async def on_message (message):
 if message.author == client.user:
  return
if message.content.startswith ( '$ hello'):
  await message.channel.send ( 'Hello!')
client.run ( 'MY TOKEN')

Error:

Traceback (most recent call last):
File “C: \ Users \ kent \ AppData \ Local \ Programs \ Python \ Python38-32 \ lib \ site-packages \ discord \ http.py”, line 256, in static_login
data = await self.request (Route ( ‘GET’, ‘/ users / @ me’))
File “C: \ Users \ kent \ AppData \ Local \ Programs \ Python \ Python38-32 \ lib \ site-packages \ discord \ http.py”, line 220, in request
raise HTTPException (r, data)
discord.errors.HTTPException: 401 UNAUTHORIZED (error code: 0): 401: Unauthorized

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “c: /Users/kent/Desktop/bot.py”, line 18, in
client.run ( ‘AjcgZJsBn1KwB31_tv-02RSluNVlU-l1’)
File “C: \ Users \ kent \ AppData \ Local \ Programs \ Python \ Python38-32 \ lib \ site-packages \ discord \ client.py”, line 640, in run
return future.result ()
File “C: \ Users \ kent \ AppData \ Local \ Programs \ Python \ Python38-32 \ lib \ site-packages \ discord \ client.py”, line 621, in runner
await self.start (* args, ** kwargs)
File “C: \ Users \ kent \ AppData \ Local \ Programs \ Python \ Python38-32 \ lib \ site-packages \ discord \ client.py”, line 584, in start
await self.login (* args, bot = bot)
File “C: \ Users \ kent \ AppData \ Local \ Programs \ Python \ Python38-32 \ lib \ site-packages \ discord \ client.py”, line 442, in login
await self.http.static_login (token.strip (), bot = bot)
File “C: \ Users \ kent \ AppData \ Local \ Programs \ Python \ Python38-32 \ lib \ site-packages \ discord \ http.py”, line 260, in static_login
raise LoginFailure ( ‘Improper token has been passed.’) from exc
discord.errors.LoginFailure: Improper token has been passed.
Exception ignored in:
Traceback (most recent call last):
File “C: \ Users \ kent \ AppData \ Local \ Programs \ Python \ Python38-32 \ lib \ asyncio \ proactor_events.py”, line 116, in del
self.close ()
File “C: \ Users \ kent \ AppData \ Local \ Programs \ Python \ Python38-32 \ lib \ asyncio \ proactor_events.py”, line 108, in close
self._loop.call_soon (self._call_connection_lost, None)
File “C: \ Users \ kent \ AppData \ Local \ Programs \ Python \ Python38-32 \ lib \ asyncio \ base_events.py”, line 715, in call_soon
self._check_closed ()
File “C: \ Users \ kent \ AppData \ Local \ Programs \ Python \ Python38-32 \ lib \ asyncio \ base_events.py”, line 508, in _check_closed
raise RuntimeError ( ‘Event loop is closed’)
RuntimeError: Event loop is closed

I wanted to create a bot discord (they are even for the documentation)


Answer 1, Authority 100%

import discord # Library
from discord.ext import commands
client = commands.Bot (command_prefix = 'prefix') # eto_prefiks_bota
@ client.event
async def on_ready ():
  print ( 'Bot is online')
#hello
@ Client.command ()
async def hello (ctx):
  await ctx.send (f '{member} Hello!')
client.run ( 'token bot')

I’m sorry that is not explained


Answer 2, authority 50%

  1. There is no argument to command_prefix in discord.Client:
client = commands.Bot (command_prefix = 'Prefix')
  1. invalid token bot likely.

Answer 3

client = commands.Bot (command_prefix = ‘/’) Replace with this line, and and if you want to cause any kind of function (for example: function test) write in a chat / test run and function

.


Answer 4

You have not added any token bot, you press the button for a token, and inserted into the brackets team run, in quotes but it is better to make a separate variable

It may also be that you did not authorize the bot on the server it is done using this link https://discordapp.com/oauth2/authorize?&amp ;client_id= {id_client} & amp; scope = Bot & amp; permissions = 8
Instead of ID Client insert your value it is in the Home Information tab

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions