[英]Checking for word in message previous defined str disnake (discord.py)
因此,我正在发出命令将消息发布到特定渠道,并且我需要这样做,以便在说购买或出售而不是选择广告时出现付款选项。 无论如何要这样做? (使用蛇)
try:
await asyncio.sleep(2)
await channel2.send(f"Please send the Post type `Advertisement` , `Selling` , `Buying` {inter.author.mention}")
msg = await self.bot.wait_for('message', check=check, timeout=120)
PType = str(msg.content)
await channel2.send("Please provide the name of the post:")
msg2 = await self.bot.wait_for('message', check=check, timeout=120)
Pname = str(msg2.content)
await channel2.send("Please provide the body of the post:")
msg3 = await self.bot.wait_for('message', check=check, timeout=120)
Body = str(msg3.content)
if "Advertisement" not in msg.content.lower():
await channel2.send("Please Provide payment option")
msg2 = await self.bot.wait_for("message", check=check, timeout=120)
Payment = str(msg2.content)
await channel2.send("Please Provide payment amount")
msg2 = await self.bot.wait_for("message", check=check, timeout=120)
Amount = str(msg2.content)
await channel2.send("Please wait for moderation to approve your message.")
reportchannel = disnake.utils.get(guild.channels, id=920358352876355664)
rem = disnake.Embed(title=f"New post created by {user.display_name}/{user.id}", description="-")
rem.add_field(name=f"Post Type: {PType}", value=f"-")
rem.add_field(name=f"{Pname}", value=f"{Body}")
if "Advertisement" not in msg.content.lower():
rem.add_field(name="Payment Type:", value=f"{Payment}")
rem.add_field(name="Payment:", value=f"{Amount}")
await reportchannel.send(embed=rem)
await asyncio.sleep(15)
await channel2.delete()
except asyncio.TimeoutError:
await channel2.delete()
await user.send("Your channel was deleted due to a timeout. The time is limited to 120 seconds.")
```
以下是如何查找一个单词是否在字符串中:
word = "example"
if word in example_string:
# do what you want here
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.