個々のサーバーレベルで特定の設定を保存できるように、不和の書き換えでサーバーIDを取得する方法を理解しようとしています。とにかくこれを行うことはありますか?
元のメッセージ/コマンドからコンテキストを収集している場合は、を使用ctx.guild.name
して名前ctx.guild.id
を返すか、コマンドが投稿されたギルドのIDを返すことができます。
例:
bot = commands.Bot(command_prefix='!')
@bot.command(name='whereami', help='print the current server name/id')
async def whereami(ctx):
await ctx.send(f'{ctx.author.name}, you are currently in {ctx.guild.name} ({ctx.guild.id}).')
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加