コード例 #1
0
ファイル: exp.py プロジェクト: manemejeff/MarvinBot
    async def display_level(self, ctx, target: Optional[Member]):
        target = target or ctx.author
        xp, lvl = db.record("SELECT XP, Level FROM exp WHERE UserID = ?", target.id) or (None, None)

        if lvl:
            await ctx.send(f'{target.display_name} is on level {lvl:,} with {xp:,} XP.', delete_after=10)

        else:
            await ctx.send('That member does not have a level.', delete_after=10)
コード例 #2
0
    async def show_balance(self, ctx, target: Optional[Member]):
        target = target or ctx.author
        wallet, bank = db.record(
            "SELECT Wallet, Bank FROM economy WHERE UserID = ?",
            target.id) or (None, None)
        if wallet is not None:
            pass
        else:
            db.execute("INSERT INTO economy (UserID) VALUES (?)", target.id)
            wallet, bank = db.record(
                f"SELECT Wallet, Bank FROM economy WHERE UserID = ?",
                target.id)

        wallet_embed = Embed(title="ECONOMY", timestamp=datetime.utcnow())
        wallet_embed.add_field(name=f"{target.display_name}'s Economy",
                               value=f"Wallet: {wallet:,} \n Bank: {bank:, }",
                               inline=False)
        await ctx.send(embed=wallet_embed)
コード例 #3
0
    def update_completion_command(self, ctx, name: str, newState: str):
        due_date = db.record(
            "SELECT DueDate FROM assignments WHERE UserID = ? AND Name = ?",
            ctx.author.id, name)
        db.execute("UPDATE assignments SET Completed = ? WHERE Name = ?",
                   newState, name)

        embed = Embed(title="Assignment's Completion Changed")
        embed.add_field(name=f"**{name}**",
                        value=f"Due: {due_date[0]}\nCompleted: {newState}",
                        inline=True)

        return embed
コード例 #4
0
    async def on_raw_reaction_add(self, payload):

        if self.bot.ready and payload.message_id == self.reaction_message.id:
            current_colours = filter(lambda r: r in self.colours.values(), payload.member.roles)
            await payload.member.remove_roles(*current_colours, reason='Colour role reaction')
            await payload.member.add_roles(self.colours[payload.emoji.name], reason='Colour role reaction')
            await self.reaction_message.remove_reaction(payload.emoji, payload.member)

        elif payload.message_id in (poll[1] for poll in self.polls):
            message = await self.bot.get_channel(payload.channel_id).fetch_message(payload.message_id)

            for reaction in message.reactions:
                if (not payload.member.bot
                        and payload.member in await reaction.users().flatten()
                        and reaction.emoji != payload.emoji.name):
                    await message.remove_reaction(reaction.emoji, payload.member)

        elif payload.emoji.name == "⭐":
            message = await self.bot.get_channel(payload.channel_id).fetch_message(payload.message_id)

            if not message.author.bot and payload.member.id != message.author.id:
                msg_id, stars = db.record("SELECT StarMessageID, Stars FROM starboard WHERE RootMessageID = ?",
                                          message.id) or (None, 0)

                embed = Embed(title='Starred message',
                              colour=message.author.colour,
                              timestamp=datetime.utcnow())

                fields = [
                    ('Author', message.author.mention, False),
                    ('Content', message.content, False),
                    ('Stars', stars + 1, False)
                ]
                for name, value, inline in fields:
                    embed.add_field(name=name, value=value, inline=inline)

                if len(message.attachments):
                    embed.set_image(url=message.attachments[0].url)

                if not stars:
                    star_message = await self.starboard_channel.send(embed=embed)
                    db.execute("INSERT INTO starboard (RootMessageID, StarMessageID) VALUES (?, ?)", message.id,
                               star_message.id)

                else:
                    star_message = await self.starboard_channel.fetch_message(msg_id)
                    await star_message.edit(embed=embed)
                    db.execute("UPDATE starboard SET Stars = Stars + 1 WHERE RootMessageID = ?", message.id)

            else:
                await message.remove_reaction(payload.emoji, payload.member)
コード例 #5
0
    async def rob_other_users(self, ctx, target: Member = None):
        wut = self.bot.get_emoji(settings['emojis']['wut'])
        if target is None:
            await ctx.send(f"{wut} who is the user bro !")
            return

        target_bal = db.record("SELECT Wallet FROM economy WHERE UserID = ?",
                               target.id) or None
        if target_bal is None:
            await ctx.send("That user doesn't have a bank account")
            return

        user_bal = db.record("SELECT Wallet FROM economy WHERE UserID = ?",
                             ctx.author.id) or None
        if user_bal is None:
            db.execute("INSERT INTO economy (UserID) VALUES (?)",
                       ctx.author.id)

        loot = randint(1, 100)
        chances = randint(1, 100)

        if chances <= 50:
            await ctx.send("You got caught by the police")
            await ctx.send(f"Now u have to pay {loot} to {target.display_name}"
                           )
            db.execute(
                "UPDATE economy SET Wallet = Wallet - ? WHERE UserID = ?",
                loot, ctx.author.id)
            db.execute(
                "UPDATE economy SET Wallet = Wallet + ? WHERE UserID = ?",
                loot, target.id)
            return

        db.execute("UPDATE economy SET Wallet = Wallet + ? WHERE UserID = ?",
                   loot, ctx.author.id)
        db.execute("UPDATE economy SET Wallet = Wallet - ? WHERE UserID = ?",
                   loot, target.id)
        await ctx.send(f"You robbed ${loot} from {target.display_name}")
