Pilot1782 / bad_copenheimer

A Python implementation of a discord bot that acts as a server scanner similar to Copenheimer, but is rather bad [DEPRECIATED].
GNU General Public License v3.0
90 stars 34 forks source link

[Bug]: No module named 'interactions' When running dis-bot.pyw #53

Closed rareromfish closed 1 year ago

rareromfish commented 2 years ago

Contact Details

bluefish#7723

What happened?

Setup ran well, (after some debugging), but when running dis-bot.pyw it returns an error suggesting it can't find the interactions module. I can't find anywhere in the files where it is created, just referenced in stopper.pyw as well. Couldn't find anything on pip either, not that I expected to. I'm using the latest build on github, ec59933. I tried using 1.9.1 but was unable to get the setup working. Thank you for reading this.

Version

1.9.1 (Default)

Relevant log output

Traceback (most recent call last):
  File "C:\Users\throwaway\Desktop\bad_copenheimer-main\dis-bot.pyw", line 1, in <module>
    import interactions
ModuleNotFoundError: No module named 'interactions'
Pilot1782 commented 2 years ago

So interactions is actually named discord-py-interactions use that instead of interactions when installing ie

pip install discord-py-interactions

rareromfish commented 2 years ago

Thank you, that works. I had to change the first line from import interactions to import discord as interactions, but I'm still having an issue running it. I get the below error when I try to run dis-bot.pyw. I have also included my settings.json file, it seems like that might be part of the issue? I tried substituting the win-py value for a full path, with no luck. Thanks again for your help, this looks like a really cool project.

