discordbotの管理者のみ実行できるコマンドをまとめたクラスでグローバルチェックがうまくいかず、@commands.is_owner()を使っていました。うまく動作しない理由を教えてください。
以下がコードの一部です
class SuperUser(commands.Cog, Everyone): # 現在うまく動作しない部分(オーナーのidの中には個人のuser_idが入る(int)) @commands.check async def is_owner(self, ctx): return ctx.author.id == オーナーのid # 再接続 @commands.command() @commands.is_owner() async def db_conn(self, ctx): self.conn = await asyncpg.connect(self.dsn) await ctx.send("データベースに接続します") # 入力クエリ実行 @commands.command() @commands.is_owner() async def db_query1(self, ctx, *, query): await ctx.send(query) await self.conn.execute(query) # 出力クエリ実行 @commands.command() @commands.is_owner() async def db_query2(self, ctx, *, query): txt = "" rows = await self.conn.fetch(query) for row in rows: txt += f"{row}\n" await ctx.send(txt)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。