【发布时间】:2020-12-12 01:03:13
【问题描述】:
我正在制作一个不和谐的机器人,我想要一个 NSFW 命令,所以我使用了一个放置 NSFW subreddit 的随机图像的命令,但我需要帮助检测 NSFW 频道,所以这个命令不能在非 nsfw 的频道中使用,并发送一条消息说“您需要在 nsfw 频道中使用此命令!” 这是我的命令,但是“else:”部分有错误
async def nsfw(ctx):
if ctx.channel.is_nsfw():
embed = discord.Embed(title="test", description="test")
async with aiohttp.ClientSession() as cs:
async with cs.get('https://www.reddit.com/r/nsfw/new.json?sort=hot') as r:
res = await r.json()
embed.set_image(url=res['data']['children'] [random.randint(0, 25)]['data']['url'])
await ctx.send(embed=embed)
else:
await ctx.send("You need to use this command in a nsfw channel!"
【问题讨论】:
-
你遇到了什么错误?
标签: python discord bots discord.py