TypeError: Client.change_presence() missing 1 required positional argument: 'self'

I am trying to make my bot change status every hour but it gives me the error in the title, I tried putting self but it would give me this error: AttributeError: 'statusscript' object has no attribute 'ws'.

    global list
    list = ["1", "2", "3"]

    @commands.command(aliases=['add'])
    async def addstatus(self, ctx, *, arg):
        global list

        list.append(arg)
        await ctx.send(f'`{arg}` added to status list')

    @commands.command()
    async def startstatus(self, ctx):
        @tasks.loop(seconds=3600)
        async def looper(self):
            duration = 3600
            print(f"LOOPER IS RUNNING EVERY {duration} SECONDS!")
            selected = random.choice(list)
            activity = selected
            client = commands.Bot
            await client.change_presence(activity=discord.Game(activity))
        looper.start(self)

Solution 1:

  1. Don't use variable names that are built-in data types. It sometimes doesn't work well, so it's a good practice to avoid it.
  2. I'm guessing this is a Cog because of self. Then when you want to refer to client you have to use self.client.

I created Test cog to let you see how it should look like:

class Test(commands.Cog):
    def __init__(self, client):
        self.client = client

    global status_list
    status_list = ["1", "2", "3"]

    @commands.command(aliases=['add'])
    async def addstatus(self, ctx, *, arg):
        global status_list

        status_list.append(arg)
        await ctx.send(f'`{arg}` added to status list')

    @commands.command()
    async def startstatus(self, ctx):
        self.looper.start()

    @tasks.loop(seconds=3600) # you can also use "hours=1" instead of seconds
    async def looper(self):
        duration = 3600
        print(f"LOOPER IS RUNNING EVERY {duration} SECONDS!")
        activity = random.choice(status_list)
        await self.client.change_presence(activity=discord.Game(activity)) # because you are in "Cog" you have to use self.client to refer to client

client.add_cog(Test(client))