Changed so that people with manage roles can add and delete tags
This commit is contained in:
parent
5caf602f79
commit
1f8856b277
@ -6,6 +6,18 @@ class BotManager:
|
|||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
|
async def on_member_join(self, member):
|
||||||
|
# If the member is not a bot
|
||||||
|
if member.bot is False:
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
# The member is a bot
|
||||||
|
# Add role testing bot
|
||||||
|
await member.add_roles(discord.utils.get(member.guild.roles, name='Bot to test'))
|
||||||
|
await self.bot.db_con.fetch('select prefix from bots where id = $1', member.id)
|
||||||
|
await member.nick('[' + await self.bot.db_con.fetch('select prefix from bots where id = $1', member.id)
|
||||||
|
+ ']' + member.name)
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def invite(self, ctx, bot: discord.User=None, prefix=None):
|
async def invite(self, ctx, bot: discord.User=None, prefix=None):
|
||||||
if not bot:
|
if not bot:
|
||||||
@ -15,12 +27,12 @@ class BotManager:
|
|||||||
if not prefix:
|
if not prefix:
|
||||||
raise Warning('Please provide a prefix')
|
raise Warning('Please provide a prefix')
|
||||||
|
|
||||||
# Make sure that the bot has not been invited already and is no being tested
|
# Make sure that the bot has not been invited already and it is not being tested
|
||||||
if await self.bot.db_con.fetch('select count(*) from bots where id = $1', bot.id) == 1:
|
if await self.bot.db_con.fetch('select count(*) from bots where id = $1', bot.id) == 1:
|
||||||
raise Warning('The bot has already been invited')
|
raise Warning('The bot has already been invited or is being tested')
|
||||||
|
|
||||||
await self.bot.db_con.execute('insert into bots (id, owner, prefix) values ($1, $2, $3)'
|
await self.bot.db_con.execute('insert into bots (id, owner, prefix) values ($1, $2, $3)',
|
||||||
, bot.id, ctx.author.id, prefix)
|
bot.id, ctx.author.id, prefix)
|
||||||
|
|
||||||
em = discord.Embed(colour=self.bot.embed_color)
|
em = discord.Embed(colour=self.bot.embed_color)
|
||||||
em.title = "Hello {},".format(ctx.author.name)
|
em.title = "Hello {},".format(ctx.author.name)
|
||||||
@ -30,6 +42,7 @@ class BotManager:
|
|||||||
await ctx.send(embed=em)
|
await ctx.send(embed=em)
|
||||||
|
|
||||||
em = discord.Embed(title="Bot invite", colour=discord.Color(0x363941))
|
em = discord.Embed(title="Bot invite", colour=discord.Color(0x363941))
|
||||||
|
em.description = "To start to test the bot, use `ds!start <bot_id>` and to finish testing it use `ds!finish`"
|
||||||
em.set_thumbnail(url=bot.avatar_url)
|
em.set_thumbnail(url=bot.avatar_url)
|
||||||
em.add_field(name="Bot name", value=bot.name)
|
em.add_field(name="Bot name", value=bot.name)
|
||||||
em.add_field(name="Bot id", value="`" + str(bot.id) + "`")
|
em.add_field(name="Bot id", value="`" + str(bot.id) + "`")
|
||||||
@ -45,6 +58,12 @@ class BotManager:
|
|||||||
raise Warning('You must include the id of the bot you are going to test... Be exact.')
|
raise Warning('You must include the id of the bot you are going to test... Be exact.')
|
||||||
|
|
||||||
if await self.bot.db_con.fetchrow('select * from bots where id = $1', bot.id):
|
if await self.bot.db_con.fetchrow('select * from bots where id = $1', bot.id):
|
||||||
|
if discord.utils.get(ctx.guild.roles, name='Bot to test') in bot.roles:
|
||||||
|
raise Warning('The bot is already being tested')
|
||||||
|
|
||||||
|
await bot.remove_roles(discord.utils.get(ctx.guild.roles, name='Bot to test'))
|
||||||
|
await bot.add_roles(discord.utils.get(ctx.guild.roles, name='Bot testing'))
|
||||||
|
|
||||||
user = await self.bot.db_con.fetch('select owner from bots where id = $1', bot.id)
|
user = await self.bot.db_con.fetch('select owner from bots where id = $1', bot.id)
|
||||||
await ctx.get_user(user).send('Your bot is being tested by ' + str(ctx.author))
|
await ctx.get_user(user).send('Your bot is being tested by ' + str(ctx.author))
|
||||||
await ctx.send('The owner has been warned')
|
await ctx.send('The owner has been warned')
|
||||||
@ -65,6 +84,10 @@ class BotManager:
|
|||||||
|
|
||||||
if await self.bot.db_con.fetchrow('select * from bots where id = $1', bot.id):
|
if await self.bot.db_con.fetchrow('select * from bots where id = $1', bot.id):
|
||||||
user = await self.bot.db_con.fetch('select owner from bots where id = $1', bot.id)
|
user = await self.bot.db_con.fetch('select owner from bots where id = $1', bot.id)
|
||||||
|
|
||||||
|
await bot.remove_roles(discord.utils.get(ctx.guild.roles, name='Bot testing'))
|
||||||
|
await bot.add_roles(discord.utils.get(ctx.guild.roles, name='Bot'))
|
||||||
|
|
||||||
await ctx.get_user(user).send('Your bot has been tested by ' + str(ctx.author) + '\n**Result:** Approved')
|
await ctx.get_user(user).send('Your bot has been tested by ' + str(ctx.author) + '\n**Result:** Approved')
|
||||||
await ctx.send('The owner has been warned')
|
await ctx.send('The owner has been warned')
|
||||||
else:
|
else:
|
||||||
@ -81,6 +104,7 @@ class BotManager:
|
|||||||
|
|
||||||
if await self.bot.db_con.fetchrow('select * from bots where id = $1', bot.id):
|
if await self.bot.db_con.fetchrow('select * from bots where id = $1', bot.id):
|
||||||
user = await self.bot.db_con.fetch('select owner from bots where id = $1', bot.id)
|
user = await self.bot.db_con.fetch('select owner from bots where id = $1', bot.id)
|
||||||
|
await bot.kick()
|
||||||
await ctx.get_user(user).send('Your bot has been tested by ' + str(ctx.author) +
|
await ctx.get_user(user).send('Your bot has been tested by ' + str(ctx.author) +
|
||||||
'\n**Result:** Declined\n**Reason:** ' + reason)
|
'\n**Result:** Declined\n**Reason:** ' + reason)
|
||||||
await ctx.send('The owner has been warned')
|
await ctx.send('The owner has been warned')
|
||||||
|
|||||||
@ -45,7 +45,7 @@ class Tag:
|
|||||||
async def add(self, ctx, tag_name=None, *, tag_info=None):
|
async def add(self, ctx, tag_name=None, *, tag_info=None):
|
||||||
"""Adds a new tag"""
|
"""Adds a new tag"""
|
||||||
await ctx.trigger_typing()
|
await ctx.trigger_typing()
|
||||||
if not ctx.author.guild_permissions.manage_guild:
|
if not ctx.author.guild_permissions.manage_roles:
|
||||||
return await ctx.send("You are not allowed to do this")
|
return await ctx.send("You are not allowed to do this")
|
||||||
|
|
||||||
if tag_name is None or tag_info is None:
|
if tag_name is None or tag_info is None:
|
||||||
@ -71,7 +71,7 @@ class Tag:
|
|||||||
async def remove(self, ctx, tag=None):
|
async def remove(self, ctx, tag=None):
|
||||||
"""Remove a existing tag"""
|
"""Remove a existing tag"""
|
||||||
await ctx.trigger_typing()
|
await ctx.trigger_typing()
|
||||||
if not ctx.author.guild_permissions.manage_guild:
|
if not ctx.author.guild_permissions.manage_roles:
|
||||||
return await ctx.send("You are not allowed to do this")
|
return await ctx.send("You are not allowed to do this")
|
||||||
|
|
||||||
if tag is None:
|
if tag is None:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user