Merubokkusu / Discord-S.C.U.M

A Discord API Wrapper for Userbots/Selfbots written in Python.
MIT License
581 stars 170 forks source link

Can't create DM. #441

Open aleperuz opened 1 year ago

aleperuz commented 1 year ago

I wanted to send a message and I read the docs, but i have an error on the function "createDM".

Error:

Traceback (most recent call last):
  File "/data/data/com.termux/files/home/discord/tools/discord_send_message.py", line 16, in <module>
    createDMandSend(id, "hello??")
  File "/data/data/com.termux/files/home/discord/tools/discord_send_message.py", line 8, in createDMandSend
    newDM = bot.createDM([userID]).json()["id"]
            ^^^^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/home/.local/lib/python3.11/site-packages/discum/discum.py", line 257, in createDM
    return imports.Messages(self.discord, self.s, self.log).createDM(recipients)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/home/.local/lib/python3.11/site-packages/discum/messages/messages.py", line 41, in createDM
    self.getMessages(req.json()["id"], num=50, beforeDate=None, aroundMessage=None)
TypeError: Messages.getMessages() missing 1 required positional argument: 'afterMessage'

Function that i use to send messages:

def createDMandSend(userID, message):
                bot.getNotes(userID)
                newDM = bot.createDM([userID]).json()["id"]
                bot.gateway.request.DMchannel(newDM) #op 13 look at private channel
                bot.getMessages(newDM, num=50)
                bot.getProfile(userID)
                bot.sendMessage(newDM, message)
AnksioXD commented 11 months ago

I was able to workaround by changing the getMessages function in discum.py to:

def getMessages(self, channelID, num=1, beforeDate=None, aroundMessage=None, afterMessage=None):
    return imports.Messages(self.discord, self.s, self.log).getMessages(channelID, num, beforeDate, aroundMessage)

and changing getMessages function of messages.py to:

def getMessages(self, channelID, num, beforeDate, aroundMessage):
    url = self.discord + "channels/" + channelID + "/messages?limit=" + str(num)
    if beforeDate != None:
        url += "&before=" + str(beforeDate)
    elif aroundMessage != None:
    url += "&around=" + str(aroundMessage)
    return Wrapper.sendRequest(self.s, 'get', url, log=self.log)