Open EchoQuill opened 1 month ago
is this perhaps related to #500 ..?
I have also run into this issue. I can run it on my main PC but I can't do it on the server I rented. So weird.
Log :
2024-10-12 02:05:00,805 - INFO - Today's Quotes: 遇到難題就慢慢來,解決它的過程也是成長的一部分汪 (๑´ㅂ`๑) --機器狼GPT
2024-10-12 02:05:00,805 - INFO - Today's Server Quotes: 托托哥哥最信任的就是你們的力量,一起迎接勝利汪 (^▽^) --機器狼GPT
2024-10-12 02:05:00,831 - INFO - New day detected. Updating count to 9.
2024-10-12 02:05:00,831 - INFO - Count updated: 9 days.
2024-10-12 02:05:00,936 - ERROR - Ignoring exception in on_ready
Traceback (most recent call last):
File "/home/container/.local/lib/python3.12/site-packages/discord/client.py", line 507, in _run_event
await coro(*args, **kwargs)
File "/home/container/run.py", line 96, in on_ready
user = await client.fetch_user(user_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/container/.local/lib/python3.12/site-packages/discord/client.py", line 2161, in fetch_user
data = await self.http.get_user(user_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/container/.local/lib/python3.12/site-packages/discord/http.py", line 830, in request
raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 40001): Unauthorized
Code :
@client.event
async def on_ready():
logging.info(f'Logged in as {client.user}')
# Load and log quotes
quotes = open("quotes.txt").read().splitlines()
random_quotes = random.choice(quotes)
logging.info(f"Today's Quotes: {random_quotes}")
quotes_server = open("quotes_server.txt").read().splitlines()
random_quotes_server = random.choice(quotes_server)
logging.info(f"Today's Server Quotes: {random_quotes_server}")
taipei_tz = pytz.timezone('Asia/Taipei')
current_date = datetime.datetime.now(taipei_tz).date()
# Check if today is not Saturday or Sunday
if current_date.weekday() < 7: # Monday is 0, Sunday is 6
file_path = 'day_count.txt'
if os.path.exists(file_path):
with open(file_path, 'r') as file:
content = file.read().split(',')
last_date = datetime.datetime.strptime(content[0], '%Y-%m-%d').date()
if current_date == last_date:
logging.info("Same day detected, shutting down the server.")
shutdown_server()
# Update the day count
day_count = update_count()
# Send messages to user and server
user = await client.fetch_user(user_id)
server_channel = await client.fetch_channel(channel_id)
logging.info(f"Sending private message to user {user_id}.")
await user.send(f"\u6258\u6258\u4e0a\u73ed\u4e86\uff01\u4eca\u5929\u662f\u4f60\u7b2c {day_count} \u5929\u5de5\u4f5c\u4e86\u3002")
time.sleep(2)
await user.send(f"{random_quotes}")
time.sleep(2)
await user.send(f"`\u6258\u6258\u4e0a\u73ed\u547c\u53eb\u5668 2024/10/12`")
logging.info(f"Sending message to server channel {channel_id}.")
await server_channel.send(f"\u5927\u5bb6\u65e9\u4e0a\u597d\uff01\u6e96\u5099\u597d\u8981\u4e0a\u73ed\u4e86\u55ce\uff1f")
time.sleep(2)
await server_channel.send(f"\u4f86\u8b93\u4eca\u5929\u7684\u91d1\u53e5\u6fc0\u52f5\u5927\u5bb6\u5427\uff01")
time.sleep(2)
await server_channel.send(f"{random_quotes_server}")
time.sleep(2)
await server_channel.send(f"`\u6258\u6258\u4e0a\u73ed\u547c\u53eb\u5668 2024/10/12`")
logging.info("Shutting down server after message delivery.")
shutdown_server()
client.run(token)
i have the same error i have tried fetching multiple different users i have tried fetching from multiple different accounts nothing is working so far i didnt have this problem yesterday but today my code is no longer working
Smells like more TLS fingerprinting. Can you check with the refactor/tls branch?
Smells like more TLS fingerprinting. Can you check with the refactor/tls branch?
I cant seem to run it sadly. I am not smart enough to figure out what I am doing wrong here.
( installed with pip install git+https://github.com/dolfies/discord.py-self.git@refactor/tls
)
sorry!
2024-10-13 09:24:15 INFO discord.http Found user agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36", build number 335184.
Exception in thread Thread-1 (run_bot):
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1073, in _bootstrap_inner
self.run()
File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1010, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\Admin\Desktop\New folder\owo-dusk\uwu.py", line 2746, in run_bot
client.run(token, log_level=logging.DEBUG)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\client.py", line 1051, in run
asyncio.run(runner())
File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\client.py", line 1040, in runner
await self.start(token, reconnect=reconnect)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\client.py", line 970, in start
await self.login(token)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\client.py", line 812, in login
data = await state.http.static_login(token.strip())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\http.py", line 1078, in static_login
data = await self.get_me()
^^^^^^^^^^^^^^^^^^^
File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\http.py", line 709, in request
await self.startup()
File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\http.py", line 644, in startup
if not requests.BrowserType.has(impersonate):
^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'BrowserType' has no attribute 'has'```
Smells like more TLS fingerprinting. Can you check with the refactor/tls branch?
This fixes it for me.
I cant seem to run it sadly. I am not smart enough to figure out what I am doing wrong here. ( installed with
pip install git+https://github.com/dolfies/discord.py-self.git@refactor/tls
) sorry!
Doesn't work with curl_cffi>=0.7.2
. You can downgrade with pip install curl_cffi==0.6.0b7
(oldest version mentioned in requirements.txt)
Sounds good, I'll make that branch a priority when I have time
Doesn't work with
curl_cffi>=0.7.2
. You can downgrade withpip install curl_cffi==0.6.0b7
(oldest version mentioned in requirements.txt)
Thanks, it worked!
Smells like more TLS fingerprinting. Can you check with the refactor/tls branch?
Fixes it for me as well.
now get_channel() also gives the same error sadly.
That doesn't make sense, that just looks up from cache
That doesn't make sense, that just looks up from cache
sorry just checked! my bad, while trying to merge two folder, i accidentally switched up file containing the channel id with one with old channel id. (since my code attempted to fetch dms as well with try-except to handle that error, i thought it was get_channel()
that was giving the error(channel fetched was none, causing the try-except to not work as intended)).
sorry again! Is working just fine.
pip uninstall discord.py-self
then pip install git+https://github.com/dolfies/discord.py-self.git@refactor/tls
worked to solve the 403 error for me on fetch_user()
Summary
fetching dms failed.
Reproduction Steps
Running the code below, gave 403 error.
Code
Expected Results
it is suppossed to fetch user with id "408785106942164992" then create a dm.
Actual Results
System Information
Checklist
Additional Information
This code was working fine yesterday and other users seems to be also having this issue today. Iam new to posting issues, so do be understanding of any mistakes in this and feel free to ask if i need to provide any additional information (and yes the bot's dm we are trying to fetch and create dm is accessable, i even dmed the bot manually and tried running the code to see if that fixed the issue.)
Note: the issue here is with fetching the channel, not creating the dm i have tried replacing
self.dm = await (await self.fetch_user(408785106942164992)).create_dm()
withself.dm = await self.fetch_user(408785106942164992)
still same result... Thanks!