Search code examples
pythontwittertweepy

"takes 1 positional argument but 2 positional arguments (and 1 keyword-only argument) were given"


I'm creating a twitter-bot which should create tweets with random words. Therefore I created two Arrays with strings to put them inside of the tweet. Inside of client.create_tweet I tried to use the random.choice function, but it doesn't work. It appears an error:

Client.create_tweet() takes 1 positional argument but 2 positional arguments (and 1 keyword-only argument) were given.
from email.utils import localtime
import tweepy 
import time
import random

name = ["x", "y", "z"]
adjektiv = ["a", "b", "c"]




class MyStream(tweepy.StreamingClient): 
    def on_tweet(self, tweet):
        print(tweet.text)

        client.retweet(tweet.id)

        client.like(tweet.id)

        client.create_tweet(tweet.id, text = random.choice(name) + " is "+          random.choice(adjektiv))
       
        time.sleep(5)

Solution

  • create_tweet doesn't have a tweet_id argument. Remove it and you should be OK:

    client.create_tweet(text = random.choice(name) + " is " + random.choice(adjektiv))