I am trying to make a bot for my server on discord using Discordia, but when I try to use member:send(str), all I get is Uncaught Error: C:/luvit/deps/coro-channel.lua:62: C:/luvit/deps/discordia/libs/containers/User.lua:91: attempt to call method 'getPrivateChannel' (a nil value)
it does send the dm, but then the code breaks and the bot doesn't run anymore, how can I fix this?
member is a variable that gets the member from message
local member = message.member
I am able to recreate the issue, albeit with a different error that I suspect is due to me not having all your code to debug with. The bot will send the DM and post a message, then crash due to error. You have this code:
I don't know how you find memberid, so I defined it like this:
memberid = message.member:__hash()It is called every time a message is sent, and it sends a message. This means the bot is going to call this and read its own messages. While the bot will not continue into the if statement because its message is not<prefix>createdm, it will still try to get memberid and evaluate the if statement. I do not know how bot users differ from human users in their account metadata, but I strongly suspect there is some difference and this is your issue.I believe adding this to your code, at the beginning of your message callback (before your do anything else to evaluate a message) will fix your problem.
clienthere is whatever you assigneddiscordia.Client()to.