示例#1
0
def newGod(guild, name, godtype, gender=None):
    try:
        god = gods.create(Guild=guild, Name=name, Type=godtype, Gender=gender)
        return god
    except Exception as error:
        logger.logDebug("Error doing new marriage - " + str(error), "ERROR")
        return False
示例#2
0
def newBeliever(userid, god):
    try:
        believer = believers.create(UserID=userid, God=god)
        return believer
    except Exception as error:
        logger.logDebug("Error doing new believer - " + str(error), "ERROR")
        return False
示例#3
0
def newInvite(godid, userid):
    try:
        invite = offers.create(God=godid, Type=1, UserID=userid)
        return invite
    except Exception as error:
        logger.logDebug("Error doing new invite - " + str(error), "ERROR")
        return False
示例#4
0
def newPriestOffer(godid, userid):
    try:
        priestoffer = offers.create(God=godid, Type=2, UserID=userid)
        return priestoffer
    except Exception as error:
        logger.logDebug("Error doing new priestoffer - " + str(error), "ERROR")
        return False
示例#5
0
    async def _bannew(self, ctx, *args):
        """Enables/disables the automatic global banning of accounts that are created less than 10 minutes ago.
        Disabled by default"""
        bot = self.bot
        if len(args) < 1:
            guild = ctx.guild
            guild_id = guild.id
        else:
            guild_id = int(args[0])
            guild = bot.get_guild(guild_id)

        if not database.isGuildInDB(guild_id):
            logger.logDebug("Guild is not in the database, adding it")
            name = None
            ownerid = None
            ownername = None
            if guild is not None:
                name = guild.name
                ownerid = guild.owner.id
                ownername = guild.owner.name
            database.addNewGuild(guild_id, name, ownerid, ownername)
        else:
            logger.logDebug("Guild is already in the database, doing toggle!")
            database.toggleNewAccountBan(guild_id)
        newAccountBanEnabled = database.isNewAccountBanGuild(guild_id)
        await ctx.send(
            "Toggled bans for new accounts for the guild with the ID: " +
            str(guild_id) + "\nBans for new accounts in this guild are now: " +
            ("Enabled!" if newAccountBanEnabled else "Disabled!"))
示例#6
0
def newGuild(guildid):
    try:
        guild = guilds.create(Guild=guildid)
        return guild
    except Exception as error:
        logger.logDebug("Error doing new guild - " + str(error), "ERROR")
        return False
示例#7
0
 async def doPresenceUpdate(self):
     try:
         await self.bot.change_presence(activity=discord.Game(
             name="with " + str(database.getBelieversGlobalCount()) +
             " believers | " + os.getenv('prefix') + "gods help"))
     except Exception as e:
         logger.logDebug("Error updating presence: " + str(e))
     self.firstrundone = True
示例#8
0
def newMarriage(believer1, believer2, god):
    try:
        marriage = marriages.create(God=god,
                                    Believer1=believer1,
                                    Believer2=believer2)
        return marriage
    except Exception as error:
        logger.logDebug("Error doing new marriage - " + str(error), "ERROR")
        return False
示例#9
0
async def on_connect():
    logger.logDebug("----------[LOGIN SUCESSFULL]----------", "INFO")
    logger.logDebug("     Username: "******"INFO")
    logger.logDebug("     UserID:   " + str(bot.user.id), "INFO")
    logger.logDebug("--------------------------------------", "INFO")
    print("\n")

    # Bot done starting up
    logger.logDebug("Bot startup done!\n", "INFO")
示例#10
0
文件: bot.py 项目: HeroGamers/Prunus
async def on_connect():
    # Bot startup is now done...
    logger.logDebug("----------[LOGIN SUCESSFULL]----------", "INFO")
    logger.logDebug("     Username: "******"INFO")
    logger.logDebug("     UserID:   " + str(bot.user.id), "INFO")
    logger.logDebug("--------------------------------------", "INFO")
    print("\n")

    logger.logDebug("The bot is ready!", "INFO")
    print("\n")
