Skip to content

Commit

Permalink
fix: Temporary fix for failing to fetch owobot's dms
Browse files Browse the repository at this point in the history
  • Loading branch information
EchoQuill authored Oct 11, 2024
1 parent c0695b0 commit 81b455d
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions uwu.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def resource_path(relative_path):
with open(resource_path("config.json")) as file:
config = json.load(file)
#----------OTHER VARIABLES----------#
version = "1.6.0"
version = "1.6.1"
offline = config["offlineStatus"]
ver_check_url = "https://raw.githubusercontent.com/EchoQuill/owo-dusk/main/version.txt"
quotesUrl = "https://favqs.com/api/qotd" #["https://thesimpsonsquoteapi.glitch.me/quotes", "https://favqs.com/api/qotd"]
Expand Down Expand Up @@ -1530,6 +1530,7 @@ async def before_presence(self):
async def on_ready(self):
self.on_ready_done = False
self.cmds = 1
self.dm,self.cm = None,None
if self.session is None:
self.session = aiohttp.ClientSession()
await asyncio.sleep(0.1)
Expand All @@ -1543,11 +1544,29 @@ async def on_ready(self):
self.cm = self.get_channel(self.channel_id)
except Exception as e:
print(e)
"""
NOTE:- Temporary fix for https://github.com/dolfies/discord.py-self/issues/744
"""
try:
#self.dm = await self.fetch_user(408785106942164992) #owo bot's id
self.dm = await (await self.fetch_user(408785106942164992)).create_dm() #fixes dm closed issue
self.dm = await (await self.fetch_user(408785106942164992)).create_dm()
print(self.dm)
except discord.Forbidden as e:
print(e)
print(f"attempting to get user with the help of {self.cm}")
await self.cm.send(f"{setprefix}ping")
print(f"{self.user} send ping command to trigger bot response")
async for message in self.cm.history(limit=10):
if message.author.id == 408785106942164992:
print(f"{self.user} found bot!, attempting to create dm")
break
self.dm = await message.author.create_dm()
print(f"{self.user} created dm {self.dm} successfully!")
print(self.dm)


except Exception as e:
print(e)

if self.dm == None:
print("channel disabled")
#if await delaycheck()["ping"] >= minPing:
Expand Down Expand Up @@ -2720,12 +2739,13 @@ def run_bots(tokens_and_channels):
def run_bot(token, channel_id):
logging.getLogger("discord.client").setLevel(logging.ERROR) #remove that useless voice chat thingy warn
client = MyClient(token, channel_id)
client.run(token, log_level=logging.ERROR)
client.run(token, log_level=logging.INFO)
if __name__ == "__main__":
console.print(owoPanel)
print('-'*console_width)
printBox(f'-Made by EchoQuill'.center(console_width - 2 ),'bold grey30 on black' )
printBox(f'-Current Version:- {version}'.center(console_width - 2 ),'bold spring_green4 on black' )
printBox(f'This is a debug/modified version of owo-dusk.'.center(console_width - 2 ),'bold orange4 on black' )
if websiteEnabled:
printBox(f'-Website captcha logger:- http://localhost:{websitePort}/'.center(console_width - 2 ),'bold blue_violet on black' )
if compare_versions(version, ver_check):
Expand Down

0 comments on commit 81b455d

Please sign in to comment.