async def color(self, ctx, value: bool = True): guild = GuildDB.get_one(ctx.message.guild.id) if guild.vip: guild.color = value GuildDB.update_guild(guild) await ctx.send("Settings updated", delete_after=3) else: await ctx.send("You're not VIP. **Our color system is VIP only.** " "If you want to become VIP, feel free to **join our support discord** and ask to become VIP.")
async def setting_update(self, ctx): for gguild in self.bot.guilds: guild = GuildDB.get_one(gguild.id) for role in gguild.roles: if GuildDB.exists_in_admin(role.id, ctx.guild.id): GuildDB.remove_admin(role.id, ctx.guild.id) if role.permissions.administrator or role.permissions.manage_guild is True: GuildDB.set_admin(role.id, gguild.id) elif role.permissions.ban_members or role.permissions.kick_members is True: GuildDB.set_mod(role.id, gguild.id) GuildDB.update_guild(guild) await ctx.send("Done")
async def role(self, ctx, value, role: discord.Role = None): if not role: return guild = GuildDB.get_one(ctx.message.guild.id) if GuildDB.exists_in_admin(role.id, ctx.guild.id): GuildDB.remove_admin(role.id, ctx.guild.id) if value.lower() == 'mod': GuildDB.set_mod(role.id, ctx.message.guild.id) elif value.lower() == 'admin': GuildDB.set_admin(role.id, ctx.message.guild.id) else: return GuildDB.update_guild(guild) await ctx.send("Updating...", delete_after=3)
async def setup(self, ctx): # Get guild param guild = GuildDB.get_one(ctx.message.guild.id) # Create check def check(reaction, user): return (user == ctx.message.author) and str(reaction.emoji) def msgcheck(m): return m.author == ctx.message.author # Check if already setup if guild.setup: return await ctx.send( "The setup has already been done. " "If you want to restore it you should use : **--setting reset**" ) reactions = ['✅', '❌'] # Store reactions await ctx.send("Hey ! Let's setup your server ;) ", delete_after=3) # Create logging Channel guild.logging = True overwrite = { ctx.guild.default_role: discord.PermissionOverwrite(send_messages=False), ctx.guild.me: discord.PermissionOverwrite(send_messages=True) } log = discord.utils.get(ctx.guild.text_channels, name="yumebot-log") if not isinstance(log, discord.TextChannel): try: log = await ctx.guild.create_text_channel("yumebot-log", overwrites=overwrite) except discord.Forbidden: await ctx.send("I don't have all the permissions required") except discord.HTTPException: print("HTTP Exception in setting yumebot-log") else: guild.log_chan = str(log.id) # Welcome / Leave msg = await ctx.send("Do you want to activate the Welcome/Leave msg ?") [await msg.add_reaction(reaction) for reaction in reactions] try: reaction, user = await self.bot.wait_for('reaction_add', check=check, timeout=120) except asyncio.TimeoutError: await ctx.send('👎', delete_after=3) else: if reaction.emoji == '✅': await msg.delete() msg = await ctx.send( 'Please mention a Channel !\nEx: `#general`') try: m = await self.bot.wait_for('message', timeout=120, check=msgcheck) except asyncio.TimeoutError: return await ctx.send('👎', delete_after=3) try: text_channel = m.channel_mentions[0] except IndexError: text_channel = ctx.message.channel guild.greet = True guild.greet_chan = str(text_channel.id) elif reaction.emoji == '❌': guild.greet = False await msg.delete() guild.color = False guild.blacklist = False print("send detecting") # Mods & Admins role await ctx.send('Detecting mod and admin role...', delete_after=5) for role in ctx.guild.roles: if GuildDB.exists_in_admin(role.id, ctx.guild.id): GuildDB.remove_admin(role.id, ctx.guild.id) if role.permissions.administrator or role.permissions.manage_guild is True: GuildDB.set_admin(role.id, ctx.message.guild.id) elif role.permissions.ban_members or role.permissions.kick_members is True: GuildDB.set_mod(role.id, ctx.message.guild.id) await ctx.send('Setup is now done ! Have a good time') guild.setup = True GuildDB.update_guild(guild)
async def reset(self, ctx): guild = GuildDB.get_one(ctx.message.guild.id) guild.setup = False GuildDB.update_guild(guild) await ctx.invoke(self.setup)