示例#11
0
def newBanAppeal(userid, reason=None):
    date = datetime.datetime.now()
    try:
        banappeals.create(UserID=userid, Reason=reason, Time=date)
    except IntegrityError as e:
        logger.logDebug(
            "DB Notice: User Already Appealed for a ban! - " + str(e) +
            ". Trying to make sure reasoning is updated then!", "WARNING")
        query = banappeals.update(Reason=reason, Accepted=None).where(
            banappeals.UserID.contains(str(userid)))
        query.execute()
示例#12
0
def addNewGuild(guildid, guildname=None, ownerid=None, ownertag=None):
    try:
        guilds.create(GuildID=guildid,
                      GuildName=guildname,
                      OwnerID=ownerid,
                      OwnerTag=ownertag,
                      HasNewAccountBan=True)
    except IntegrityError as e:
        logger.logDebug(
            "DB Notice: Guild Already Added To Sync List! - " + str(e) + ".",
            "WARNING")
示例#13
0
文件: bot.py 项目: Fido2603/WatchDog
async def on_guild_join(guild):
    await logger.log("Joined a new guild (`%s` - `%s`)" % (guild.name, guild.id), bot, "INFO")
    # Check the bot's ban permission
    if Permissions.ban_members in guild.get_member(bot.user.id).guild_permissions:
        # Get bans from db
        bans = database.getBans()
        # make new list for userid in bans, if member is in guild
        ban_members = [userid for userid in bans if guild.get_member(userid)]
        logger.logDebug(str(ban_members))
        # Ban the found users
        for userid in ban_members:
            await guild.ban(bot.get_user(int(userid)), reason="WatchDog - Global Ban")
            logger.logDebug("Banned user in guild hahayes")
示例#14
0
    async def performBan(cls, ctx, users, reason):
        bot = ctx.bot
        if isinstance(users, tuple):
            users = list(users)
        elif not isinstance(users, list):
            users = [users]

        # Check all users if they are already banned and stuff
        usersToBan = []
        for user in users:
            if user == ctx.bot.user:
                error = "Banning a user failed - given user is the bot"
                await logger.log(error, bot, "INFO")
            elif isModerator(user.id):
                error = "Banning a user failed - given user is a Global Moderator"
                await logger.log(error, bot, "INFO")
            elif database.isBanned(user.id):
                error = "Banning a user failed - given user is already banned"
                await logger.log(error, bot, "INFO")
            else:
                usersToBan.append(user)

        # If the list is empty, then there are no users to ban. As such, let's return the most recent error, I guess
        if not usersToBan:
            return error

        # Ban on current guild
        for user in usersToBan:
            # Bans on current guild first
            try:
                await ctx.guild.ban(user, reason="WatchDog - Global Ban")
            except Exception as e:
                await logger.log("Could not ban the user `%s` (%s) in the guild `%s` (%s)" % (
                    user.name, user.id, ctx.guild.name, ctx.guild.id), bot, "INFO")
                logger.logDebug(e)

        # Ban on other guilds
        for user in usersToBan:
            guilds = [guild for guild in bot.guilds if guild.get_member(user.id)]
            guilds.append(bot.get_guild(int(os.getenv('banlistguild'))))

            for guild in guilds:
                try:
                    await guild.ban(user, reason="WatchDog - Global Ban")
                except Exception as e:
                    await logger.log("Could not ban the user `%s` (%s) in the guild `%s` (%s)" % (
                        user.name, user.id, guild.name, guild.id), bot, "INFO")
                    logger.logDebug(e)
            # Send private ban notif in private moderator ban list as well as message in botlog
            await cls.logBan(ctx, user, reason=reason)
