実現したいこと
Discord.pyでチケットシステムを構築しようとしているのですが、
チケットを作る際に新しく作成したチャンネルのパーミッションの設定を行いたいのですが、ターゲットとするユーザのIDの取得方法について困っています。
そのユーザーIDは、Discordのチャンネルに設置したボタンを押した人から取得することを考えています。
発生している問題・エラーメッセージ
Ignoring exception in on_socket_response Traceback (most recent call last): File "C:\Users\~\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event await coro(*args, **kwargs) File "C:\Users\~\Python\Python310\lib\site-packages\discord_buttons_plugin\__main__.py", line 17, in soclistener await self.emit(data["data"]["custom_id"], data) File "C:\Users\~\Python\Python310\lib\site-packages\discord_buttons_plugin\__main__.py", line 37, in emit await i(comp) File "C:\Users\~\bot.py", line 50, in start mem = await client.fetch_user(ctx.user.id) AttributeError: 'InteractionContext' object has no attribute 'user'
該当のソースコード
Python
async def create_channel(ctx, channel_name): category_id = ctx.channel.category_id category = ctx.guild.get_channel(category_id) new_channel = await category.create_text_channel(name=channel_name) return new_channel @buttons.click async def start(ctx): dt_now = datetime.datetime.now() time = dt_now.strftime('%Y%m%d%H%M%S') name = '????チケット' + time #チャンネルを新規作成 newc = await create_channel(ctx, channel_name= name) cid = newc.id c = client.get_channel(cid) # ターゲットとするメンバーを取得 mem = await client.fetch_user(ctx.user.id) # 変更する await c.set_permissions(member, send_messages=True, read_messages=True) @client.command() async def tset(message): if message.author.bot: return await message.channel.send(embed=tmes) await buttons.send( content = "↓↓↓", channel = message.channel.id, components = [ ActionRow([ Button( label="????チケット", style=ButtonType().Primary, custom_id="start" ) ]) ] )
まだ回答がついていません
会員登録して回答してみよう