如何在欢迎频道中使用漫游器在会员加入活动中发送欢迎消息?

时间:2019-05-20 10:14:56

标签: python discord discord.py

使用 on_member_join()事件向新成员发送私人消息似乎没有问题,但是找不到在欢迎聊天中发布嵌入消息的方法。

我有一台新的RPG Discord服务器,并想创建一个带有嵌入式消息的欢迎机器人。这个想法是在每次弹出一个随机欢迎消息时都弹出一个随机图像。现在的问题是,我找不到在频道中发布消息的方法,我只找到了一种与漫游器发送私人消息的方法。任何帮助,将不胜感激。创建嵌入消息后,我尝试通过

发送
await bot.send_message(message.channel, embed=embed)

#or

 bot.say(embed = embed)

但是每次我收到类似这样的错误消息

'Bot' object has no attribute 'send_message'.

这是代码:

#The imports, classic stuff
import discord
import random as rng
from discord.ext import commands

bot = commands.Bot(command_prefix = ".")

#To check if the bot is running properly before testing it
@bot.event
async def on_ready():
    print("Bot at Ready.")

#when somebody gets in my sweet sweet server
@bot.event
async def on_member_join(member):
    print(f"{member} has joined.")#makes sure he detected a user has joined. He always does.

    #creates the embedded message
    embed = discord.Embed(
        title = 'Welcome, '+ member.name,
        description = 'This is a welcoming message.',
    )

    #edits the embedded message to add an image and a footer
    embed.set_footer(text = 'this is a footer')
    embed.set_image(url='https://i.imgur.com/ntagZ1z.gifv')

    welcome_pm = 'Something about the rules' #as the name suggests, this is the private message the new user receives 

    await member.send(welcome_pm) #this sends the private message, no issues here
    await bot.send_message(message.channel, embed=embed) #this is the culprit... DAMN YOU !!!

bot.run('this is my token.')

如上所述,我得到了错误 AttributeError:“ Bot”对象没有属性“ send_message”

当我想看到的是嵌入式消息出现在服务器的欢迎聊天中。

感谢您的帮助!

0 个答案:

没有答案
相关问题