I keep getting a error while attempting to run my bot, module 'discord' has no attribute 'bot' - discord

I am trying to run my bot currently and I keep running into the error “module 'discord' has no attribute 'bot'” and will not let me start my bot.
Here is my code:
import os
os.system("pip install py-cord")
import discord
import time
import requests
import datetime
from discord.ext import commands
from discord.utils import get from discord.ext import tasks
from discord.ext.commands import Bot
bot = discord.Bot()
#bot.event
async def on_ready():
print(f"WORKING AS {client.user}"
# commands were removed due to it not letting me post the question but the code shouldn’t be a issue with the bot. It is slash commands. I will leave the beginning of the code below.
#bot.slash_command(description="Unlock the chat.")
#commands.has_permissions(manage_channels = True)
# code was here
bot.run(mytoken)
I’ve already tried changing it from bot to client with no luck. I also already tried the specific version being 2b1. I want to use slash commands with the bot and client says there is no attribute slash commands.I do not think it’s something to do with the lower portion of the code, it’s something to do with the top of the code if you can help, please and thank you.

Your code looks perfectly fine.
However, this may be a library issue, and you're installing libraries in code (see below). If you accidentally installed discord.py, it may be causing this issue.
In the console do the following:
pip uninstall discord.py
This will uninstall discord.py
Then install the proper pycord version:
pip install -U py-cord==2.4.0
Why you want to do this manually
The reason you want to do this manually is that installing libraries in code is not supported by PIP. See more here.

Related

Observing error while running Gatling project 'object gatling is not a member of package io'

I m seeing the following error while running Engine.scala
object gatling is not a member of package io import io.gatling.app.Gatling
Below is the code that is used
`import io.gatling.app.Gatling
import io.gatling.core.config.GatlingPropertiesBuilder
object Engine extends App {
val props = new GatlingPropertiesBuilder()
.resourcesDirectory(IDEPathHelper.mavenResourcesDirectory.toString)
.resultsDirectory(IDEPathHelper.resultsDirectory.toString)
.binariesDirectory(IDEPathHelper.mavenBinariesDirectory.toString)
Gatling.fromMap(props.build)
}`
I tried changing the Gatling version in mvn file, but no luck. could someone please help
It means the Gatling jars are not properly imported in your classpath.
No idea how to help you though as you're not describing exactly what you're doing and how you're getting this error: when running maven from the command line? when running from IntelliJ? or another IDE?
Note: if you're struggling with properly setting up a development environment for Scala, you should probably consider using Gatling with Java instead, where the set up is way more simple.

Discord Bot Doesn't Recognize Attributes / Imports it originally had. (Pycord, Nextcord & Replit)

My discord bot was previously running on pycord and only pycord for the previous while, it had several commands and worked fine! When I tried to add nextcord to work on another command, I figured out the hard way that nextcord and pycord are incompatible, upon uninstalling nextcord, it appears that my entire discord bot doesn't recognize old attributes and tokens the way it used to before nextcord was even installed. Generating errors like
python3 -m poetry add discord
/home/runner/bbot-fixed/venv/bin/python3: No module named poetry.__main__; 'poetry' is a package and cannot be directly executed
exit status 1
Replit: Package operation failed.
,
discord.errors.LoginFailure: Improper token has been passed.
,
AttributeError: module 'discord' has no attribute 'Bot'
I've even made a new replit, set it up like I did before, and it still didn't work! putting quite a bit of time into this discord bot, and since it is my first project, I dont want to lose it over a stupid mistake I have made. Any help would be amazing and I do appreciate it.

Cant resolve ipfs-car/blockstore/memory when importing nft.storage

Im trying to store my nft metadata to ipfs using nft.storage (Reactjs)
When I import the library as explained in their docs I get this error
enter image description here
I read a similar error online for web3storage library and that it is probably a webpack version issue, but there is no solution. Any ideas?
This is how I am importing it:
import { NFTStorage, File } from 'nft.storage'
Exactly as shown in the docs.
Since there's insufficient info on how to deal with this out of the box, this is how I resolved it. It worked fine.
Go to node_modules/nft.storage directory.
Make sure you have ipfs-car/dist/esm/blockstore and ipfs-car/dist/esm/pack. If not, install ipfs-car with npm i ipfs-car. Copy ipfs-car/dist/esm to nft.storage/src.
Inside nft.storage/src, update the ipfs-car import statements in the following files like so:
Inside platform.web.js, update to this: import { MemoryBlockStore } from 'ipfs-car/dist/esm/blockstore/memory'
Inside lib.js, update to this: import { pack } from 'ipfs-car/dist/esm/pack'
Inside token.js, update to this: import { pack } from 'ipfs-car/dist/esm/pack'
This solved my problem.
Crude but works.
importing pack from built version should also work but crude as well...the package doesn't work at all without doing these, they should update it...I will send a pull request later on.
import { Web3Storage } from 'web3.storage/dist/bundle.esm.min.js'
I just upgraded Create React App to 5.0.0 (which upgrades to webpack 5) and it's working fine. Some relevant tips here.

TypeError '_Environ' object is not callable

this show up everytime i try launch my discord bot. i tried to google but there wasnt anything good code is
bot.run(os.environ('TOKEN'))
os.environ is a dictionary object. Use os.environ['TOKEN'] or os.environ.get('TOKEN')
You should first import loadenv from a module called dotenv and than you can get the token from .env
pip install python-dotenv That how to install it using pip.
from dotenv import load_dotenv
load_dotenv["token"] # load_dotenv.get('token') work the same as the first one

pycrypto develoment server error "from Crypto.Cipher import blockalgo"

I have installed pycrypto version 2.6 , and i am getting this error
from Crypto.Cipher import blockalgo
ImportError: cannot import name blockalgo
I have read many post but i am unable to solve this problem
If you are not able to import anything from Crypto.Cipher at all, it might be due to folders, crypto and respective egg info, under site-packages are created with lower-case 'c'
/Library/Python/2.7/site-packages/crypto
/Library/Python/2.7/site-packages/crypto-1.0.0-py2.7.egg-info
Imports were successful when same case was used while importing
from crypto.Cipher import AES
or renaming the folders
/Library/Python/2.7/site-packages/Crypto-1.0.0-py2.7.egg-info
/Library/Python/2.7/site-packages/Crypto
I went with the later, to have consistency with others.
I use Eclipse and was able to overcome this problem using one of the above solutions.
Sometimes we overlook these kind of details easily. Its a long shot, hope this helps!

Resources