示例#15
0
    async def _ban(self, ctx, arg1, *args):
        """Bans a user globally - GM only."""
        bot = ctx.bot
        if isModerator(ctx.author.id):
            try:
                user = await self.getUser(ctx, arg1)
            except Exception as e:
                await ctx.send(embed=Embed(color=discord.Color.red(), description="Specified user not found!"))
                await logger.log("Could not get a specified user - Specified arg: %s - Error: %s" % (arg1, e), bot,
                                 "ERROR")
                return

            # Get the ban reason, if there is any
            reason = None
            if len(args) > 1:
                logger.logDebug("More than 1 argument given on ban command, getting banreason")
                reason = ' '.join(args)
                logger.logDebug("Banreason: " + reason)

            # Sends main embed
            embed = discord.Embed(title="Account is being banned...", color=discord.Color.green(),
                                  description="The ban is happening! Woah there! 👌")
            embed.set_footer(text="%s - Global WatchDog Moderator" % ctx.author.name,
                             icon_url=ctx.author.avatar_url)
            embed_message = await ctx.send(embed=embed)

            # Perform the ban
            error = await self.performBan(ctx, user, reason)

            # Do this when done
            # send final embed, telling the ban was sucessful
            if not error:
                embed = discord.Embed(title="Account banned", color=discord.Color.green(),
                                      description="`%s` has been globally banned 👌" % user)
                embed.set_image(
                    url="https://cdn.discordapp.com/attachments/456229881064325131/475498849696219141/ban.gif")
            else:
                embed = discord.Embed(title="Banning failed", color=discord.Color.red(),
                                      description="Error: %s" % error)
                embed.set_image(
                    url="https://cdn.discordapp.com/attachments/474313313598046238/689828429318848517/failed.gif")
            embed.set_footer(text="%s - Global WatchDog Moderator" % ctx.author.name,
                             icon_url=ctx.author.avatar_url)
            await embed_message.edit(embed=embed)
        else:
            await ctx.send(
                embed=Embed(color=discord.Color.red(), description="You are not a Global Moderator! Shame!"))
示例#16
0
    async def _unban(self, ctx, arg1):
        """Unbans a user globally - GM only."""
        bot = ctx.bot
        if isModerator(ctx.author.id):
            try:
                user = await self.getUser(ctx, arg1)
            except Exception as e:
                await ctx.send(embed=Embed(color=discord.Color.red(), description="Specified user not found!"))
                await logger.log("Could not get a specified user - Specified arg: %s - Error: %s" % (arg1, e), bot,
                                 "ERROR")
                return

            if not database.isBanned(user.id):
                return

            guilds = bot.guilds
            if len(guilds) >= 1:
                embed = discord.Embed(title="Account is being unbanned...", color=discord.Color.green(),
                                      description="The bans are happening! Woah there! 👌")
                embed.set_footer(text="%s - Global WatchDog Moderator" % ctx.author.name,
                                 icon_url=ctx.author.avatar_url)
                embed_message = await ctx.send(embed=embed)
                for guild in guilds:
                    if guild is None:  # Check if guild is none
                        await logger.log("Guild is none... GuildID: " + guild.id, bot, "ERROR")
                        continue
                    try:
                        await guild.unban(user, reason="WatchDog - Global Unban")
                    except Exception as e:
                        logger.logDebug("Could not unban the user `%s` (%s) in the guild `%s` (%s)" % (
                            user.name, user.id, guild.name, guild.id), "DEBUG")
                        logger.logDebug(e)
                # do this when done
                # Send private ban notif in private moderator ban list as well as message in botlog
                await self.logBan(ctx, user, unban=True)
                # edits final embed
                embed = discord.Embed(title="Account unbanned", color=discord.Color.green(),
                                      description="`%s` has been globally unbanned 👌" % user)
                embed.set_footer(text="%s - Global WatchDog Moderator" % ctx.author.name,
                                 icon_url=ctx.author.avatar_url)
                embed.set_image(
                    url="https://cdn.discordapp.com/attachments/456229881064325131/475498943178866689/unban.gif")
                await embed_message.edit(embed=embed)
        else:
            await ctx.send(
                embed=Embed(color=discord.Color.red(), description="You are not a Global Moderator! Shame!"))
