【问题标题】:How to make Only you can see this message in Discord py?如何使只有您可以在 Discord py 中看到此消息?
【发布时间】:2022-10-30 23:14:21
【问题描述】:

如何使只有您可以在 Discord py 中看到此消息?

我想在 discord.py 中使用“只有你可以看到这条消息”来让 discord bot 回复用户

import discord
from discord.ext import commands

client = commands.Bot(
    help_command=None,
    command_prefix=">"
)
@client.event
async def on_ready():
    print('Connection as {0.user}'.format(client))

@client.command()
async def Hi(ctx):
    await ctx.reply('Hello')

client.run('token')

【问题讨论】:

标签: python discord.py


【解决方案1】:

有两种方法可以做到这一点:

一个简单的解决方案是通过向用户发送 DM(直接消息),这是一个示例:

DM = await ctx.author.create_dm()
await DM.send("Hello")

另一种解决方案,更复杂的是通过响应与临时消息的交互,这些消息与斜杠命令和按钮有关。如果你还没有处理交互,我不建议这样做,因为你必须实现很多东西。

【讨论】:

    【解决方案2】:

    如果您只需要显示此消息,那么

    @client.command()
    async def Hi(ctx):
        await ctx.send('Hello')
    

    【讨论】:

      猜你喜欢
      • 2022-06-30
      • 2021-07-05
      • 1970-01-01
      • 2022-11-26
      • 2020-10-26
      • 2019-10-02
      • 2021-12-08
      • 1970-01-01
      • 2020-04-07
      相关资源
      最近更新 更多