From b2f09d6cca52f6f5abf64de56df76c30c1fe08f5 Mon Sep 17 00:00:00 2001 From: Rainy21 Date: Thu, 16 Apr 2026 22:53:50 -0400 Subject: [PATCH] added the bot --- __pycache__/bot.cpython-313.pyc | Bin 0 -> 2786 bytes bot.log | 84 ++++++++++++++++++++++++++++++++ bot.py | 59 ++++++++++++++++++++++ requirements.txt | 4 ++ 4 files changed, 147 insertions(+) create mode 100644 __pycache__/bot.cpython-313.pyc create mode 100644 bot.log create mode 100644 bot.py create mode 100644 requirements.txt diff --git a/__pycache__/bot.cpython-313.pyc b/__pycache__/bot.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5d775f398cba708a533add496a988e97b4d7276b GIT binary patch literal 2786 zcmcgtO>7fK6rR}~ukCeg@&`dQF`Mv{EGYy;CS)N#zagA#N>aJs5+%Yt7oI z$tloE{9J;nR!t?Urd1`9Q?EV3tw*~Nax{PhZ4c#UWT_RmzFFIWG=S7gN7^^@es|`Z zH}6$~K^4LH^V=t>pF9ZtE|~i8))tjx5<*`g0~vS>F)>SHXcRN7Rb>*BKqimLql6I+ zMM)PrRC5JRinxEM2d&Os$RLMsb24{5b4>tf1_pF+WoN2QKfDY??MPX_HOie?H#t(v8>M; zO5$i6-0tR=CHj`9BIvk|c|$y#jhS{P6Soo$@PV`)Ps9>-j#`&_!_bH^I1w3|oERGx z#@>_#@|?p-Hf1GeTPLZL(^BWPX&WX-i>FhUsV;G1#WR!#64WtSDw|8$77qwd7B>ZB z*7D3f7vwnl48F=FkR3>aygr8_u4+Ar$m@B*8Q72vc|aP0yuSeY%lIpK+|vM2lE{a~ zJ%{DNxQvUB*nj5JzlN z;|d&ZUv`Fx$LEqpq1y@MDVjr%)y*X}TvWp)wYRADE}i~4S5SKk>QIRct&pMTl?E`p z8t%c1csKc8>A~ESwv#DqcFUQRbxE7C^Gu7R0KT|s+IcI-gHAq^u`SACE{F=FNdei* zhZj3>A)AK9e~0WG4ne^3^UVM%`^L$Ja=5oclF^rcrRH}`Y;C+O~~8X zHiObC=2d}~iRa7ctGD2-izdeKw>4Y@w;OwiF4zu&=MqLADNH?PaS?b=`}(YPGQ(Os%ypgG`B}bH}S1 zRtO!G>iepdkxsXac*eQk7>;~69Ept#K`oS038*KYWImNn%m&Zc$s|o^DNBnxnjYZZ zM9ML3mf*_7^hIjsxC{l5OSZ$6Bz0>m$uUZK$h5OFv1Hnwj;CWen-gcoGPx(qgt=m- zQ;@ctYGd%12+a&MjcY%9iSJTb%ez-e~D=X?T0T>T#nE%W0y$8VcIcHPl`(3i$m zx{j=b2Z{|x=Y}5=Ux~C8N!tP~h;0y8 zp`)O7-zPoKWaR05?g;R%o_y;R#`ik#$rI#WxC_=iSnCuqw^ht;%Uz(1YH|21TdQHA zRELI&*KWtMPzvuk{|cf^*r)v1-{7uZDZ*Wq{d*k;^P^v2KtqqY6+| z!}?gpPUO?{I2!<&xCEyUXj#S>KR}^JNPB?%k5Kpt3Va@1ZEXJ9|Al{H-%6uC7ksQX z&G+5tE2*7DwR1(?G3Qf6tt<>TM}`xBu$hzNoBtyXQz*MUrx@{Yv|- zcM9F_&b1ft@v?;RFkU!aYVRwy_f?SKDl(EzR25}k-Q#ef=RM(ZvMdp-EPPbz*kA0} zUq-;(ZE>ex%!=TI_bKdJl|yy!BL)4G@E$BnGI%FT;RD6+0jQ}}`ysH0rLgyj{XK(! v=ps-^#L@o>A=0!;)N7+xMz6E^nVT~U+gCQ}_sO0o#9vT%-zVMd2mtpF6WT4+ literal 0 HcmV?d00001 diff --git a/bot.log b/bot.log new file mode 100644 index 0000000..44fed83 --- /dev/null +++ b/bot.log @@ -0,0 +1,84 @@ +[2026-04-16 22:50:39] [INFO ] discord.client: logging in using static token +Traceback (most recent call last): + File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/aiohttp/connector.py", line 1325, in _wrap_create_connection + return await self._loop.create_connection(*args, **kwargs, sock=sock) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line 1188, in create_connection + transport, protocol = await self._create_connection_transport( + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ...<2 lines>... + ssl_shutdown_timeout=ssl_shutdown_timeout) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line 1221, in _create_connection_transport + await waiter + File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/sslproto.py", line 581, in _on_handshake_complete + raise handshake_exc + File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/sslproto.py", line 563, in _do_handshake + self._sslobj.do_handshake() + ~~~~~~~~~~~~~~~~~~~~~~~~~^^ + File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/ssl.py", line 951, in do_handshake + self._sslobj.do_handshake() + ~~~~~~~~~~~~~~~~~~~~~~~~~^^ +ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1018) + +The above exception was the direct cause of the following exception: + +Traceback (most recent call last): + File "/Users/simonzheng/Documents/vscode/lolBot/bot.py", line 56, in + client.run(Discord_Token) + ~~~~~~~~~~^^^^^^^^^^^^^^^ + File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/discord/client.py", line 933, in run + asyncio.run(runner()) + ~~~~~~~~~~~^^^^^^^^^^ + File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 194, in run + return runner.run(main) + ~~~~~~~~~~^^^^^^ + File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 118, in run + return self._loop.run_until_complete(task) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^ + File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line 720, in run_until_complete + return future.result() + ~~~~~~~~~~~~~^^ + File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/discord/client.py", line 922, in runner + await self.start(token, reconnect=reconnect) + File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/discord/client.py", line 850, in start + await self.login(token) + File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/discord/client.py", line 679, in login + data = await self.http.static_login(token) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/discord/http.py", line 844, in static_login + data = await self.request(Route('GET', '/users/@me')) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/discord/http.py", line 659, in request + async with self.__session.request(method, url, **kwargs) as response: + ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^ + File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/aiohttp/client.py", line 1521, in __aenter__ + self._resp: _RetType = await self._coro + ^^^^^^^^^^^^^^^^ + File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/aiohttp/client.py", line 788, in _request + resp = await handler(req) + ^^^^^^^^^^^^^^^^^^ + File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/aiohttp/client.py", line 742, in _connect_and_send_request + conn = await self._connector.connect( + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + req, traces=traces, timeout=real_timeout + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ) + ^ + File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/aiohttp/connector.py", line 672, in connect + proto = await self._create_connection(req, traces, timeout) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/aiohttp/connector.py", line 1251, in _create_connection + _, proto = await self._create_direct_connection(req, traces, timeout) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/aiohttp/connector.py", line 1623, in _create_direct_connection + raise last_exc + File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/aiohttp/connector.py", line 1592, in _create_direct_connection + transp, proto = await self._wrap_create_connection( + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ...<7 lines>... + ) + ^ + File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/aiohttp/connector.py", line 1327, in _wrap_create_connection + raise ClientConnectorCertificateError(req.connection_key, exc) from exc +aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discord.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1018)')] diff --git a/bot.py b/bot.py new file mode 100644 index 0000000..555f016 --- /dev/null +++ b/bot.py @@ -0,0 +1,59 @@ +import discord +from discord import app_commands +import os +from dotenv import load_dotenv + +load_dotenv() +Discord_Token = os.getenv("DISCORDTOKEN") + +intents = discord.Intents.default() +client = discord.Client(intents=intents) +tree = app_commands.CommandTree(client) + +# --command --------------------------------------------------------- + + +@tree.command(name="ping", description="Test if bot is alive") +async def ping(interaction: discord.Interaction): + await interaction.response.send_message("Pong!", ephemeral=True) + + +@tree.command(name="login", description="Link your Riot account") +async def login(interaction: discord.Interaction, summoner_name: str, region: str): + await interaction.response.send_message( + f"Received: {summoner_name} on {region} — login logic coming soon!", + ephemeral=True, + ) + + +@tree.command(name="recent", description="See your recent matches") +async def recent(interaction: discord.Interaction): + await interaction.response.send_message( + "Fetching your recent matches — coming soon!", ephemeral=True + ) + + +# --StartUp ------------------------------------------------------- +@client.event +async def on_ready(): + server_id = os.getenv("SERVER_ID") + if server_id: + try: + guild = discord.Object(id=int(server_id)) + tree.copy_global_to(guild=guild) + await tree.sync(guild=guild) + print(f"Logged in as {client.user} (Synced to Guild ID: {server_id})") + except ValueError: + print(f"Error: SERVER_ID '{server_id}' is not a valid integer. Syncing globally instead.") + await tree.sync() + print(f"Logged in as {client.user} (Global Sync)") + else: + await tree.sync() + print(f"Logged in as {client.user} (Global Sync)") + + +if Discord_Token: + client.run(Discord_Token) +else: + print("Error: DISCORDTOKEN not found in .env file.") + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..4304048 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +discord.py +python-doten +httpx +aiosqlite