示例#17
0
async def checkAppealGuild():
    appealguild = bot.get_guild(int(os.getenv('appealguild')))
    appealchannel = None

    logger.logDebug(appealguild.channels)
    for channel in appealguild.channels:
        if channel.name == "appeal-here":
            appealchannel = channel
            break
    if appealchannel is None:
        await logger.log("No appealchannel found! Trying to create one!", bot,
                         "INFO")
        try:
            overwrites = {
                appealguild.default_role:
                discord.PermissionOverwrite(read_messages=True,
                                            send_messages=False),
                appealguild.me:
                discord.PermissionOverwrite(read_messages=True,
                                            send_messages=True,
                                            manage_messages=True,
                                            embed_links=True,
                                            add_reactions=True)
            }
            appealchannel = await appealguild.create_text_channel(
                "appeal-here", overwrites=overwrites)
        except Exception as e:
            await logger.log(
                "Could not create an appeal channel! Returning! - " + str(e),
                bot, "ERROR")
            return

    history = await appealchannel.history(limit=5).flatten()
    # check if no messages
    if len(history) == 0:  # no messages
        # Sending the message
        await logger.log("Sending the appeal channel message", bot, "INFO")
        message = await appealchannel.send(
            content="Hello there! Welcome to the WatchDog Appeal Server!\n" +
            "\nTo begin your appeal process, please click this reaction!")

        # now we add a reaction to the message
        await message.add_reaction("✅")
示例#18
0
    async def _create(self, ctx, *args):
        """Creates a new God"""
        user = ctx.author

        if database.getBeliever(user.id, ctx.guild.id):
            await ctx.send(
                "You are already in a God, please leave it to create a new one using `/gods leave`!"
            )
            return

        if len(args) < 1:
            await ctx.send("Please give your God a name!")
            return

        if database.getGodName(args[0], ctx.guild.id):
            await ctx.send("A God with that name already exists!")
            return

        if len(args[0]) > 16:
            await ctx.send(
                "Please choose a name that's not longer than 16 characters!")
            return

        if len(args) > 1:
            if len(args[1]) > 19:
                await ctx.send(
                    "Please choose a gender that's not longer than 19 characters!"
                )
                return

            god = database.newGod(ctx.guild.id, args[0],
                                  random.choice(botutils.godtypes)[0], args[1])
        else:
            god = database.newGod(ctx.guild.id, args[0],
                                  random.choice(botutils.godtypes)[0])
        if god.ID:
            await ctx.send("God created!")
            believer = database.newBeliever(user.id, god)
            if believer.ID:
                logger.logDebug("Believer created!")
        else:
            await ctx.send("Boohoo, God creation failed...")
示例#19
0
    async def _join(self, ctx, arg1):
        """Joins a religion"""
        believer = database.getBeliever(ctx.author.id, ctx.guild.id)
        if believer:
            if arg1.upper() == believer.God.Name.upper():
                await ctx.send("You are already believing in this God!")
                return
            await ctx.send(
                "You are already in a God, please leave it to join a new one using `/gods leave`!"
            )
            return

        god = database.getGodName(arg1, ctx.guild.id)
        if not god:
            await ctx.send(
                "There is no God by that name... yet! `/gods create <name>`")
            return

        if god.InviteOnly:
            invite = database.getInvite(ctx.author.id, god.ID)
            if not invite:
                await ctx.send(
                    "That God is invite-only, and you don't have an invite...\n"
                    "Try contacting the Preist of the God for an invite!")
                return
            database.deleteInvite(invite.ID)

        database.newBeliever(ctx.author.id, god.ID)
        await ctx.send("You've now become a believer in the name of " +
                       god.Name + "!")

        priestoffer = database.getPriestOffer(god.ID)

        print(priestoffer)

        if not god.Priest and not database.getPriestOffer(god.ID):
            await botutils.doNewPriestOffer(self.bot, god)
            logger.logDebug(
                "Sent a new priest offer, God reached 3 believers!")
        else:
            logger.logDebug("God already had a preist or a priest offer")
