Beispiel #1
0
    async def Call(self, context, classroom, showAll: bool):
        class_role = Tools.convert(classroom)
        data = readGuild(context.guild.id)
        if class_role is None:
            await Tools.embedError("This is not a role, but a specific user")
        else:
            if Tools.got_the_role(data["teacher"], context.author):
                self.callList[
                    f"{context.guild.id}-{context.message.id}"] = Check(
                        class_role, context.message.author, showAll,
                        data["delay"] if data["delay"] > 0 else 0)
                message = returnLanguage(data["language"], "startcall")

                embed = discord.Embed(color=discord.Colour.green(),
                                      title=message[0],
                                      description=message[1])
                embed.set_author(name=Tools.name(context.message.author),
                                 icon_url=context.message.author.avatar_url)
                embed.add_field(name=f"**__{message[2]}__**", value=classroom)
                embed.add_field(name="Date",
                                value=date.today().strftime("%d/%m/%Y"))
                embed.set_footer(text=message[3])

                await context.channel.send(embed=embed)
                await context.message.add_reaction(
                    "✅")  # on rajoute les réactions ✅ & 🆗
                await context.message.add_reaction("🆗")
                await context.message.add_reaction("🛑")
            else:
                await context.channel.send("<@{}> : {}".format(
                    context.author.id,
                    returnLanguage(data["language"], "notTeacher")))
Beispiel #2
0
    async def rmRole(context, value, args):
        guild = str(context.guild.id)
        data = readGuild(guild)
        if not data["admin"]:
            await Tools.embedError(
                context.channel,
                returnLanguage(data["language"], "zeroPrivileges"))
        elif Tools.got_the_role(data["admin"], context.author):
            embed = discord.Embed(color=discord.Colour.orange())
            embed.set_author(
                name="CheckStudents",
                url="https://github.com/Renaud-Dov/CheckStudents",
                icon_url=
                "https://raw.githubusercontent.com/Renaud-Dov/CheckStudents/master/img/logo.png"
            )

            removed_roles = ""
            not_removed_roles = ""

            for i in args:
                role = Tools.convert(i)
                if role in data[value]:
                    removed_roles += i + "\n"
                    data[value].remove(role)
                else:
                    not_removed_roles += i + "\n"

            if removed_roles == "" and not_removed_roles == "":
                embed.add_field(
                    name="You need to write role(s) to use the command",
                    value=f"{value} rm @role")
                await context.channel.send(embed=embed)
            else:
                if removed_roles != "":
                    embed.add_field(name="Removed roles", value=removed_roles)
                if not_removed_roles != "":
                    embed.add_field(name=f"Was not an {value}",
                                    value=not_removed_roles)
                editGuild(guild, data)
                await Admin.AdminCommand(context, embed, "Remove Command")
        else:
            await Tools.embedError(
                context.channel,
                returnLanguage(data["language"], "NoPrivileges"))
Beispiel #3
0
    async def addRole(context, value, args):
        guild = str(context.guild.id)
        data = readGuild(guild)
        if data["admin"] != [] and not Tools.got_the_role(
                data["admin"], context.author):
            await Tools.embedError(
                context.channel,
                returnLanguage(data["language"], "NoPrivileges"))
        else:
            embed = discord.Embed(color=discord.Colour.orange())
            embed.set_author(
                name="CheckStudents",
                url="https://github.com/Renaud-Dov/CheckStudents",
                icon_url=
                "https://raw.githubusercontent.com/Renaud-Dov/CheckStudents/master/img/logo.png"
            )

            added_roles = ""
            already_added_roles = ""
            for i in args:

                role = Tools.convert(i)

                if role not in data[value]:
                    data[value].append(role)
                    added_roles += i + "\n"
                else:
                    already_added_roles += i + "\n"

            if added_roles == "" and already_added_roles == "":
                embed.add_field(
                    name="You need to add roles to use the command",
                    value=f"{value} add @role1 @role2")
                await context.channel.send(embed=embed)
            else:
                if added_roles != "":
                    embed.add_field(name="Added roles", value=added_roles)
                if already_added_roles != "":
                    embed.add_field(name="Already added",
                                    value=already_added_roles)
                editGuild(guild, data)
                await Admin.AdminCommand(context, embed, "Add teacher Command")