Pycord-Development / pycord

Pycord is a modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python
https://docs.pycord.dev
MIT License
2.75k stars 462 forks source link

AttributeError: module 'discord' has no attribute 'Bot' #2613

Closed lamps-dev closed 1 month ago

lamps-dev commented 1 month ago

Summary

I cannot fix this at all, tried going outside of the environment, same thing.

Reproduction Steps

Paste this code: import client_settings import discord from dotenv import load_dotenv from os import getenv from random import randint

load_dotenv()

token = str(getenv("TOKEN"))

intents = discord.Intents.all()

client = discord.Bot(intents=intents)

async def connect_nodes():

#await client.wait_until_ready()

#nodes = [
    #wavelink.Node(
        #identifier="Node1",
        #uri="http://0.0.0.0:443",
        #password="hidden-for-security"
    #)
#]

#await wavelink.Pool.connect(nodes=nodes, client=client)

@client.event async def on_ready(): print(f'{client.user} has logged in!')

await connect_nodes()

@client.event

async def on_wavelink_node_ready(payload: wavelink.NodeReadyEventPayload):

#print(f"Node with ID {payload.session_id} has connected")
#print(f"Resumed session: {payload.resumed}")

@client.message_command(name="Reverse message") async def reverse_message(ctx, message: discord.Message): await ctx.respond(f"The reversed message is: {message.content[::-1]}")

@client.user_command(name="Member Info") async def member_info(ctx, member: discord.Member): memberinfoembed = discord.Embed( title=f"Username: {member.name}.", description=f"ID: {member.id}.", color=discord.Colour.blue(), ) memberinfoembed.add_field(name="Profile", value=f"Account Creation Date: {member.created_at}\nServer Join Date: {member.joined_at}\nActivity: {member.activity}\nStatus: {member.status}\nRoles: {member.roles}\nServer Nick: {member.nick}\nCurrent guild perms: {member.guild_permissions}", inline=True) memberinfoembed.set_thumbnail(url=f"{member.guild.icon}") memberinfoembed.set_image(url=f"{member.avatar}") await ctx.respond(embed=memberinfoembed)

@client.slash_command(name="help", description="All of the commands.") async def help(ctx: discord.ApplicationContext): embed = discord.Embed( title="Help | All commands.", description="Heres all of the bot's commands.", color=discord.Colour.blue(), ) embed.add_field(name="Fun", value="/dice num1 num2 Rolls a dice.\n/badtranslate text Bad translate some text.\n/anim Uses the anim python lib to anim the 10 latest messages sent in the current channel.", inline=True) embed.add_field(name="Utilities", value="/help Shows this message embed.", inline=True) embed.addfield(name=" _", value="Support Server - Source Code", inline=False) embed.setfooter(text="Bot made by <@1056952213056004118>") await ctx.respond(" _", embed=embed)

@client.slash_command(name="dice", description="Rolls a dice.") @discord.option("num1", type=discord.SlashCommandOptionType.integer) @discord.option("num2", type=discord.SlashCommandOptionType.integer) async def dice(ctx: discord.ApplicationContext, num1: int, num2: int): dicenum = randint(num1, num2) diceembed = discord.Embed( title="Dice", description=f"Dice rolled from {num1} to {num2} and the dice rolled on {dicenum}!", color=discord.Colour.blue(), ) diceembed.set_author(name="Lampyt", icon_url="https://lamps-dev.is-a.dev/pfp.png")

await ctx.respond(embed=diceembed)

class MyView(discord.ui.View): @discord.ui.button(label="Announce", style=discord.ButtonStyle.primary, emoji="📢") async def button_callback(self, button, interaction): await interaction.response.send_message("Clicked.")

@client.slash_command(name="announcement", description="Send an announcement as the bot in a specified channel and ping a specified role or user.") async def announcement(ctx: discord.ApplicationContext): await ctx.respond("Click the announce button to fill a form and to announce your message.", view=MyView())

client.run(token)

Uncomment the connect_nodes and wavelink parts, run the bot. (This could just be an issue with me.)

Minimal Reproducible Code

import client_settings
import discord
from dotenv import load_dotenv
from os import getenv
from random import randint

load_dotenv()

token = str(getenv("TOKEN"))

intents = discord.Intents.all()

client = discord.Bot(intents=intents)

Expected Results

Work as normal and start the bot.

Actual Results

Traceback (most recent call last): File "H:\pycord assistant bot\main.py", line 13, in client = discord.Bot(intents=intents) ^^^^^^^^^^^ AttributeError: module 'discord' has no attribute 'Bot'

Intents

all

System Information

Checklist

Additional Context

I tried adding song playing support from the docs and right after i run the python script, it errored the same thing but even tho i removed the line of code for playing songs, i still get the error.

Icebluewolf commented 1 month ago

Please confirm that you have only the py-cord library installed. Having other discord libraries such as discord.py installed will break py-cord (and is unnecessary). Uninstall any of those libraries and then uninstall py-cord then reinstall py-cord. Then restart your IDE.

lamps-dev commented 1 month ago

it worked thanks a lot