【发布时间】:2020-07-26 15:09:28
【问题描述】:
我对 python 很陌生,所以我认为一个好的学习项目是为个人服务器创建一个不和谐的机器人,我有一些命令只有我作为机器人的所有者才能访问,但我希望能够使用命令切换该访问权限,以便我的朋友也可以使用它们,但我有一个问题,这是给我一个错误的代码:
MyID = '<@xxxxxxxxxxxxxxxx>'
FFA = False
class TestCommands(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
def IDCheck(ctx):
return ctx.message.author.id == xxxxxxxxxxxxxxxxxxxxxx
@commands.command()
async def ToggleFFA(ctx):
if FFA == False:
FFA = True
print (FFA)
await message.channel.send('All user can now use owner locked commands')
if FFA == True:
FFA = False
print (FFA)
await message.channel.send('All user can no longer use owner locked commands')
###########################################################################
@commands.command()
if FFA == False:
@commands.check(IDCheck)
async def FFATest(self, ctx, *, question):
loopnumber = 0
while spamnumber < int(question):
await ctx.send('Test' + MyID);
await asyncio.sleep(1)
loopnumber += 1
print ({loopnumber})
if FFA == True:
async def LoopTest(self, ctx, *, question):
loopnumber = 0
while loopnumber < int(question):
await ctx.send('Test' + MyID);
await asyncio.sleep(1)
loopnumber+= 1
print ({loopnumber})
###########################################################################
在突出显示的代码段中出现无效语法错误。如果有人知道切换访问的更简单方法或我可以纠正错误的方法,我将不胜感激。
提前致谢。
【问题讨论】:
标签: python discord.py