如何使 Twitch Bot 命令仅对管理员可用?有些命令只对管理员可用,有些命令对所有人可用。
那是我的代码:
from twitchio.ext import commands
import openpyxl
from openpyxl import load_workbook
from decouple import config
temp_initial_channels = str(config('CHANNEL'))
temp_xlsx_name = str(config('XLSX_NAME'))
class Bot(commands.Bot):
def __init__(self):
super().__init__(irc_token=config('TMI_TOKEN'), client_id=config('CLIENT_ID'), nick=config('BOT_NICK'), prefix=config('BOT_PREFIX'),
initial_channels=[temp_initial_channels])
async def event_ready(self):
ws = bot._ws
await ws.send_privmsg("whitebot201", f"whitebot201 이 준비 완료 되었습니다!")
async def event_message(self, message):
print(message.content)
await self.handle_commands(message)
@commands.command(name='test')
async def test(self, ctx):
await ctx.send(f'test pass!!!')
bot = Bot()
bot.run()