aelew / cryptotracker

🤖 A Discord bot that alerts users when their cryptocurrency transactions confirm. Supports BTC, ETH, and LTC.
https://discord.com/oauth2/authorize?client_id=1132724830135922688&permissions=277025508352&scope=bot%20applications.commands
MIT License
9 stars 5 forks source link

Replit import error #2

Closed ogigio closed 9 months ago

ogigio commented 9 months ago

Traceback (most recent call last): File "/home/runner/blockchain/main.py", line 5, in from interactions import (listen, slash_command, Activity, ActivityType, OptionType, SlashContext, SlashCommandChoice, ImportError: cannot import name 'listen' from 'interactions' (/home/runner/blockchain/.pythonlibs/lib/python3.10/site-packages/interactions/init.py) Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x7ffabfa6ca60>

aelew commented 9 months ago

Try updating interactions.py using pip install -U discord-py-interactions

ogigio commented 9 months ago

Screenshot 2023-12-11 005757

says already satisfied

aelew commented 9 months ago

You might have another Python package installed that also uses the module name interactions, try setting up a virtual environment

ogigio commented 9 months ago

wdym, virtual environment

aelew commented 9 months ago

wdym, virtual environment

https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/

ogigio commented 9 months ago

i've done that and it's still same error Screenshot 2023-12-11 215648

aelew commented 9 months ago

Make sure you activate the venv and install the packages + run the bot inside the venv

ogigio commented 9 months ago

wait so i did run venv by doing something in shell(i am using replit) i need to install packages again? And if yes how should i do it, btw do you have discord or smth so we could chat if u want to help?

aelew commented 9 months ago

Yep, it should say (venv) when you activate the virtual environment. If you still need help my Discord is @aelew

aelew commented 9 months ago

Apparently this is an issue with Replit guessing and automatically installing the wrong packages based on import names.

Here's how you can fix this:

  1. Create a fresh Replit project using the GitHub repo URL

  2. Turn on show hidden files

    image
  3. Open .replit and add disableGuessImports = true to the top of the file

  4. Manually install packages using pip install -r requirements.txt

  5. Set your environment variables using Replit's Secrets tool (see the .env.example file to see what you need)

  6. Run the bot using the run button

Hope this helps! You should not need a virtual environment anymore. I'll probably look into adding a Replit deploy button when I have some free time.

ogigio commented 9 months ago

"Create a fresh Replit project using the GitHub repo URL" Do i just download all files and upload there or is there easier way?

aelew commented 9 months ago

Here is a video to help you :) https://github.com/aelew/cryptotracker/assets/118043566/c14452a7-719b-4d07-9a72-a6a0aa4b76c2

ogigio commented 9 months ago

how did bro make that so fast...

ogigio commented 9 months ago

Well i got this now, i put token in env.example file and i tried with "" and without since idk if i should or shouldnt add them btw what's web3_http_provider and where to get that

Traceback (most recent call last): File "/home/runner/cryptotracker/main.py", line 131, in bot.start(os.getenv("DISCORD_BOT_TOKEN")) File "/home/runner/cryptotracker/.pythonlibs/lib/python3.10/site-packages/interactions/client/client.py", line 993, in start asyncio.run(self.astart(token)) File "/nix/store/xf54733x4chbawkh1qvy9i1i4mlscy1c-python3-3.10.11/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/nix/store/xf54733x4chbawkh1qvy9i1i4mlscy1c-python3-3.10.11/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete return future.result() File "/home/runner/cryptotracker/.pythonlibs/lib/python3.10/site-packages/interactions/client/client.py", line 949, in astart await self.login(token) File "/home/runner/cryptotracker/.pythonlibs/lib/python3.10/site-packages/interactions/client/client.py", line 915, in login raise RuntimeError( RuntimeError: No token provided - please provide a token in the client constructor or via the login method.

aelew commented 9 months ago

Since you're using Replit, you need to use their Secrets tool to set your environment variables. For WEB3_HTTP_PROVIDER, you can create an Ethereum endpoint at https://www.quicknode.com and use the HTTP Provider URL it gives you. If you don't need ETH support, you don't need this variable.

ogigio commented 9 months ago

Damn this works, ty for this kind of support, tbh i never saw better developer (that posts on github), you know how to make shit and how to help others, ty brother!

aelew commented 9 months ago

No problem! Let me know if you have any other questions 😉

ogigio commented 9 months ago

Yo now if i wanna host 24/7 with uptimerobot i can just add my keep_alive.py? It won't mess up something?

from flask import Flask from threading import Thread import random

app = Flask('')

@app.route('/') def home(): return 'Im in!'

def run(): app.run( host='0.0.0.0', port=random.randint(2000,9000) )

def keep_alive(): ''' Creates and starts new thread that runs the function run. ''' t = Thread(target=run) t.start()

aelew commented 9 months ago

You can try, no guarantees it'll work though. I'm afraid I can't help with that if it doesn't. If you're a student, Heroku offers credits via the GitHub Student Developer Pack that can host the bot for free for a whole year, which is what I'm currently doing with the hosted version.

ogigio commented 8 months ago

Came back to thank you again for this source code, my bot is now in 134 servers and i am waiting for verification of it!

Update on keep_alive: yea it worked, it's hosted 24/7 for free

Question: How could i add multiple checking because some sites with crypto as payment method has checking with more blockchain type of sites like blockchair, blockchain etc. and it says 1/2 confirmations but my bot pinged me bc it confirmed 1/1 for it