Create is_moderator check
This commit is contained in:
parent
d0bab4a179
commit
c317077d8f
@ -235,6 +235,7 @@ class Rcon(commands.Cog):
|
|||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
|
@checks.is_moderator()
|
||||||
async def listplayers(self, ctx, *, server_name=None):
|
async def listplayers(self, ctx, *, server_name=None):
|
||||||
"""Lists the players currently connected to the specified ARK server.
|
"""Lists the players currently connected to the specified ARK server.
|
||||||
The specified server must already be in the current guild\'s configuration.
|
The specified server must already be in the current guild\'s configuration.
|
||||||
@ -245,8 +246,6 @@ class Rcon(commands.Cog):
|
|||||||
first_last
|
first_last
|
||||||
"first last"
|
"first last"
|
||||||
To view all the valid ARK servers for this guild see list_ark_servers."""
|
To view all the valid ARK servers for this guild see list_ark_servers."""
|
||||||
if await checks.is_rcon_admin(self.bot, ctx):
|
|
||||||
|
|
||||||
if server_name:
|
if server_name:
|
||||||
server_name = server_name.replace('_', ' ').title()
|
server_name = server_name.replace('_', ' ').title()
|
||||||
msg = await ctx.send(f'**Getting Data for the {server_name} server**')
|
msg = await ctx.send(f'**Getting Data for the {server_name} server**')
|
||||||
@ -303,8 +302,6 @@ class Rcon(commands.Cog):
|
|||||||
asyncio.ensure_future(asyncio.gather(*futures))
|
asyncio.ensure_future(asyncio.gather(*futures))
|
||||||
else:
|
else:
|
||||||
await ctx.send('There are no available servers for this guild.')
|
await ctx.send('There are no available servers for this guild.')
|
||||||
else:
|
|
||||||
await ctx.send(f'You are not authorized to run this command.')
|
|
||||||
|
|
||||||
# @commands.command()
|
# @commands.command()
|
||||||
# @commands.guild_only()
|
# @commands.guild_only()
|
||||||
|
|||||||
@ -5,3 +5,29 @@ def is_me():
|
|||||||
def predicate(ctx):
|
def predicate(ctx):
|
||||||
return ctx.message.author.id == ctx.bot.owner_id
|
return ctx.message.author.id == ctx.bot.owner_id
|
||||||
return discord.ext.commands.check(predicate)
|
return discord.ext.commands.check(predicate)
|
||||||
|
|
||||||
|
|
||||||
|
def is_moderator():
|
||||||
|
async def predicate(ctx):
|
||||||
|
resp = await ctx.bot.aio_session.get(f'{ctx.bot.api_base}/guilds/{ctx.guild.id}/roles/moderator/',
|
||||||
|
headers=ctx.bot.auth_header)
|
||||||
|
if resp.status == 200:
|
||||||
|
mod_roles = await resp.json()
|
||||||
|
for role in mod_roles:
|
||||||
|
if discord.utils.get(ctx.author.roles, id=role["id"]):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
return discord.ext.commands.check(predicate)
|
||||||
|
|
||||||
|
|
||||||
|
def is_admin():
|
||||||
|
async def predicate(ctx):
|
||||||
|
resp = await ctx.bot.aio_session.get(f'{ctx.bot.api_base}/guilds/{ctx.guild.id}/roles/admin/',
|
||||||
|
headers=ctx.bot.auth_header)
|
||||||
|
if resp.status == 200:
|
||||||
|
admin_roles = await resp.json()
|
||||||
|
for role in admin_roles:
|
||||||
|
if discord.utils.get(ctx.author.roles, id=role["id"]):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
return discord.ext.commands.check(predicate)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user