示例#20
0
文件: bot.py 项目: HeroGamers/Prunus
async def on_ready():
    logger.logDebug("Prunus has (re)connected to Discord!")

    logger.logDebug("Checking the welcome channel!", "INFO")
    await welcome_channel()
    logger.logDebug("Done checking the welcome channel!", "INFO")
    print("\n")
示例#21
0
    async def unban(self, user):
        for guild in self.bot.guilds:
            if guild is None:
                await logger.log("Guild is none... GuildID: " + guild.id,
                                 self.bot, "ERROR")
                continue

            # Check for testMode
            if os.getenv('testModeEnabled') != "True":
                try:
                    await guild.unban(user, reason="WatchDog - Global Unban")
                except Exception as e:
                    await logger.log(
                        "Could not unban the user `%s` (%s) in the guild `%s` (%s)"
                        % (user.name, user.id, guild.name, guild.id), self.bot,
                        "INFO")
                    logger.logDebug(e)
            else:
                logger.logDebug(
                    "TestUnBanned (unban) " + user.name + " (" + str(user.id) +
                    "), in the guild " + guild.name + "(" + str(guild.id) +
                    ")", "DEBUG")
        if os.getenv('testModeEnabled') != "True":
            database.invalidateBan(user.id)
示例#22
0
    async def getUser(cls, ctx, arg):
        if arg.startswith("<@") and arg.endswith(">"):
            userid = arg.replace("<@", "").replace(">", "").replace("!", "")  # f**k you nicknames
        else:
            userid = arg

        user = None
        try:
            user = await ctx.bot.fetch_user(userid)
        except Exception as e:
            logger.logDebug("User not found! ID method - %s" % e)
            try:
                user = discord.utils.get(ctx.message.guild.members, name=arg)
            except Exception as e:
                logger.logDebug("User not found! Name method - %s" % e)
        if user is not None:
            logger.logDebug("User found! - %s" % user.name)
            return user
        else:
            raise Exception("User not found!")
示例#23
0
    async def update_stats(self):
        """This function runs every 30 minutes to automatically update the server count across multiple bot lists."""
        guilds = len(self.bot.guilds)
        users = len(set(self.bot.get_all_members()))
        id = str(self.bot.user.id)
        logger.logDebug("Attempting to post server counts...", "INFO")

        # top.gg
        site = "top.gg"
        try:
            await self.topgg.post_guild_count()
            logger.logDebug('Posted server count to ' + site + ' ({})'.format(self.topgg.guild_count()), "INFO")
        except Exception as e:
            logger.logDebug('Failed to post server count to ' + site + ': {} - {}'.format(type(e).__name__, e), "INFO")

        # discord.bots.gg
        site = "discord.bots.gg"
        headers = {'Authorization': self.dbotsgg_token,
                   'Content-Type': "application/json"}
        payload = {'guildCount': guilds}
        url = "https://discord.bots.gg/api/v1/bots/" + id + "/stats"
        resp = requests.post(url=url, headers=headers, data=json.dumps(payload))
        logger.logDebug("Response from " + site + ": " + str(resp), "INFO")

        # discordbotlist.com
        site = "discordbotlist.com"
        headers = {'Authorization': "Bot " + self.discordbotlistcom_token,
                   'Content-Type': "application/json"}
        payload = {'guilds': guilds,
                   'users': users}
        url = "https://discordbotlist.com/api/bots/" + id + "/stats"
        resp = requests.post(url=url, headers=headers, data=json.dumps(payload))
        logger.logDebug("Response from " + site + ": " + str(resp), "INFO")

        # bots.ondiscord.xyz
        site = "bots.ondiscord.xyz"
        headers = {'Authorization': self.botsondiscordxyz_token,
                   'Content-Type': "application/json"}
        payload = {'guildCount': guilds}
        url = "https://discordbotlist.com/bot-api/bots/" + id + "/guilds"
        resp = requests.post(url=url, headers=headers, data=json.dumps(payload))
        logger.logDebug("Response from " + site + ": " + str(resp), "INFO")
