I'm trying to send a dm to a specific user with the command .dmtest, but whenever I run the command I get the error mentioned in the title Here is my code:
import discord
from discord.ext import commands
import os
import requests
import asyncio
from keep_alive import keep_alive
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('.dmtest'):
user = client.get_user(384185404510961664)
# await message.author.send(...)
await message.channel.send('test worked')
await user.send('a')
keep_alive()
client.run(os.getenv('TOKEN'))
Error:
line 78, in on_message
await user.send('a')
AttributeError: 'NoneType' object has no attribute 'send'