DISCORD: My Discord self bot takes too much time to load

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



DISCORD: My Discord self bot takes too much time to load



I coded a Discord self bot that sends a picture that acts like a global emote without nitro.



Example:



me: !ok



me(bot): ok.png



But when I edit my code and add more pictures and stuff and I load it again (By doing "mybot.py" in cmd) it takes around 5 minutes to finally print "Self bot working." in the cmd window... what is the problem? I don't think it's a problem with my code because it's working overall. I'm using python 3.6 and windows.


import discord
import asyncio

client = discord.Client()

@client.event
async def on_ready():
print("nonitro Loaded.n")

@client.event
async def on_message(message):
if message.author == client.user:
if(message.content.startswith("!ok")):
emo = "./img/ok.png"
async for msg in client.logs_from(message.channel,limit=1):
await client.delete_message(msg)
await client.send_file(message.channel, emo)

if message.author == client.user:
if(message.content.startswith("!xd")):
emo = "./img/xd.png"
async for msg in client.logs_from(message.channel,limit=1):
await client.delete_message(msg)
await client.send_file(message.channel, emo)

if message.author == client.user:
if(message.content.startswith("!coffee")):
emo = "./img/coffee.png"
async for msg in client.logs_from(message.channel,limit=1):
await client.delete_message(msg)
await client.send_file(message.channel, emo)

if message.author == client.user:
if(message.content.startswith("!thonk")):
emo = "./img/thonk.png"
async for msg in client.logs_from(message.channel,limit=1):
await client.delete_message(msg)
await client.send_file(message.channel, emo)

if message.author == client.user:
if(message.content.startswith("!like")):
emo = "./img/like.png"
async for msg in client.logs_from(message.channel,limit=1):
await client.delete_message(msg)
await client.send_file(message.channel, emo)

if message.author == client.user:
if(message.content.startswith("!kek")):
emo = "./img/kek.png"
async for msg in client.logs_from(message.channel,limit=1):
await client.delete_message(msg)
await client.send_file(message.channel, emo)

if message.author == client.user:
if(message.content.startswith("!bobross")):
emo = "./img/bobross.png"
async for msg in client.logs_from(message.channel,limit=1):
await client.delete_message(msg)
await client.send_file(message.channel, emo)

if message.author == client.user:
if(message.content.startswith("!likethis")):
emo = "./img/likethis.png"
async for msg in client.logs_from(message.channel,limit=1):
await client.delete_message(msg)
await client.send_file(message.channel, emo)

client.run("my token", bot=False)





Alright I will add in the code!
– lemun
Aug 8 at 18:06





Please post all code as formatted text in the body of your question. Your linked page could disappear suddenly, or be blocked at peoples workplaces.
– Patrick Haugh
Aug 8 at 18:10





Why are you passing bot=False to run? Self bots are against the Discord terms of service, and they're pretty good at detecting them. It's very possible that they've limited your connection in some way. I would recommend switching to a regular token setup, and seeing if that improve the performance.
– Patrick Haugh
Aug 8 at 18:14


bot=False


run





No, you don't understand my problem. it's not that the imgs take time to load or something... Running the python file in cmd takes so much to print that it's ready and working...
– lemun
Aug 8 at 18:15





and also, the whole point of this is that it's a self bot...
– lemun
Aug 8 at 18:16




1 Answer
1



You don't need to pull logs from the chat in order to delete that one message, you can just do


@client.event
async def on_message(message):
if message.author.id == "your id" and "!ok" == message.content:
await client.delete_message(message)
await client.send_file(message.channel,"path/to/file")
return

client.run("token",bot=False)



Which will send message only if the content of the message is !ok and if its your id thats saying !ok






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS