【发布时间】:2021-07-28 16:22:59
【问题描述】:
代码本质上应该创建一个嵌入,但由于某种原因它给了我错误“'message' is not defined”(嵌入将被放入另一个机器人中)
import discord
from discord.ext import commands
import random
from discord.ext.commands import Bot
class MyClient(discord.Client):
async def on_ready(self):
print('Logged on as', self.user)
channel = self.get_channel(717005397655027805)
await channel.send("I am now online")
messageContent = message.Content
if message.author == self.user:
return
@client.event
async def on_message(message):
if message.content.startswith('!hello'):
embedVar = discord.Embed(
title="Title", description="Desc", color=0x336EFF
)
embedVar.add_field(name="Field1", value="hi", inline=False)
embedVar.add_field(name="Field2", value="hi2", inline=False)
client.send_message(message.channel, embed=embedVar)
PREFIX = ("$")
bot = commands.Bot(command_prefix=PREFIX, description='Hi')
client = MyClient()
client.run('TOKEN')
【问题讨论】:
标签: python discord discord.py