Exemple #1
0
async def createtables():
    engine = loadDB()
    Session = sessionmaker(bind=engine)

    Base.metadata.create_all(engine)

    session = Session()

    luke = Staff(358244935041810443, "lukesaltweather")
    wordref = Staff(345845639663583252, "wordref")
    yankee = Project("Yankee-kun", "active", "https://google.com", "Yankee")
    chapter = Chapter(24, "https://google.com")

    chapter.translator = wordref
    chapter.proofreader = wordref
    chapter.project = yankee
    yankee.typesetter = luke

    session.add(luke)
    session.add(wordref)
    session.add(yankee)
    session.add(chapter)

    session.commit()
    session.close()
Exemple #2
0
 async def addall(self, ctx):
     session = self.bot.Session()
     members = ctx.guild.get_role(self.bot.config.get("neko_workers")).members
     for member in members:
         st = Staff(member.id, member.name)
         session.add(st)
         await ctx.send("Successfully added {} to staff. ".format(member.name))
     session.commit()
     session.close()
Exemple #3
0
async def on_member_update(before: discord.Member , after: discord.Member):
    worker = before.guild.get_role(345799525274746891)
    if worker not in before.roles and worker in after.roles:
        session1 = bot.Session()
        try:
            st = Staff(after.id, after.name)
            session1.add(st)
            session1.commit()
            session1.close()
            channel = before.guild.get_channel(390395499355701249)
            await channel.send("Successfully added {} to staff. ".format(after.name))
        finally:
            session1.close()
Exemple #4
0
 async def addstaffexp(self, ctx, *, arg):
     session1 = self.bot.Session()
     try:
         arg = arg[1:]
         d = dict(x.split('=', 1) for x in arg.split(' -'))
         if d["id"] is not None:
             st = Staff(d["id"], d["name"])
             session1.add(st)
             session1.commit()
             session1.close()
             await ctx.send(f"Successfully added {d['name']} to staff with id {d['id']}")
         else:
             await ctx.send("There seems to be a mistake in the command syntax.")
     finally:
         session1.close()
Exemple #5
0
async def on_member_update(before: discord.Member, after: discord.Member):
    worker = before.guild.get_role(345799525274746891)
    if worker not in before.roles and worker in after.roles:
        session1 = bot.Session()
        try:
            st = Staff(after.id, after.name)
            session1.add(st)
            await session1.commit()
            channel = before.guild.get_channel_or_thread(390395499355701249)
            await channel.send("Successfully added {} to staff. ".format(
                after.name))  # type: ignore
            logging.getLogger("akashi").info(
                f"Added staffmember {before.display_name}.")
        finally:
            await session1.close()
Exemple #6
0
 async def addstaff(self, ctx, *, arg):
     session1 = self.bot.Session()
     try:
         arg = arg[1:]
         d = dict(x.split('=', 1) for x in arg.split(' -'))
         if d["id"] is not None:
             stobject = discord.utils.find(lambda m: m.id == int(d["id"]), ctx.guild.members)
             if stobject is not None:
                 st = Staff(d["id"], stobject.name)
                 session1.add(st)
                 session1.commit()
                 session1.close()
                 await ctx.send("Successfully added {} to staff. ".format(stobject.name))
             else:
                 await ctx.send("Sorry, could not find a user with that ID")
         else:
             await ctx.send("There seems to be a mistake in the command syntax.")
     finally:
         session1.close()
Exemple #7
0
    async def staff(self, ctx: CstmContext, *, flags: AddStaffFlags):
        """
        Description
        ==============
        Add a staffmember to the database.

        Required Role
        =====================
        Role `Neko Herder`.

        Arguments
        ===========
        :member:
            | The Member to be added by Mention, ID, or Name  [:doc:`/Types/discord`]
        """
        member = flags.member
        st = Staff(member.id, member.name)
        ctx.session.add(st)
        await ctx.session.commit()
        await ctx.reply(f"Successfully added {st.name} to staff. ")
        await ctx.success()