{ "TOKEN":"[removed]" "lower_ip_bound":"172.65.238.255", "upper_ip_bound":"172.65.240.255", "threads":1020, "timeout":6000, "os":1, "home-dir": "C:\Users\throwaway\Desktop\bad_copenheimer-1.9.1\", "user":"[removed]", "password":"[removed]", "guild-id": [removed], "server":false, "server-port":"8080", "masscan":false, "time2":1000, "lin-py":"python3", "win-py":"%LOCALAPPDATA%\\Programs\\Python\\Python310\\python.exe", "debugging":true, "testing":true }

Traceback (most recent call last): File "C:\Users\throw\Desktop\bad_copenheimer-main\dis-bot.pyw", line 20, in <module> fncs = funcs(settings_path) File "C:\Users\throw\Desktop\bad_copenheimer-main\funcs.py", line 15, in __init__ with open(settings_path, "r") as read_file: # Open the settings file and start defineing variables from it OSError: [Errno 22] Invalid argument: 'C:\\Program Files\\Common Files\\Oracle\\Java\\javapath;C:\\Python310\\Scripts\\;C:\\Python310\\;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\Users\\throw\\AppData\\Local\\Programs\\Python\\Python39;C:\\Users\\throw\\AppData\\Local\\Programs\\Python\\Python39\\Scripts;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Program Files (x86)\\AOMEI\\AOMEI Backupper 6.4.0;C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common;C:\\Program Files\\dotnet\\;C:\\Program Files (x86)\\FFAIO\\bin;C:\\Program Files\\NVIDIA Corporation\\NVIDIA NvDLISR;D:\\Program Files\\Node\\;C:\\ProgramData\\chocolatey\\bin;D:\\Program Files\\Git\\cmd;C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\170\\Tools\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\150\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\150\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\150\\DTS\\Binn\\;C:\\Program Files (x86)\\Windows Kits\\8.1\\Windows Performance Toolkit\\;C:\\Users\\throw\\AppData\\Local\\Programs\\Python\\Python37\\Scripts\\;C:\\Users\\throw\\AppData\\Local\\Programs\\Python\\Python37\\;C:\\Users\\throw\\AppData\\Roaming\\Python\\Python37\\Scripts;C:\\Users\\throw\\AppData\\Roaming\\Python\\Python37;C:\\Users\\throw\\AppData\\Local\\atom\\bin;C:\\Users\\throw\\AppData\\Roaming\\npm'

Pilot1782 commented 2 years ago

In .env make sure the path is correct

rareromfish commented 2 years ago

Yes, the path is correct and I get the same error.

PATH=C:\Users\throwaway\Desktop\bad_copenheimer-main\settings.json

Pilot1782 commented 2 years ago

Alright so looking at the error again, the path the script is using is that defined by the system environment, which is not what we want, try and edit the line (15 in dis-bot.pyw) settings_path = osys.getenv("PATH"

To

settings_path = "Your path here"

rareromfish commented 2 years ago

Changed the code as suggested, getting a unicode error now. I get the same error with or without the settings.json at the end.

File "C:\Users\throwaway\Desktop\bad_copenheimer-main\dis-bot.pyw", line 15 settings_path = "C:\Users\throw\Desktop\bad_copenheimer-main\settings.json" ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

Pilot1782 commented 2 years ago

Ya forgot to mention but \ is an escape character and used like that messes things up so new code:

settings_path = r"Your path with the settings.json attached"

rareromfish commented 2 years ago

Yikes, I'm dumb. After fixing all the escape issues littering my changes, we are now back to the initial issue. I installed discord-py-interactions with pip (it seems to have downloaded), but it still won't import it. When I import discord as interactions, I get the following error later in the code (I would have been surprised if that worked).

Checking scan Traceback (most recent call last): File "C:\Users\throwaway\Desktop\bad_copenheimer-main\dis-bot.pyw", line 78, in <module> @bot.command( AttributeError: 'Client' object has no attribute 'command'

And a bit more of the relevant code

23 bot = interactions.Client(token=osys.getenv("TOKEN"))

Pilot1782 commented 2 years ago

So the module discord is not the same as interactions and thus the error, change the import stamens back to import interactions

rareromfish commented 2 years ago

Sorry, I thought it was part of discord.py, I've never used it before. Reverted that change, and did some more debugging, now I'm here. It looks like its having an issue with the discord guild. I grabbed the first part of the link to my discord server, and its in both the .env file and settings.json. Its entered as a number, not a string (but it didn't seem to change anything). Thanks for your help.

Checking scan Checking status Checking list Testing:True, Debugging:True

Starting bot... Starting emergency bot... Checking scan Checking status Checking list b'Traceback (most recent call last):\r\n File "C:\\Users\\throw\\Desktop\\bad_copenheimer-main\\stopper.pyw", line 12, in <module>\r\n with open(settings_path) as json_file:\r\nOSError: [Errno 22] Invalid argument: \'C:\\\\Program Files\\\\Common Files\\\\Oracle\\\\Java\\\\javapath;C:\\\\Python310\\\\Scripts\\\\;C:\\\\Python310\\\\;C:\\\\Program Files (x86)\\\\Common Files\\\\Oracle\\\\Java\\\\javapath;C:\\\\Users\\\\throw\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python39;C:\\\\Users\\\\throw\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python39\\\\Scripts;C:\\\\Windows\\\\system32;C:\\\\Windows;C:\\\\Windows\\\\System32\\\\Wbem;C:\\\\Windows\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\;C:\\\\Windows\\\\System32\\\\OpenSSH\\\\;C:\\\\Program Files (x86)\\\\AOMEI\\\\AOMEI Backupper 6.4.0;C:\\\\Program Files (x86)\\\\NVIDIA Corporation\\\\PhysX\\\\Common;C:\\\\Program Files\\\\dotnet\\\\;C:\\\\Program Files (x86)\\\\FFAIO\\\\bin;C:\\\\Program Files\\\\NVIDIA Corporation\\\\NVIDIA NvDLISR;D:\\\\Program Files\\\\Node\\\\;C:\\\\ProgramData\\\\chocolatey\\\\bin;D:\\\\Program Files\\\\Git\\\\cmd;C:\\\\Program Files\\\\Microsoft SQL Server\\\\Client SDK\\\\ODBC\\\\170\\\\Tools\\\\Binn\\\\;C:\\\\Program Files (x86)\\\\Microsoft SQL Server\\\\150\\\\Tools\\\\Binn\\\\;C:\\\\Program Files\\\\Microsoft SQL Server\\\\150\\\\Tools\\\\Binn\\\\;C:\\\\Program Files\\\\Microsoft SQL Server\\\\150\\\\DTS\\\\Binn\\\\;C:\\\\Program Files (x86)\\\\Windows Kits\\\\8.1\\\\Windows Performance Toolkit\\\\;C:\\\\Users\\\\throw\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python37\\\\Scripts\\\\;C:\\\\Users\\\\throw\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python37\\\\;C:\\\\Users\\\\throw\\\\AppData\\\\Roaming\\\\Python\\\\Python37\\\\Scripts;C:\\\\Users\\\\throw\\\\AppData\\\\Roaming\\\\Python\\\\Python37;C:\\\\Users\\\\throw\\\\AppData\\\\Local\\\\atom\\\\bin;C:\\\\Users\\\\throw\\\\AppData\\\\Roaming\\\\npm\'\r\nUnclosed client session\r\nclient_session: <aiohttp.client.ClientSession object at 0x0000016257BF9120>\r\n' Could not prepare the client: Traceback (most recent call last): File "C:\Python310\lib\site-packages\interactions\client\bot.py", line 352, in _ready await self.__sync() File "C:\Python310\lib\site-packages\interactions\client\bot.py", line 429, in __sync _guilds = await self._http.get_self_guilds() File "C:\Python310\lib\site-packages\interactions\api\http\guild.py", line 30, in get_self_guilds if guild.get("id"): AttributeError: 'str' object has no attribute 'get' Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x0000022E49BF2980> Unclosed connector connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x0000022E49D86DA0>, 19824.062)]'] connector: <aiohttp.connector.TCPConnector object at 0x0000022E49BF30A0> Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x0000022BB122B940> Unclosed connector connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x0000022BB13DFDC0>, 19823.375)]'] connector: <aiohttp.connector.TCPConnector object at 0x0000022BB12600A0>

Pilot1782 commented 2 years ago

So this is the same issue as before so just do the same edit to the settings path at the top

rareromfish commented 2 years ago

I tried a relative path settings_path = "settings.json", and absolute paths with forward slashes, a backward slash, and a double backward slash. All produce the same error. How should the paths be formatted?

Pilot1782 commented 2 years ago

Absolute path as a string with \

rareromfish commented 2 years ago

I've tried a bunch of those, but it still has the issue. Double \, with an r in front, but when I try like this settings_path = "C:\Users\throw\Desktop\bad_copenheimer-main\settings.json" I get a unicode error.

Pilot1782 commented 2 years ago

Ya you want to use either a \ or an r and the Unicode error is from python expecting x123 after ie \Ux123

rareromfish commented 2 years ago

I tried with either a \ or a r, with both, when I got the unicode error I tried a bunch of combos with x123 after the . Nothing worked. Can you please give me an example of how you'd format line 15 of dis-bot.pyw? This is what I have settings_path = "C:\Users\throwaway\Desktop\bad_copenheimer-main\settings.json". Should I just wait for a more stable build?

Pilot1782 commented 2 years ago

current dev-builds commit has been working for me

Bananalolok commented 2 years ago
C:\Users\bsuwm\Documents\um\bad_copenheimer-main\bad_copenheimer-main>python3 dis-bot.pyw
Traceback (most recent call last):
  File "C:\Users\bsuwm\Documents\um\bad_copenheimer-main\bad_copenheimer-main\dis-bot.pyw", line 20, in <module>
    fncs = funcs(r"C:\Users\bsuwm\Documents\um\bad_copenheimer-main\bad_copenheimer-main\settings.json")
  File "C:\Users\bsuwm\Documents\um\bad_copenheimer-main\bad_copenheimer-main\funcs.py", line 17, in __init__
    data = json.load(read_file)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\json\__init__.py", line 293, in load
    return loads(fp.read(),
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\json\decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Invalid \escape: line 8 column 18 (char 223)
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x00000200FEA8F580

how can i fix this error?

ADAMOUMOU commented 2 years ago
C:\Users\bsuwm\Documents\um\bad_copenheimer-main\bad_copenheimer-main>python3 dis-bot.pyw
Traceback (most recent call last):
  File "C:\Users\bsuwm\Documents\um\bad_copenheimer-main\bad_copenheimer-main\dis-bot.pyw", line 20, in <module>
    fncs = funcs(r"C:\Users\bsuwm\Documents\um\bad_copenheimer-main\bad_copenheimer-main\settings.json")
  File "C:\Users\bsuwm\Documents\um\bad_copenheimer-main\bad_copenheimer-main\funcs.py", line 17, in __init__
    data = json.load(read_file)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\json\__init__.py", line 293, in load
    return loads(fp.read(),
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\json\decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Invalid \escape: line 8 column 18 (char 223)
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x00000200FEA8F580

how can i fix this error?

I have same error

Pilot1782 commented 2 years ago

Make sure that the settings.json file is correct as explained in the wiki