【发布时间】:2021-12-03 07:54:02
【问题描述】:
我的代码应该可以正常工作吗?因为它以前做得很好。现在在我开始运行代码之后。并输入和转发消息。它不会再发送它了。并且获得频道名称而不是获得频道ID会更好吗?如果获取频道 ID 更好,我应该用 if channel.name in 替换什么? , 如果我的代码没问题,这是否意味着问题出在 discod 权限上?
@commands.has_permissions(kick_members=True)
async def alert(ctx, *, msg): #ALERT
for guild in client.guilds:
role = get(guild.roles, name = 'RayGunOptions Alerts') # roles
for channel in guild.channels:
if channel.name in ('????????????????????????-????????????????????????','gunvir-gay'): # change for the list of channel names you got in your discord server
one = Button(style=ButtonStyle.URL, label='Twitter', url="https://twitter.com/RayGunsOptions")
two = Button(style=ButtonStyle.URL, label='Discord', url="https://discord.gg/6Fh4MTZN")
three = Button(style=ButtonStyle.URL, label='Trading Journal', url="https://tradingjournal.com")
embed=discord.Embed(title= ':moneybag: **Option Alert** :moneybag:', description= (msg), url='https://twitter.com/RayGunsOptions', color=0x33FF9F, timestamp=datetime.datetime.utcnow())
"""embed.set_author(name="Crypto Alert", icon_url = ctx.author.avatar_url)""" #Top left name # IGNORE
embed.set_thumbnail(url='https://pbs.twimg.com/profile_images/1383574983645962246/kD6PNI_L_400x400.jpg')
embed.set_footer(icon_url = ctx.author.avatar_url, text='Powered by Duck Programming',)
await channel.send(f"{role.mention}")
await channel.send(embed=embed)
await channel.send(
'** **',
components=[
[one,]
]
)
【问题讨论】:
-
您最近是否添加了
on_message监听器? -
Wdym by on_message?
-
我的代码中没有 on_message 代码行..
标签: python discord.py