コード例 #6
0
    def edit_date_command(self, ctx, name: str, newDate: str):
        completion = db.record(
            "SELECT DueDate, Completed FROM assignments WHERE UserID = ? AND Name = ?",
            ctx.author.id, name)

        db.execute("UPDATE assignments SET DueDate = ? WHERE Name = ?",
                   newDate, name)

        embed = Embed(title="Assignment's Date Changed")
        embed.add_field(name=f"**{name}**",
                        value=f"Due on {newDate}\nCompleted: {completion}",
                        inline=True)

        return embed
コード例 #7
0
    def display_assignment(self, title: str, UserID: int, name: str):
        try:
            due_date, completion = db.record(
                "SELECT DueDate, Completed FROM assignments WHERE UserID = ? AND Name = ?",
                UserID, name)
        except:
            return Embed(title="No Assignment Found")

        embed = Embed(title=title, )
        embed.add_field(name=f"**{name}**",
                        value=f"Due: {due_date}\nCompleted: {completion}",
                        inline=True)

        return embed
コード例 #8
0
    async def daily_reward(self, ctx):
        wallet = db.record("SELECT Wallet FROM economy WHERE UserID = ?",
                           ctx.author.id) or None

        daily_reward = 100

        if wallet is not None:
            db.execute(
                "UPDATE economy SET Wallet = Wallet + ? WHERE UserID = ?",
                daily_reward, ctx.author.id)

            await ctx.send('here is your reward...')
            return
        else:
            db.execute("INSERT INTO economy (UserID) VALUES (?)",
                       ctx.author.id)
            db.execute(
                "UPDATE economy SET Wallet = Wallet + ? WHERE UserID = ?",
                daily_reward, ctx.author.id)
            await ctx.send('here is your reward...')
            return
コード例 #9
0
ファイル: mod.py プロジェクト: namanyt/discord-lassan-bot
    async def unmute_member(self, ctx, member: Member = None):
        if member is None:
            await ctx.send(
                'do it again, but also put the name of the member to unmute',
                delete_after=2)
            return

        try:
            db.execute("INSERT INTO mutes (UserID) VALUES (?)", member.id)
        except:
            pass

        is_muted = db.record("SELECT mute FROM mutes WHERE UserID = ?",
                             member.id)
        if is_muted == (0, ):
            await ctx.send(f'{member.display_name} is already unmuted')
            return

        await member.remove_roles(
            member.guild.get_role(settings['roles']['mute']))
        db.execute("UPDATE mutes SET mute = mute - ? WHERE UserID = ?", 1,
                   member.id)
コード例 #10
0
    async def begging(self, ctx):
        wallet = db.record("SELECT Wallet FROM economy WHERE UserID = ?",
                           ctx.author.id) or None
        ppl = ['Vivek', 'Charles', 'Alan', 'Queen', 'King', 'President', 'Dev']
        beg_money = randint(-100, 300)
        if beg_money <= 0:
            beg_money = 0
            await ctx.send(f"{choice(ppl)} -> No money for you !")
            if wallet is not None:
                db.execute(
                    "UPDATE economy SET Wallet = Wallet + ? WHERE UserID = ?",
                    beg_money, ctx.author.id)
                return
            else:
                db.execute("INSERT INTO economy (UserID) VALUES (?)",
                           ctx.author.id)
                db.execute(
                    "UPDATE economy SET Wallet = Wallet + ? WHERE UserID = ?",
                    beg_money, ctx.author.id)
                await ctx.send('here is your reward...')
                return

        else:
            await ctx.send(f"{choice(ppl)} -> ${beg_money}, here you go.")
            if wallet is not None:
                db.execute(
                    "UPDATE economy SET Wallet = Wallet + ? WHERE UserID = ?",
                    beg_money, ctx.author.id)
                return
            else:
                db.execute("INSERT INTO economy (UserID) VALUES (?)",
                           ctx.author.id)
                db.execute(
                    "UPDATE economy SET Wallet = Wallet + ? WHERE UserID = ?",
                    beg_money, ctx.author.id)
                await ctx.send('here is your reward...')
                return
コード例 #11
0
ファイル: exp.py プロジェクト: manemejeff/MarvinBot
    async def process_xp(self, message):
        xp, lvl, xplock = db.record("SELECT XP, Level, XPLock FROM exp WHERE UserID = ?", message.author.id)

        if datetime.fromisoformat(xplock) < datetime.utcnow():
            await self.add_xp(message, xp, lvl)