#old code doesnt work on new computer

1 messages · Page 1 of 1 (latest)

woeful karma
#

I made this bot a long while back and have since reset my computer and have therefore reinstalled python and its libraries. What can i do to make it work again?

import discord
from discord.ext import commands
import asyncio
import subprocess

bot = discord.Bot(case_sensitive=False, command_prefix="/", intents=discord.Intents.default())

goose_count = 0
goose_limit = 2

@bot.slash_command(description = "Says hello!")
async def hello(ctx):
    await ctx.respond(f"Hello!")

@bot.slash_command(description = "Summons a goose on Villeravn's computer!")
async def goose(ctx):
    global goose_count
    if goose_count < goose_limit:
        goosecmd = subprocess.Popen(['"PathToDesktopgoose.exe"'])
        goose_count += 1
        await ctx.respond(f"Summoned new goose on villeravn's computer, total number {goose_count}")
        await asyncio.sleep(90)
        subprocess.Popen.kill(goosecmd)
        goose_count -= 1
        await ctx.respond(f"Goose despawned :slight_frown:, total number {goose_count}")
    elif goose_count >= goose_limit:
        await ctx.respond(f'Already at max count, total number {goose_count}')

bot.run("discord token")#discord token```
nova crown
#

?tag idw

warm pebbleBOT
#

Saying it doesn't work or asking what's wrong with this code? is not helpful for yourself or others.
Describe what you expect and/or tried (with your code), and what isn't going right.
Please provide any errors you get for optimal assistance.

woeful karma
# nova crown ?tag idw

it worked perfectly fine months ago but i have since wiped my computer and therefore had to reinstall python and its libraries, what changes, like changing the version of the library or python can i do to make the code work again or what needs to be updated?

nova crown
#

Like what is happening so that you say it is not working

#

Is there an error?

#

What is the issue specifically

woeful karma
# nova crown how does it not work?

i get this error: Traceback (most recent call last): File "C:\Users\ville\Documents\programing\python\discord\bots\goosebot\goosebot.py", line 29, in <module> bot.run("tokenwasherebutdiscordwarnedme")#discord token ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ville\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\client.py", line 766, in run return future.result() ^^^^^^^^^^^^^^^ File "C:\Users\ville\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\client.py", line 745, in runner await self.start(*args, **kwargs) File "C:\Users\ville\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\client.py", line 709, in start await self.connect(reconnect=reconnect) File "C:\Users\ville\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\client.py", line 601, in connect await self.ws.poll_event() File "C:\Users\ville\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\gateway.py", line 605, in poll_event await self.received_message(msg.data) File "C:\Users\ville\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\gateway.py", line 555, in received_message func(data) File "C:\Users\ville\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\state.py", line 818, in parse_interaction_create interaction = Interaction(data=data, state=self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ville\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\interactions.py", line 171, in __init__ self._from_data(data) File "C:\Users\ville\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\interactions.py", line 201, in _from_data self._guild = Guild(data=self._guild_data, state=self)

nova crown
#

?tag install

warm pebbleBOT
#

1. Uninstall discord.py or any other forks of discord.py you might have with the namespace discord.
python -m pip uninstall discord.py discord -y

2a. Install py-cord
python -m pip install py-cord

2b. Update py-cord
python pip install -U py-cord

Installing other builds:
Note: You need to have git installed. Use ?tag git to find out how to install git.

Updating the module to master branch (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord

nova crown
#

we fixed this on master branch

#

just run the last line of command

woeful karma
# nova crown just run the last line of command

now i get a new error: File "C:\Users\ville\Documents\programing\python\discord\bots\goosebot\goosebot.py", line 29, in <module> bot.run("thetokenwashere")#discord token ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ville\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\client.py", line 766, in run return future.result() ^^^^^^^^^^^^^^^ File "C:\Users\ville\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\client.py", line 745, in runner await self.start(*args, **kwargs) File "C:\Users\ville\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\client.py", line 709, in start await self.connect(reconnect=reconnect) File "C:\Users\ville\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\client.py", line 601, in connect await self.ws.poll_event() File "C:\Users\ville\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\gateway.py", line 605, in poll_event await self.received_message(msg.data) File "C:\Users\ville\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\gateway.py", line 555, in received_message func(data) File "C:\Users\ville\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\state.py", line 818, in parse_interaction_create interaction = Interaction(data=data, state=self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ville\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\interactions.py", line 171, in __init__ self._from_data(data) File "C:\Users\ville\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\interactions.py", line 201, in _from_data self._guild = Guild(data=self._guild_data, state=self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ville\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\guild.py", line 307, in __init__ self._from_data(data) File "C:\Users\ville\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\guild.py", line 515, in _from_data cache_joined = self._state.member_cache_flags.joined ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'Interaction' object has no attribute 'member_cache_flags'

nova crown
#

@crimson kraken ?

#

I’m handing this off to them

crimson kraken
#

Damn ok

#

Oh there's an open pr for this

#

..I think?

#

Or someone mentioned it idk

nova crown
#

@woeful karma this isn’t your fault btw. It’s probably on our end

crimson kraken
#

I'll submit a pr later if there isn't one already

nova crown
#

now I just want to git blame it lol

woeful karma
nova crown
woeful karma
crimson kraken
#

If you wanna patch it yourself, edit that self._guild line to read self._guild = Guild(data=self._guild_data, state=self._state)

nova crown
woeful karma
crimson kraken
#

Nice

woeful karma
#

was it /close to end the thread?

crimson kraken
#

Go for it