Closed nshout closed 3 years ago
Please provide your code. on_ready()
works perfectly fine for me.
You can also try the development branch.
bot = commands.Bot(prefix)
@bot.event
async def on_ready():
print("Logged in")
print(f"Logged into {bot.user}")
try:
print("Logging in...")
bot.run(token)
except discord.errors.LoginFailure:
print("Invalid Token")
A. You never started the bot.
B. That's not how you pass the prefix.
Well I do have a variable for the prefix.
import json
import discord
from discord.ext import commands
with open('./config.json') as f:
config = json.load(f)
token = config.get('token')
prefix = config.get('prefix')
bot = commands.Bot(prefix)
@bot.event
async def on_ready():
print("Logged in")
print(f"Logged into {bot.user}")
@bot.listen()
async def on_message(message):
print(message.content)
@bot.command(name='test', usage="", description = "test")
async def test(ctx, user_id):
await ctx.message.delete()
user = await bot.fetch_user(user_id)
print(f"Used {prefix}test")
print(user.avatar_url)
try:
print("Logging in...")
bot.run(token)
except discord.errors.LoginFailure:
print("Invalid Token")
It's bot = commands.Bot(prefix=prefix)
.
Also, what discord.py-self version are you using?
The latest development branch.
Well actually, after reinstalling and testing with the development branch, it wasn't able to login into any tokens. Then using pip to install it (discord.py-self 1.8.1) got it back to log into tokens, but without the fetch_user function which I need as well.
On the development version, on_ready may take longer to trigger because it "subscribes" (fetches the member sidebar) of all guilds with less than 12k members by default iirc. You can disable this by passing guild_subscription_options = GuildSubscriptionOptions.off()
when initializing bot
, and then only subscribe the guilds you need with await guild.subscribe()
.
I use this library in a project together with a friend, and he also had this problem, the solution was to install Python 3.9 from the Windows Store, with that, the problem was solved.
On the development version, on_ready may take longer to trigger because it "subscribes" (fetches the member sidebar) of all guilds with less than 12k members by default iirc. You can disable this by passing
guild_subscription_options = GuildSubscriptionOptions.off()
when initializingbot
, and then only subscribe the guilds you need withawait guild.subscribe()
.
Thanks a lot, I got it to work that way.
I use this library in a project together with a friend, and he also had this problem, the solution was to install Python 3.9 from the Windows Store, with that, the problem was solved.
tf lol How did that help
The creature probably has some malware on the PC that damages the AppData folder
Em qua., 4 de ago. de 2021 às 13:56, dolfies @.***> escreveu:
I use this library in a project together with a friend, and he also had this problem, the solution was to install Python 3.9 from the Windows Store, with that, the problem was solved.
tf lol How did that help
— You are receiving this because you commented.
Basically on_ready doesn't function as it should. If you have something like, print(f"Logged into {bot.user}"). That would never be printed.