首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >检查消息中的单词先前定义的str disnake (discord.py)

检查消息中的单词先前定义的str disnake (discord.py)
EN

Stack Overflow用户
提问于 2021-12-14 17:45:41
回答 1查看 227关注 0票数 0

所以,我正在做一个命令,把一个消息发布到一个特定的渠道,我需要做它,所以付款选项,如果说买卖,而不是什么时候选择广告。总之要这么做?(使用disnake)

代码语言:javascript
复制
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.")
    ```
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-12-14 18:35:52

下面是如何查找字符串中的单词:

代码语言:javascript
复制
word = "example"
if word in example_string: 
   # do what you want here
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70353383

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档