Discord bot Python禁止使用403

时间:2018-09-20 02:14:51

标签: python discord discord.py

因此,我一直在尝试打造一个欢迎新用户的不和谐python机器人。但是,每次尝试时,都会出现以下错误。我已经赋予我的漫游器服务器中的所有权限以及那里的每个角色。我不知道怎么了。

 Recognised that a member called Exercise now!!! joined
    Ignoring exception in on_member_join
    Traceback (most recent call last):
      File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\client.py", line 307, in _run_event
        yield from getattr(self, event)(*args, **kwargs)
      File "bot.py", line 37, in on_member_join
        await client.send_message(member, "Welcome to the server")
      File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\client.py", line 1152, in send_message
        data = yield from self.http.send_message(channel_id, content, guild_id=guild_id, tts=tts, embed=embed)
      File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\http.py", line 196, in request
        raise Forbidden(r, data)
    discord.errors.Forbidden: FORBIDDEN (status code: 403): Cannot send messages to this user

这是我的机器人代码,如下所示:

import discord
from discord.ext import commands
import asyncio


client = discord.Client()


@client.event
async def on_ready():
    print('logged in!')
    print(client.user.name)
    print(client.user.id)
    print('-------------')

@client.event
async def on_member_join(member):
    print("Recognised that a member called " + member.name + " joined")
    await client.send_message(member, "Welcome to the server")
    print("sent message to " + member.name)

@client.event
async def on_message(message):
    if message.content.startswith('!Hello'):
        await client.send_message(message.channel, 'hello')
        msg = await client.wait_for_message(author=message.author, content='Hello Creator.')
        await client.send_message(message.channel, 'Hello.')

client.run('my token')

0 个答案:

没有答案