-1

I have a problem in python, i'm coding my own discord.py bot and i have really annoying problem.

My code:

    import discord
from discord.ext import commands
from discord.ext.commands import Bot
import asyncio
import random


client = discord.Client()


bot = commands.Bot(command_prefix='!')

print ("Discord version: " + discord.__version__)

@bot.event
async def on_ready():
print ("Logged in as " + bot.user.name)
await client.change_presence(discord.Game(name="use !commands"))
hotline1337
  • 47
  • 1
  • 6

1 Answers1

2

Try changing the positional argument you have in change_presence to a keyword argument: according to the docs, that would be game.

Hence

client.change_presence(discord.Game(name="use !commands"))

to

client.change_presence(game=discord.Game(name="use !commands")).

In addition if we check out the source code for discord.py, we can see the exact reason for your error.

Line 409 in this file defines change_presence as

def change_presence(self, *, game=None, status=None, afk=False, since=0.0, idle=None)

we can see the asterisk (*) right after the self argument which is Python 3 semantics for accepting only keyword arguments after the asterisk.

You can see this StackOverflow answer for some more information.

That means that all arguments after self are purely keyword arguments (need an identifier), you are passing an argument which coupled with self (passed in automatically) makes two positional arguments when the maximum positional arguments are just one (which is self). So you must change your positional argument to a keyword one.

Ziyad Edher
  • 2,150
  • 18
  • 31