Esempio n. 1
0
 async def on_guild_join(self, guild):
   try:
     await guild.owner.send(embed=discord.Embed(
       title="Thanks for inviting BytesBump",
       description=Files.read("Admin/Messages/invite.txt").format(guild.owner.mention,guild.name),
       color=discord.Color.blurple()
     )
     .set_author(name="BytesBump", icon_url=self.bot.user.avatar_url, url="https://discord.gg/8akycDh"))
   except: pass
   db.add(guild)
   return
Esempio n. 2
0
    async def bump(self, ctx):
        guild = ctx.guild
        if not db.exists(guild):
            ctx.command.reset_cooldown(ctx)
            return await ctx.send(embed=discord.Embed(
                description=
                f"{emoji('cross')} This server seems to not exist in the Database! Use `=setup`!",
                color=discord.Color.red()))
        invchannel, description, color = db.get(guild)["fetch_invite"], db.get(
            guild)["description"], db.get(guild)["color"]

        try:
            invite = await ctx.guild.get_channel(invchannel).create_invite(
                max_uses=0, temporary=False, max_age=0, unique=False)
        except Exception as e:
            ctx.command.reset_cooldown(ctx)
            return await ctx.send(embed=discord.Embed(
                description=
                f"{emoji('cross')} Cannot fetch invite! Please review the following error, and if you can't solve it, please contact the developers in the [Support Server](https://discord.gg/r2rAUJZ)!",
                color=discord.Color.red()).add_field(name="Exception",
                                                     value=f"```{e}```"))

        embed = discord.Embed(title=guild.name,
                              description=description,
                              color=discord.Color(value=color),
                              url=invite.url)
        embed.add_field(name="👑 **Owner**", value=guild.owner.name)
        embed.add_field(name=f"{emoji('boost')} **Boosts**",
                        value=guild.premium_subscription_count)
        embed.add_field(name=f"{emoji('online')} **Members**",
                        value=len(guild.members))
        embed.add_field(name=f"{emoji('emojis')} **Emojis**",
                        value=f"{len(guild.emojis)}/{guild.emoji_limit}")
        embed.add_field(name=f"{emoji('region')} **Region**",
                        value=str(guild.region).capitalize())
        embed.add_field(name=f"{emoji('ccheck')} **Join**",
                        value=f"**[Join {guild.name}!]({invite.url})**")
        embed.set_thumbnail(url=guild.icon_url_as(static_format="png"))
        embed.set_footer(text="Powered by • BytesBump")
        msg = await ctx.send(embed=discord.Embed(
            description=
            f"{emoji('loading')} **Bumping your server...!**\nThis might take some time, so don't worry!",
            color=discord.Color.orange()))
        success, fail = 0, 0
        channels = [
            i["listing"] for i in db.get_all() if not i["listing"] == None
        ]
        for channel in channels:
            try:
                await asyncio.sleep(0.3)
                await self.bot.get_channel(channel).send(embed=embed)
                success += 1
            except:
                try:
                    temp = self.bot.get_guild(
                        db.find({"listing": channel})["_id"])
                    db.delete(temp)
                except:
                    return db.delete(db.find({"listing": channel})["_id"])
                await temp.owner.send(embed=discord.Embed(
                    title=f"{emoji('warn')} ATTENTION REQUIRED {emoji('warn')}",
                    description=
                    f"The bot cannot find or send messages in your listing channel, therefore we have removed your server ({temp.name}) from the Database! Run `=setup` again to set it up!",
                    color=discord.Color.red()))
                fail += 1

        await msg.edit(embed=discord.Embed(
            title=f"{emoji('ccheck')} Guild Bumped!",
            description=
            f"Your server was successfully bumped to `{success}` guilds! There were {fail} errors encountered on guilds, and they were removed from the database!",
            color=discord.Color.green()))
        await asyncio.sleep(60)
        await msg.edit(embed=discord.Embed(
            title="BytesBump | Promotional",
            description=Files.read("Admin/Messages/promotional.txt"),
            color=discord.Color.green()))
Esempio n. 3
0
  async def setup(self, ctx):
    if not db.exists(ctx.guild): db.add(ctx.guild)
    async def cancel(t):
      return await ctx.send(embed=discord.Embed(
        description=f"{emoji('warn')} {t}",
        color=discord.Color.orange()
      ))

    async def ask(q):
      return await ctx.send(embed=discord.Embed(
        description=f"{emoji('loading')} {q}",
        color=discord.Color.blurple()
      ))
    
    def basic_check(message):
      return message.author == ctx.author and message.channel == message.channel and len(message.content) != 0
    
    await ask("Enter your server's description!")
    try:
      description = await self.bot.wait_for("message", check=basic_check, timeout=120)
      description = description.content
      if len(description) < 250 or len(description) >= 2048:
        return await cancel("Your description must be at least **250 characters long** and can't be more than **2048 characters**! Setup canceled.")
    except asyncio.TimeoutError:
      return await cancel("Setup timed out! Please redo the command!")

    await ask("Mention the channel you want to fetch invites from!")
    try:
      channel = await self.bot.wait_for("message", check=basic_check, timeout=60)
      channel = channel.content
    except asyncio.TimeoutError:
      return await cancel("Setup timed out! Please redo the command!")
    try:
      channel = await commands.TextChannelConverter().convert(ctx, channel)
    except commands.ChannelNotFound:
      return await cancel("Invalid channel, please mention a valid **Text Channel**!")

    await ask("Mention the channel you want to send bumps at!")    
    try:
      lp = await self.bot.wait_for("message", check=basic_check, timeout=60)
      lp = lp.content
    except asyncio.TimeoutError:
      return await cancel("Setup timed out! Please redo the command!")
    
    try:
      lp = await commands.TextChannelConverter().convert(ctx, lp)
    except commands.ChannelNotFound:
      return await cancel("Invalid channel, please mention a valid **Text Channel**!")
    
    await ask("Enter the color you want for your server! (Only `HEX` codes are accepted)")
    try:
      color = await self.bot.wait_for("message", check=basic_check, timeout=120)
      color = color.content
    except asyncio.TimeoutError:
      return await cancel("Setup timed out! Please redo the command!")
    try:
      color = int(color.replace("#",""), 16)
    except ValueError:
      return await cancel("This is an invalid color! You can use [this tool](https://htmlcolorcodes.com/) to choose a valid HEX color!")
    
    post = {
      "fetch_invite": channel.id,
      "listing":lp.id,
      "color":color,
      "description":description
    }
    db.update(ctx.guild, post)
    return await ctx.send(embed=discord.Embed(
      description=f"{emoji('ccheck')} Your server is ready to be bumped! Use `{Files.config('main', 'prefix')}bump` to bump it every 1 hour!",
      color=discord.Color.green()
    ))
Esempio n. 4
0
 async def on_guild_remove(self, guild):
   return db.delete(guild)