#đź”’ Help with Discord Webhook Integration and Username Checker Script
112 messages · Page 1 of 1 (latest)
@terse walrus
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Hey everyone!
I’ve been working on a Python script to check the availability of Minecraft usernames, and if a username is available, it pings me in a Discord channel. I’m using a Discord webhook to post the results of the checks.
Here’s a brief overview of the issue I’m facing:
Problem:
The script works as expected when checking usernames, but the message is not being sent to Discord, even though the script appears to execute without errors.
The webhook integration doesn’t seem to send messages or alerts as it should.
What I’ve Tried:
I’ve confirmed that the webhook URL is correct.
The check for username availability works, and the script logs the correct output for available/unavailable usernames in the console.
The issue seems to be related to the communication with Discord, as there is no error but no message is sent either.
Here's the pastebin link for the source code for the discord integration: https://pastebin.com/Ue8SneS0
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
What is userid used for
to ping me when it finds an available name!
And why is it “hidden for privacy”
Oh ok
Just don't want people friending it lols
Oh wait it seemed to work, It just doesn't do a live update.
It only sends the message when it's finished running the entire script and checking every name.
@terse walrus This is vibecoded right?
I'm not sure about 'vibecoded.' I wrote this script myself, but if you're referring to a specific style or method, I would love to know more!
Vibecoded is when code is written by ai
Ohhh, no I wrote it myself and my friend tweaked a little bit of the code.
for username in usernames:
if username_is_available(username):
You used function which is not in the code
This looks very AI ngl
I don't know what it means to look AI, I can ask my friend if she used AI? because i only did the first bit of the code.
Yeah ask
Cause idk using non-existing function is very ai job
Can i see the original script?
Hey @terse walrus!
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
Also i suggest using file to store the usernames
Would be way easier to check a ton of usernames
lemme re send that
ill upload to pastebin
discord does wacky shit with markdown
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
AI did very bad here, it removed the check account system through mojang API and included nonexistent function
Let me see
yeah thats not my doing lol
Does this work?
it works yes
But only sends the message after the entire script has ran.
And I'm looking for it to send a message everytime it checks a name.
I think it actually does send
it does but only after it has checked every name in the txt
so you wanna make a list of existing minecraft accounts?
and with it containing like 20 thousand names, it is very painful to scroll up past all the existing names.
i wanna do the opposite
oh ok
make a list of non existent names
lemme see what i can do
okay awesome
can i remove comments from the code?
honestly it doesnt even need to send the unavailable names
I do not recommend sending to discord due to message length and rate limit limitating
It will confuse me but yes sure
it sleeps for 1 second every time it checks
Sleep to avoid hitting rate limits or appearing like a bot
time.sleep(1)
can discord stop formatting my messages
jeez
but yea it would be great if you could help with this
e.g. it can only post message length <= 2000
yeah i know
# you can avoid formatting
!d discord.utils.escape_markdown
discord.utils.escape_markdown(text, *, as_needed=False, ignore_links=True)```
A helper function that escapes Discord’s markdown.
i want it to either update live, or only send the available ones, which will only be like 1/1000 names
or this if you use discord.py / installed discord.py
import requests
import time
from colorama import Fore, Style, init
init()
WEBHOOK_URL = ""
USER_ID = ""
def check_username(username):
url = f"https://api.mojang.com/users/profiles/minecraft/{username}"
try:
response = requests.get(url)
return response.status_code == 204
except requests.exceptions.RequestException as e:
print(f"{Fore.RED}Error while checking username '{username}': {e}{Style.RESET_ALL}")
return False
def send_to_discord(message):
data = {"content": message}
try:
response = requests.post(WEBHOOK_URL, json=data)
if response.status_code == 204:
print(f"{Fore.GREEN}Message sent successfully to Discord!{Style.RESET_ALL}")
else:
print(f"{Fore.RED}Failed to send message. Status code: {response.status_code} Response: {response.text}{Style.RESET_ALL}")
except Exception as e:
print(f"{Fore.RED}Error while sending message to Discord: {e}{Style.RESET_ALL}")
def check_and_send_usernames(filename):
with open(filename, 'r') as file:
usernames = file.readlines()
for username in usernames:
username = username.strip()
print(f"{Fore.YELLOW}Checking username: {username}...{Style.RESET_ALL}")
if check_username(username):
print(f"{Fore.GREEN}Username '{username}' is available!{Style.RESET_ALL}")
message = f"<@{USER_ID}> Username '{username}' is available!"
send_to_discord(message)
else:
print(f"{Fore.RED}Username '{username}' is not available.{Style.RESET_ALL}")
time.sleep(1)
if __name__ == "__main__":
check_and_send_usernames("usernames.txt")
Should work
I very simplified this
oh where to?
wait im so stupid
i forgot to put my userid and webhook url back in there
dohhh
Should it also save them into a file?
doesnt need to if its sending to discord or somewhere else
works very well, but do you know how to do a live update?
sends each message individually so i can bulk search without running into the message limit
Gonna try something that is faster
import requests
import time
from colorama import Fore, Style, init
init()
WEBHOOK_URL = ""
USER_ID = ""
def check_username(username):
url = f"https://api.mojang.com/users/profiles/minecraft/{username}"
try:
response = requests.get(url)
return response.status_code == 204
except:
return False
def send_to_discord(message):
try:
response = requests.post(WEBHOOK_URL, json={"content": message})
if response.status_code == 204:
print(f"{Fore.GREEN}Sent to Discord: {message}{Style.RESET_ALL}")
else:
print(f"{Fore.RED}Failed to send: {response.status_code} {response.text}{Style.RESET_ALL}")
except Exception as e:
print(f"{Fore.RED}Error sending to Discord: {e}{Style.RESET_ALL}")
def check_and_send_usernames(filename):
with open(filename, 'r') as file:
usernames = file.readlines()
for username in usernames:
username = username.strip()
print(f"{Fore.YELLOW}Checking: {username}{Style.RESET_ALL}")
if check_username(username):
print(f"{Fore.GREEN}Available: {username}{Style.RESET_ALL}")
send_to_discord(f"<@{USER_ID}> Username '{username}' is available!")
else:
print(f"{Fore.RED}Unavailable: {username}{Style.RESET_ALL}")
time.sleep(1)
if __name__ == "__main__":
check_and_send_usernames("usernames.txt")
faster? go for it
Using proxies so you dont get ratelimited is nice
You can use OpenBullet for that
Just make config yourself
yea
Tbf idk the rate limit
But I can make you decide on amount of worker you used for simultaneous request
600 requests per 10 minutes
Have you checked? If so, where
thats mojang api
discord is limited to 50 requests per second.
so the discord api is not a problem
It's what I won't do
did it, but gonna have to heavily limit this, i can already see me getting limited by mojang
got it to work :D
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.