示例#24
0
    async def _userinfo(self, ctx, arg1):
        """Gets info about a user."""
        try:
            user = await ctx.bot.fetch_user(arg1)
        except Exception as e:
            logger.logDebug("User not found! - %s" % e)
            try:
                user = await ctx.bot.fetch_user(ctx.message.mentions[0].id)
            except Exception as e:
                logger.logDebug("User not found! - %s" % e)
                try:
                    user = await ctx.bot.fetch_user(ctx.message.mentions[0].id)
                except Exception as e:
                    logger.logDebug("User not found! - %s" % e)
                    try:
                        user = discord.utils.get(ctx.message.guild.members, name=arg1)
                    except Exception as e:
                        logger.logDebug("User not found! - %s" % e)
                        await ctx.send("User not found!")
        if user is None:
            await ctx.send("User not found!")
        else:
            embed = discord.Embed(title="User Information", color=discord.Color.green(),
                                  description="DiscordTag: %s#%s" % (user.name, user.discriminator))
            embed.add_field(name="ID:", value="%s" % user.id, inline=True)
            embed.add_field(name="Created at:",
                            value="%s" % discord.utils.snowflake_time(user.id).strftime("%Y-%m-%d %H:%M:%S"),
                            inline=True)
            isUserBanned = isBanned(user.id)
            embed.add_field(name="Banned:", value="Yes" if isUserBanned else "No", inline=True)
            embed.add_field(name="In guild with bot:", value="Pending...", inline=True)
            if isUserBanned & isModerator(ctx.author.id):
                banreason = getBan(user.id).Reason
                if banreason is None:
                    banreason = "None"
                embed.add_field(name="Ban reason:", value=banreason, inline=True)
            embed.set_thumbnail(url=user.avatar_url)
            embed.set_footer(text="Userinfo requested by %s" % ctx.author.name, icon_url=ctx.author.avatar_url)
            embed_message = await ctx.send(embed=embed)

            inguildwithbot = "No"
            member = None
            for guild in self.bot.guilds:
                if inguildwithbot == "Yes":
                    break
                member = guild.get_member(user.id)
                if member:
                    inguildwithbot = "Yes"
                    break

            if inguildwithbot == "Yes":
                if str(member.status) == "dnd":
                    status = "Do Not Disturb"
                elif str(member.status) == "do_not_disturb":
                    status = "Do Not Disturb"
                elif str(member.status) == "offline":
                    status = "Offline"
                elif str(member.status) == "online":
                    status = "Online"
                elif str(member.status) == "idle":
                    status = "Idle"
                elif str(member.status) == "invisible":
                    status = "Offline"
                else:
                    status = "Unknown"
                embed.add_field(name="Status:", value="%s" % status, inline=True)

            embed.set_field_at(index=3, name="In guild with bot:", value="%s" % inguildwithbot, inline=True)
            await embed_message.edit(embed=embed)
