Traceback most recent call lash replit discord py token
Я недавно начал работать с discord.py, и часто натыкался на такую ошибку, не могу понять почему она появляется
import discord
import asyncio
import aiohttp
from keep_alive import keep_alive
import os
from discord.ext import commands
from discord import app_commands
import os
import json
from func import *
def get_prefix(bot, message):
with open("prefix.json", "r") as f:
prefix = json.load(f)
return prefix[str(message.guild.id)]
intents = discord.Intents().all()
bot = commands.Bot(command_prefix=get_prefix, intents = intents)
bot.remove_command('help')
bot.remove_command('setprefix')
@bot.event
async def on_member_join(member):
mutes = load_json("jsons/mutes.json")
if str(member.id) in mutes:
role = discord.utils.get(member.guild.roles, id=...) # mute role id
await member.add_roles(role)
@bot.command()
async def verify_account(ctx, arg):
async with aiohttp.ClientSession() as session:
await ctx.send(f":warning:В разработке:warning: ")
@bot.event
async def on_ready():
while True:
game = discord.Game("Роблокс.Рф")
await bot.change_presence(status=discord.Status.idle, activity=game)
@bot.command()
async def info_accounts(ctx, arg):
async with aiohttp.ClientSession() as session:
request = await session.get(f'http://all-roblox-parody.kchessub.beget.tech/accounts/{arg}ach.json') # Make a request
request2 = await session.get(f'http://all-roblox-parody.kchessub.beget.tech/accounts/{arg}.json')
dogjson = await request.json() # Convert it to a JSON dictionary
dogjson2 = await request2.json() # Convert it to a JSON dictionary
embed = discord.Embed(title=arg, color=0xd6c029) # Create embed
embed.add_field(name="Монеты", value=dogjson[arg]['Money'], inline=True)
embed.add_field(name="Буксы", value=dogjson[arg]['Redix'], inline=True)
embed.set_thumbnail(url=f"http://all-roblox-parody.kchessub.beget.tech/{dogjson2[arg]['Avatar']}")
embed.add_field(name= "Топ", value=dogjson[arg]['TOP_Leader'], inline=True)
await ctx.send(embed=embed) # Send the embed
@bot.event
async def on_guild_join(guild):
with open("prefix.json", "r") as f:
prefix = json.load(f)
prefix[str(guild.id)] = "/"
with open("prefix.json", "w") as f:
json.dump(prefix, f, indent=4)
@bot.event
async def on_guild_remove(guild):
with open("prefix.json", "r") as f:
prefix = json.load(f)
prefix.pop(str(guild.id))
with open("prefix.json", "w") as f:
json.dump(prefix, f, indent=4)
class Buttons(discord.ui.View):
def __init__(self, *, timeout=180):
super().__init__(timeout=timeout)
@bot.command()
async def help(ctx):
embed=discord.Embed(title="Пародия Роблокс.Рф", url="http://all-roblox-parody.kchessub.beget.tech/", description="Официальный Бот Пародии Роблокс.Рф", color=0xd6c029)
embed.set_author(name="Parody-Роблокс.Рф", icon_url="https://роблокс.рф/favicon-32x32.png")
embed.add_field(name="**Поменять префикс**", value="*setprefix*", inline=True)
embed.add_field(name="**Помощь**", value="*help*", inline=True)
embed.add_field(name="**Найти пользователя на Пародии**", value="*info_accounts* **``Ник``**", inline=False)
await ctx.send(embed=embed )
@bot.command()
async def ping(ctx):
await ctx.send("pong")
embed.add_field(name="**Помощь**", value="*/help*", inline=True)
await ctx.send(f"*Бот* был добавлен на сервер **{ctx.guild.name}**", view=view )
@bot.command(name = "setprefix", brief="Новый prefix", usage="setprefix")
@commands.has_permissions(administrator = True)
async def setprefix(ctx, new: str):
with open("prefix.json", "r") as f:
prefix = json.load(f)
prefix[str(ctx.guild.id)] = new
with open("prefix.json", "w") as f:
json.dump(prefix, f, indent=4)
await ctx.send(f"Новый **prefix** `{new}`")
@bot.command()
async def load(ctx, extension):
extension = extension.lower()
bot.load_extension(f'cogs.{extension}')
await ctx.send(f'{extension} loaded')
@bot.command()
async def unload(ctx, extension):
extension = extension.lower()
bot.unload_extension(f'cogs.{extension}')
await ctx.send(f'{extension} unloaded')
keep_alive()
bot.run("TOKEN")
Cама ошибка
python3 main.py
2022-11-21 12:50:49 INFO discord.client logging in using static token
* Serving Flask app ''
* Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:8080
* Running on http://172.31.128.2:8080
Press CTRL+C to quit
Traceback (most recent call last):
File "/home/runner/EvilSeagreenProcedure/venv/lib/python3.10/site-packages/discord/http.py", line 801, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "/home/runner/EvilSeagreenProcedure/venv/lib/python3.10/site-packages/discord/http.py", line 744, in request
raise HTTPException(response, 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 "/home/runner/EvilSeagreenProcedure/main.py", line 130, in <module>
bot.run("TOKEN")
File "/home/runner/EvilSeagreenProcedure/venv/lib/python3.10/site-packages/discord/client.py", line 828, in run
asyncio.run(runner())
File "/nix/store/7c2d4f13a93vf8xx548czn0v0hsgrrkv-python3-3.10.0/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/nix/store/7c2d4f13a93vf8xx548czn0v0hsgrrkv-python3-3.10.0/lib/python3.10/asyncio/base_events.py", line 641, in run_until_complete
return future.result()
File "/home/runner/EvilSeagreenProcedure/venv/lib/python3.10/site-packages/discord/client.py", line 817, in runner
await self.start(token, reconnect=reconnect)
File "/home/runner/EvilSeagreenProcedure/venv/lib/python3.10/site-packages/discord/client.py", line 745, in start
await self.login(token)
File "/home/runner/EvilSeagreenProcedure/venv/lib/python3.10/site-packages/discord/client.py", line 580, in login
data = await self.http.static_login(token)
File "/home/runner/EvilSeagreenProcedure/venv/lib/python3.10/site-packages/discord/http.py", line 805, in static_login
raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.
172.31.128.1 - - [21/Nov/2022 12:50:50] "GET / HTTP/1.1" 200 -