示例#25
0
    async def doNewPriestOffer(cls, bot, god, old_priestoffer=None):
        believers = database.getBelieversByID(god.ID)

        if len(believers) >= 2:
            logger.logDebug(
                "More than 3 believers in god, choosing new priest candidate!")
            iterations = 0
            while True:
                if iterations > 3:
                    logger.logDebug(
                        "Did over 3 iterations trying to find priest offer... Breaking"
                    )
                    break

                iterations += 1
                believer = random.choice(believers)

                if old_priestoffer is not None:
                    if believer.UserID == old_priestoffer.UserID:
                        continue

                user = await botutils.getUser(
                    bot, bot.get_guild(believer.God.Guild), believer.UserID)

                # Update the Database with the new priest offer
                database.newPriestOffer(god.ID, user.id)

                # Get DM channel
                dm_channel = user.dm_channel
                if dm_channel is None:
                    await user.create_dm()
                    dm_channel = user.dm_channel

                # Send the message to the user about being selected as new Priest
                guild = bot.get_guild(int(god.Guild))
                try:
                    await dm_channel.send(
                        "Congratulations! You've been selected as the priest for **"
                        + god.Name + "** on "
                        "the " + guild.name +
                        " server!\nWrite `/gods accept` to accept the request, or "
                        "`/gods deny` to decline the request, on that server!")
                except Exception as e:
                    # if we can't send the DM, the user probably has DM's off, at which point we would uhhh, yes
                    await logger.log(
                        "Couldn't send DM to user about being selected as a priest. User ID: "
                        + str(user.id) + " - Error: " + str(e), bot, "INFO")

                    # send a message to the user in a channel where the user can read, and the bot can send
                    member = guild.get_member(user.id)
                    bot_member = guild.get_member(bot.user.id)
                    for channel in guild.channels:
                        if isinstance(channel,
                                      discord.CategoryChannel) or isinstance(
                                          channel, discord.VoiceChannel):
                            continue
                        user_permissions = channel.permissions_for(member)
                        bot_permissions = channel.permissions_for(bot_member)
                        if user_permissions.send_messages & bot_permissions.send_messages:
                            await channel.send(
                                "<@" + str(user.id) +
                                "> has been selected as the priest for **" +
                                god.Name +
                                "**!\nWrite `/gods accept` to accept the "
                                "request, or `/gods deny` to decline the request!"
                            )
                            break
                # Jump out of while loop
                break
        else:
            logger.logDebug(
                "Not more than 3 believers in god, skipping new priest candidate check"
            )
示例#26
0
 async def _war(self, ctx):
     """Toggles war with another religion - Not done"""
     logger.logDebug("yes")
示例#27
0
 async def _ally(self, ctx):
     """Toggles alliance with another religion - Not done"""
     logger.logDebug("yes")
示例#28
0

@bot.event
async def on_message(message: discord.Message):
    if message.author.bot:
        return
    ctx: commands.Context = await bot.get_context(message)

    if ctx.command is not None:
        if isinstance(message.channel, discord.DMChannel):
            await logger.log("`%s` (%s) used the `%s` command in their DM's" % (
                ctx.author.name, ctx.author.id, ctx.invoked_with), bot, "INFO")
        else:
            await logger.log("`%s` (%s) used the `%s` command in the guild `%s` (%s), in the channel `%s` (%s)" % (
                ctx.author.name, ctx.author.id, ctx.invoked_with, ctx.guild.name, ctx.guild.id, ctx.channel.name,
                ctx.channel.id), bot, "INFO")
        await bot.invoke(ctx)


if __name__ == '__main__':
    logger.setup_logger()

    # Load extensions
    for extension in startup_extensions:
        try:
            bot.load_extension(f"cogs.{extension}")
        except Exception as e:
            logger.logDebug(f"Failed to load extension {extension}. - {e}", "ERROR")

bot.run(os.getenv('token'))
示例#29
0
async def on_connect():
    logger.logDebug("----------[LOGIN SUCESSFULL]----------", "INFO")
    logger.logDebug("     Username: "******"INFO")
    logger.logDebug("     UserID:   " + str(bot.user.id), "INFO")
    logger.logDebug("--------------------------------------", "INFO")
    print("\n")

    logger.logDebug("Updating the database!", "INFO")
    await updateDatabase()
    logger.logDebug("Done updating the database!", "INFO")
    print("\n")

    # Ban appeal server setup
    await checkAppealGuild()

    # Bot done starting up
    await logger.log("Bot startup done!", bot, "INFO", "Bot startup done.\n")
示例#30
0
async def on_ready():
    # Bot startup is now done...
    logger.logDebug("Gods has (re)connected to Discord!")