Esempio n. 1
0
        async def uconnect(self, ctx):
            vchannel = await is_connected(ctx)
            error1 = "❌ Already connected to a voice channel"
            error2 = "❌ Please join a voice channel or enter the command in guild chat"
            if db.get_lang(ctx) == "ar":
                error1 = "❌ متصل بالفعل بقناة صوتية"
                error2 = "❌ يرجى الانضمام إلى قناة صوتية أو إدخال الأمر في دردشة النقابة"
            if vchannel is not None:
                await ctx.send(embed=discord.Embed(description=error1,
                                                   color=discord.Colour.red()))
                return

            current_guild = get_guild(self.client, ctx.message)

            if current_guild is None:
                await ctx.send(embed=discord.Embed(description=error2,
                                                   color=discord.Colour.red()))
                return
            # await ctx.message.add_reaction("<a:loading:797134049939816478>")
            guild_to_audiocontroller[current_guild] = AudioController(
                self.client, current_guild)
            await guild_to_audiocontroller[
                current_guild].register_voice_channel(ctx.author.voice.channel)
            msg_connected = "Connected to"
            if db.get_lang(ctx) == "ar":
                msg_connected = "تم الاتصال في"
            await ctx.send(embed=discord.Embed(description="✅ {} {} {}".format(
                msg_connected, ctx.author.voice.channel.name,
                ":white_check_mark:"),
                                               color=discord.Colour.green()))
Esempio n. 2
0
    async def _shuffle(self, ctx):
        current_guild = get_guild(self.client, ctx.message)
        audiocontroller = guild_to_audiocontroller[current_guild]

        if await play_check(ctx) == False:
            return

        if current_guild is None:
            msg = "❌ Please join a voice channel or enter the command in guild chat"
            if db.get_lang(ctx) == "ar":
                msg = "❌ يرجى الانضمام إلى قناة صوتية أو إدخال الأمر في دردشة النقابة"
            await ctx.send(embed=discord.Embed(description=msg,
                                               color=discord.Colour.red()))
            return
        if current_guild.voice_client is None or not current_guild.voice_client.is_playing(
        ):
            msg = "❌ Queue is empty "
            if db.get_lang(ctx) == "ar":
                msg = "❌ قائمة الانتظار فارغة"
            await ctx.send(embed=discord.Embed(description=msg,
                                               color=discord.Colour.green()))
            return

        audiocontroller.playlist.shuffle()
        msg = "Shuffled queue 🔀"
        if db.get_lang(ctx) == "ar":
            msg = "قائمة انتظار عشوائية 🔀"
        await ctx.send(
            embed=discord.Embed(description=msg, color=discord.Colour.green()))
Esempio n. 3
0
    async def uconnect(self, ctx):

        vchannel = await is_connected(ctx)

        if vchannel is not None:
            msg = "❌ Already connected to a voice channel"
            if db.get_lang(ctx) == "ar":
                msg = "❌ متصل بالفعل بقناة صوتية"
            await ctx.send(embed=discord.Embed(description=msg,
                                               color=discord.Colour.red()))
            return

        current_guild = get_guild(self.client, ctx.message)

        if current_guild is None:
            msg = "❌ Please join a voice channel or enter the command in guild chat"
            if db.get_lang(ctx) == "ar":
                msg = "❌ يرجى الانضمام إلى قناة صوتية أو إدخال الأمر في دردشة النقابة"
            await ctx.send(embed=discord.Embed(description=msg,
                                               color=discord.Colour.red()))
            return

        guild_to_audiocontroller[current_guild] = AudioController(
            self.client, current_guild)
        await guild_to_audiocontroller[current_guild].register_voice_channel(
            ctx.author.voice.channel)

        await ctx.message.add_reaction("✅")
Esempio n. 4
0
    async def giveaway_start(self, ctx, time, *, prize: str):
        await ctx.message.delete()

        def convert(time):
            pos = ["s", "m", "h", "d", "mo"]
            time_dict = {
                "s": 1,
                "m": 60,
                "h": 3600,
                "d": 3600 * 24,
                "mo": 86400 * 30
            }
            unit = time[-1]
            if unit not in pos:
                return -1
            try:
                val = int(time[:-1])
            except:
                return -2
            return val * time_dict[unit]

        pr, end, host, win = "prize", "Ends At", "Host By", "winner"
        if db.get_lang(ctx) == "ar":
            pr, end, host, win = "الجائزه", "ينتهي بعد", "المسؤول", "الفائز"
        time1 = convert(time)
        embed = discord.Embed(
            color=ctx.author.color,
            timestamp=ctx.message.created_at,
            description='**{}:** {}\n**{}:** {}\n**{}:** {}'.format(
                pr, prize, end, time, host, ctx.author.mention))
        embed.set_footer(text=ctx.guild.name, icon_url=ctx.guild.icon_url)
        embed.set_author(name=self.client.user.name,
                         icon_url=self.client.user.avatar_url)
        give = "giveaway"
        if db.get_lang(ctx) == "ar":
            give = "الجيفاوي"
        my_msg = await ctx.send(f'🎉 {give}! 🎉', embed=embed)
        await my_msg.add_reaction("🎉")

        await asyncio.sleep(time1)

        new_msg = await ctx.channel.fetch_message(my_msg.id)
        users = await new_msg.reactions[0].users().flatten()
        users.pop(users.index(self.client.user))
        winner = random.choice(users)
        embed = discord.Embed(
            color=ctx.author.color,
            timestamp=ctx.message.created_at,
            description='**{}:** {}\n**{}:** {}\n**{}:** {}'.format(
                pr, prize, host, ctx.author.mention, win, winner.mention))
        embed.set_footer(text=ctx.guild.name, icon_url=ctx.guild.icon_url)
        embed.set_author(name=self.client.user.name,
                         icon_url=self.client.user.avatar_url)
        await my_msg.edit(embed=embed)
        msg = f"the winner is {winner.mention} Won in **{prize}**!"
        if db.get_lang(ctx) == "ar":
            msg = f"الفائز هو {winner.mention} فاز في ** {prize} **!"
        await ctx.send(
            embed=discord.Embed(description=msg, color=discord.Colour.green()))
Esempio n. 5
0
 async def echo(self, ctx, channel: discord.TextChannel, *, arg):
     await channel.send(arg)
     if db.get_lang(ctx) == "en":
         await ctx.send(embed=discord.Embed(
             description='Message was sent in {}'.format(channel.mention),
             color=discord.Colour.green()))
     elif db.get_lang(ctx) == "ar":
         await ctx.send(embed=discord.Embed(
             description='تم إرسال الرسالة {}'.format(channel.mention),
             color=discord.Colour.green()))
Esempio n. 6
0
 async def unlock(self, ctx, channel: discord.TextChannel = None):
     channel = channel or ctx.channel
     overwrite = channel.overwrites_for(ctx.guild.default_role)
     overwrite.send_messages = True
     await channel.set_permissions(ctx.guild.default_role,
                                   overwrite=overwrite)
     if db.get_lang(ctx) == "en":
         await ctx.send(embed=discord.Embed(
             description='🔓 | channel has been unlock {}'.format(
                 channel.mention),
             color=discord.Colour.green()))
     elif db.get_lang(ctx) == "ar":
         await ctx.send(embed=discord.Embed(
             description='🔓 | تم فتح الروم {}'.format(channel.mention),
             color=discord.Colour.green()))
Esempio n. 7
0
    async def magik(self, ctx, member: discord.Member, intensity: int = 5):
        member = member if member else ctx.author
        avatar = member.avatar_url_as(size=1024,
                                      format=None,
                                      static_format='png')
        msg = "Processing the image please wait!"
        if db.get_lang(ctx):
            msg = "جاري معالجة الصورة يرجى الانتظار!"
        message = await ctx.send(embed=discord.Embed(
            description=
            f"{str(self.client.get_emoji(797134049939816478))} — **{msg}**",
            color=discord.Colour.green()))
        await message.delete(delay=15)

        async with aiohttp.ClientSession() as cs:
            async with cs.get(
                    f"https://nekobot.xyz/api/imagegen?type=magik&image={avatar}&intensity={intensity}"
            ) as r:
                res = await r.json()
                embed = discord.Embed(color=ctx.author.color,
                                      description=f"[Magik]({res['message']})",
                                      timestamp=ctx.message.created_at)
                embed.set_image(url=res["message"])
                embed.set_footer(text=ctx.guild.name,
                                 icon_url=ctx.guild.icon_url)
                embed.set_author(name=self.client.user.name,
                                 icon_url=self.client.user.avatar_url)
                await ctx.send(embed=embed)
Esempio n. 8
0
    async def udisconnect(self, ctx, guild):
        if guild is not False:

            current_guild = guild

            await guild_to_audiocontroller[current_guild].stop_player()
            await current_guild.voice_client.disconnect(force=True)

        else:
            current_guild = get_guild(self.client, ctx.message)

            if current_guild is None or await is_connected(ctx) is None:
                msg = "❌ Please join a voice channel or enter the command in guild chat"
                if db.get_lang(ctx) == "ar":
                    msg = "❌ يرجى الانضمام إلى قناة صوتية أو إدخال الأمر في دردشة النقابة"
                await ctx.send(embed=discord.Embed(description=msg,
                                                   color=discord.Colour.red()))
                return

            # if await is_connected(ctx) is None:
            #     await ctx.send(embed=discord.Embed(
            #         description="Error: Please join a voice channel or enter the command in guild chat",
            #         color=discord.Colour.red()))
            #     return

            await guild_to_audiocontroller[current_guild].stop_player()
            await current_guild.voice_client.disconnect(force=True)
            await ctx.send(embed=discord.Embed(
                description=
                "Disconnected from voice channel. Use `{}c` to rejoin.".format(
                    db.get_prefix(ctx)),
                color=discord.Colour.red()))
Esempio n. 9
0
 async def roll(self, ctx, faces: int = 100):
     msg = "You have got"
     if db.get_lang(ctx) == "ar":
         msg = "لقد حصلت على"
     number = randint(1, faces)
     await ctx.send(
         embed=discord.Embed(description=f'**🎲 {msg} `{str(number)}` !**',
                             color=discord.Colour.green()))
Esempio n. 10
0
    async def _queue(self, ctx):
        current_guild = get_guild(self.client, ctx.message)

        if await play_check(ctx) == False:
            return

        if current_guild is None:
            msg = "❌ Please join a voice channel or enter the command in guild chat"
            if db.get_lang(ctx) == "ar":
                msg = "❌ يرجى الانضمام إلى قناة صوتية أو إدخال الأمر في دردشة النقابة"
            await ctx.send(embed=discord.Embed(description=msg,
                                               color=discord.Colour.red()))
            return
        if current_guild.voice_client is None or not current_guild.voice_client.is_playing(
        ):
            msg = "Queue is empty"
            if db.get_lang(ctx) == "ar":
                msg = "قائمة الانتظار فارغة ❌"
            await ctx.send(embed=discord.Embed(description=msg,
                                               color=discord.Colour.green()))
            return

        playlist = guild_to_audiocontroller[current_guild].playlist

        songlist = []
        counter = 1

        for song in playlist.playque:
            entry = "{}. {}".format(str(counter), song.info.webpage_url)
            songlist.append(entry)
            counter = counter + 1

        try:
            msg = "the Queue"
            if db.get_lang(ctx) == "ar":
                msg = "في الانتظار"
            await ctx.send(
                embed=discord.Embed(description="{}: [**{}**]:\n{}".format(
                    msg, len(songlist), '\n'.join(songlist[:10])),
                                    color=discord.Colour.green()))
        except:
            msg = "Queue to long to post. Working on this feature."
            if db.get_lang(ctx) == "ar":
                msg = "قائمه الانتظار طويله.جاري العمل على هذه الميزة."
            await ctx.send(embed=discord.Embed(description=msg,
                                               color=discord.Colour.red()))
Esempio n. 11
0
 async def nickname(self, ctx, member: discord.Member, *, new: str = None):
     reset_name = "has been reset nickname"
     if db.get_lang(ctx) == "ar":
         reset_name = "تم إعادة تعيين اللقب"
     if new == None:
         await member.edit(nick="")
         await ctx.send(embed=discord.Embed(
             description=f'`{member.name}` {reset_name}',
             color=discord.Colour.green()))
     else:
         been_changed = "has been changed to"
         if db.get_lang(ctx) == "ar":
             been_changed = "تم تغير اللقب إلى"
         await member.edit(nick=f'{new}')
         await ctx.send(embed=discord.Embed(
             description=f'{member.name} {been_changed} {new}',
             color=discord.Colour.green()))
    async def on_command_error(self, ctx, error):
        # print(db.get_cooldown())
        if ctx.author.id in db.get_cooldown():
            return
        elif isinstance(error, commands.CommandOnCooldown):
            m, s = divmod(error.retry_after, 60)
            await ctx.send(embed=discord.Embed(
                description=
                f"This command is currently **on cooldown** for ,Please **try again in** `{'%02d seconds' % (s,)}`.",
                color=discord.Colour.red()),
                           delete_after=2)

            db.cr.execute("INSERT OR IGNORE INTO cooldown(user_id) VALUES(?)",
                          (ctx.author.id, ))
            db.commit()
            return
        elif isinstance(ctx.channel, discord.channel.DMChannel):
            return
        elif isinstance(error, commands.errors.MemberNotFound):
            embed = member_not_found_en()
            if db.get_lang(ctx) == "ar":
                embed = member_not_found_ar()
            await ctx.send(embed=embed)
            return
        elif isinstance(error, commands.MissingRequiredArgument):
            aliases = []
            if ctx.command.aliases == []:
                aliases = None
            else:
                aliases = ", ".join(ctx.command.aliases)
            embed = discord.Embed(
                description=f"**command:** {ctx.command.name}\n\
**help:** {ctx.command.help}\n\
**used:** {db.get_prefix(ctx)}{ctx.command.usage}\n\
**aliases:** {aliases}\n",
                color=Colour.red()).set_author(name=ctx.command.cog_name)
            await ctx.send(embed=embed)
            return
        elif isinstance(error, commands.errors.BadArgument):
            aliases = []
            if ctx.command.aliases == []:
                aliases = None
            else:
                aliases = ", ".join(ctx.command.aliases)
            embed = discord.Embed(
                description=f"**command:** {ctx.command.name}\n\
**help:** {ctx.command.help}\n\
**used:** {db.get_prefix(ctx)}{ctx.command.usage}\n\
**aliases:** {aliases}\n",
                color=Colour.red()).set_author(name=ctx.command.cog_name)
            await ctx.send(embed=embed)
            return
        elif isinstance(error, commands.errors.MissingPermissions):
            await ctx.send(error)
        else:
            pass
Esempio n. 13
0
 async def poll(self, ctx, *, arg):
     await ctx.message.delete()
     embed = discord.Embed(timestamp=ctx.message.created_at,
                           description=arg,
                           color=ctx.author.color)
     embed.set_author(name=self.client.user.name,
                      icon_url=self.client.user.avatar_url)
     embed.set_footer(text=ctx.guild.name, icon_url=ctx.guild.icon_url)
     poll = "poll"
     if db.get_lang(ctx) == "ar":
         poll = "تصويت"
     msg = await ctx.send("📢 {} 📢".format(poll), embed=embed)
     await msg.add_reaction('👍')
     await msg.add_reaction('👎')
Esempio n. 14
0
 async def play_song_error(self, ctx, error):
     if isinstance(error, commands.MissingRequiredArgument):
         embed = error_handler.error_en(
             ctx=ctx,
             used="play <name or link>",
             description="play song in youtube or spotify",
             aliases="yt, p, pl",
             type="Music")
         if db.get_lang(ctx) == "ar":
             embed = error_handler.error_en(
                 ctx=ctx,
                 used="play <اسم او رابط الاغنيه>",
                 description="تشغيل الصوت سوائن من يتيوب او سبوتيفاي",
                 aliases="yt, p, pl",
                 type="الموسيقه")
         await ctx.send(embed=embed)
Esempio n. 15
0
    async def _stop(self, ctx):
        current_guild = get_guild(self.client, ctx.message)

        if await play_check(ctx) == False:
            return

        audiocontroller = guild_to_audiocontroller[current_guild]
        audiocontroller.playlist.loop = False
        if current_guild is None:
            msg = "❌ Please join a voice channel or enter the command in guild chat"
            if db.get_lang(ctx) == "ar":
                msg = "❌ يرجى الانضمام إلى قناة صوتية أو إدخال الأمر في دردشة النقابة"
            await ctx.send(embed=discord.Embed(description=msg,
                                               color=discord.Colour.red()))
            return
        await guild_to_audiocontroller[current_guild].stop_player()
        await ctx.message.add_reaction("⏹️")
Esempio n. 16
0
 async def ascll(self, ctx, *, arg: str):
     msg = "The number of characters must be less than `30`"
     font = [
         'slant', "3-d", "3x5", "5lineoblique", "alphabet", "letters",
         "bubble", "bulbhead", "digital"
     ]
     ran = random.choice(font)
     if db.get_lang(ctx) == "ar":
         msg = "يجب أن يكون عدد الأحرف أقل من `30`"
     if len(arg) >= 30:
         await ctx.send(embed=discord.Embed(description="❌ {}".format(msg),
                                            color=discord.Colour.red()))
     else:
         await ctx.send(embed=discord.Embed(
             description=
             f"""```javascript\n{pyfiglet.figlet_format(text=arg, font=ran)}```""",
             color=discord.Colour.green()))
Esempio n. 17
0
    async def reroll(self, ctx, channel: discord.TextChannel, message_id: int):
        msg, msg1 = "The id was entered incorrectly.", "the winner is"
        try:
            new_msg = await channel.fetch_message(message_id)

        except:
            if db.get_lang(ctx) == "ar":
                msg, msg1 = "تم إدخال الايدي بشكل غير صحيح.", "الفائز هو"
            await ctx.send(embed=discord.Embed(description=msg,
                                               color=discord.Colour.red()))
            return
        users = await new_msg.reactions[0].users().flatten()
        users.pop(users.index(self.client.user))
        winner = random.choice(users)
        await channel.send(
            embed=discord.Embed(description=f"{msg1} {winner.mention}.!",
                                color=discord.Colour.green()))
Esempio n. 18
0
    async def _pause(self, ctx):
        current_guild = get_guild(self.client, ctx.message)

        if await play_check(ctx) == False:
            return

        if current_guild is None:
            msg = "❌ Please join a voice channel or enter the command in guild chat"
            if db.get_lang(ctx) == "ar":
                msg = "❌ يرجى الانضمام إلى قناة صوتية أو إدخال الأمر في دردشة النقابة"
            await ctx.send(embed=discord.Embed(description=msg,
                                               color=discord.Colour.red()))
            return
        if current_guild.voice_client is None or not current_guild.voice_client.is_playing(
        ):
            return
        current_guild.voice_client.pause()
        await ctx.message.add_reaction("⏸")
Esempio n. 19
0
    async def _songinfo(self, ctx):
        current_guild = get_guild(self.client, ctx.message)

        if await play_check(ctx) == False:
            return

        if current_guild is None:
            pass
        song = guild_to_audiocontroller[current_guild].current_song
        if song is None:
            return
        msg = "Song info"
        if db.get_lang(ctx) == "ar":
            msg = "معلومات الاغنيه"
        await ctx.send(
            embed=song.info.format_output(msg,
                                          color=ctx.author.color,
                                          timestamp=ctx.message.created_at,
                                          text_fooder=ctx.author,
                                          icon_fooder=ctx.author.avatar_url))
Esempio n. 20
0
    async def _loop(self, ctx):

        current_guild = get_guild(self.client, ctx.message)
        audiocontroller = guild_to_audiocontroller[current_guild]

        if await play_check(ctx) == False:
            return

        if len(audiocontroller.playlist.playque) < 1:
            msg = "No songs in queue"
            if db.get_lang(ctx) == "ar":
                msg = "لا توجد أغانٍ في قائمة الانتظار"
            await ctx.send(embed=discord.Embed(description=f"❌ {msg}!",
                                               color=discord.Colour.red()))
            return

        if audiocontroller.playlist.loop == False:
            audiocontroller.playlist.loop = True
            await ctx.message.add_reaction("🔄")
        else:
            audiocontroller.playlist.loop = False
            await ctx.message.add_reaction("🔄")
Esempio n. 21
0
    async def tag(self, ctx, *, arg: str = None):
        if ctx.author.bot:
            return
        m = ""
        if arg is None:
            await ctx.send("""```
{}tag <message>
     ^^^^^^^^^
message is a required argument that is missing.
```
""".format(db.get_prefix(ctx)))
        msg = "The number of characters must be less than `30`"
        art = [
            pyfiglet.figlet_format(arg),
        ]
        if db.get_lang(ctx) == "ar":
            msg = "يجب أن يكون عدد الأحرف أقل من `30`"
        if len(arg) >= 30:
            await ctx.send(embed=discord.Embed(description="❌ {}".format(msg),
                                               color=discord.Colour.red()))
        else:
            await ctx.send(
                embed=discord.Embed(description=f"""```javascript\n{art}```""",
                                    color=discord.Colour.green()))
Esempio n. 22
0
 async def clear(self, ctx, amount: int):
     if amount > 200:
         if db.get_lang(ctx) == 'en':
             msg = await ctx.send(embed=discord.Embed(
                 description='You cannot delete more than 200 messages.',
                 color=discord.Colour.red()))
             await asyncio.sleep(2)
             await msg.delete()
         elif db.get_lang(ctx) == 'ar':
             msg = await ctx.send(embed=discord.Embed(
                 description='لا يمكنك حذف أكثر من 200 رسالة.',
                 color=discord.Colour.red()))
             await asyncio.sleep(2)
             await msg.delete()
     if amount <= 0:
         if db.get_lang(ctx) == "en":
             msg = await ctx.send(embed=discord.Embed(
                 description='You cannot delete less than one message.',
                 color=discord.Colour.red()))
             await asyncio.sleep(2)
             await msg.delete()
         elif db.get_lang(ctx) == "ar":
             msg = await ctx.send(embed=discord.Embed(
                 description='لا يمكنك حذف أقل من رسالة واحدة.',
                 color=discord.Colour.red()))
             await asyncio.sleep(2)
             await msg.delete()
     else:
         await ctx.message.delete()
         await ctx.channel.purge(limit=amount)
         if db.get_lang(ctx) == "en":
             msg = await ctx.send(embed=discord.Embed(
                 description="✅ Done", color=discord.Colour.green()))
             await asyncio.sleep(2)
             await msg.delete()
         elif db.get_lang(ctx) == "ar":
             msg = await ctx.send(embed=discord.Embed(
                 description="✅ تم", color=discord.Colour.green()))
             await asyncio.sleep(2)
             await msg.delete()
Esempio n. 23
0
    async def smart(self, ctx, member: discord.Member = None):
        # Open template and get drawing context
        im = Image.open('img/progress.png').convert('RGB')
        draw = ImageDraw.Draw(im)

        # Cyan-ish fill colour
        color = (98, 211, 245)

        # Draw circle at right end of progress bar
        x, y, diam = 254, 8, 34
        draw.ellipse([x, y, x + diam, y + diam], fill=color)

        # Flood-fill from extreme left of progress bar area to behind circle
        # await ctx.send(file=discord.File("img/result.png"))
        if member == None:
            member = ctx.author

            nam = randint(1, 100)
            msg = "progress IQ for"
            if db.get_lang(ctx) == "ar":
                msg = "نسبه ذكاء"
            embed = discord.Embed(
                description=f'{msg} {member.display_name} = `{nam}`',
                color=ctx.author.color,
                timestamp=ctx.message.created_at)
            embed.set_footer(text=ctx.guild.name, icon_url=ctx.guild.icon_url)
            embed.set_author(name=self.client.user.name,
                             icon_url=self.client.user.avatar_url)

            ImageDraw.floodfill(im, xy=(nam, 24), value=color, thresh=100)
            im.save('img/result.png')
            file = discord.File(f"./img/result.png", filename="result.png")
            embed.set_image(url="attachment://result.png")
            await ctx.send(file=file, embed=embed)
            os.remove("/img/result.png")

        elif member == self.client.user:
            sumbot_iq = "SumBot is smarter than your father `:-)`"
            if db.get_lang(ctx) == "ar":
                sumbot_iq = "سوم بوت اذكى من ابوك `:-)`"
            embed = discord.Embed(description=sumbot_iq,
                                  color=ctx.author.color,
                                  timestamp=ctx.message.created_at)
            embed.set_footer(text=ctx.guild.name, icon_url=ctx.guild.icon_url)
            embed.set_author(name=self.client.user.name,
                             icon_url=self.client.user.avatar_url)
            ImageDraw.floodfill(im, xy=(14, 24), value=color, thresh=100)
            file = discord.File(f"./img/result.png", filename="result.png")
            im.save('img/result.png')
            embed.set_image(url="attachment://result.png")
            await ctx.send(file=file, embed=embed)
            os.remove("/img/result.png")

        else:
            msg = "progress IQ for"
            if db.get_lang(ctx) == "ar":
                msg = "نسبه ذكاء"
            nam = randint(1, 100)
            embed = discord.Embed(
                description=f'{msg} {member.display_name} = `{nam}`',
                color=ctx.author.color,
                timestamp=ctx.message.created_at)
            embed.set_footer(text=ctx.guild.name, icon_url=ctx.guild.icon_url)
            embed.set_author(name=self.client.user.name,
                             icon_url=self.client.user.avatar_url)
            ImageDraw.floodfill(im,
                                xy=(nam, 24),
                                value=color,
                                thresh=int(nam / 1.75),
                                border=None)
            im.save('img/result.png')
            file = discord.File(f"./img/result.png", filename="result.png")
            embed.set_image(url="attachment://result.png")
            await ctx.send(file=file, embed=embed)
            os.remove("/img/result.png")
Esempio n. 24
0
    async def giveaway_create(self, ctx):
        questions = [
            "Which channel should it be hosted in?",
            "What should be the duration of the giveaway? (s|m|h|d|mo)",
            "What is the prize of the giveaway?"
        ]
        if db.get_lang(ctx) == "ar":
            questions[0] = "ما هي الروم التي يجب استضافتها؟"
            questions[1] = "حدد الوقت المناسب؟ (s|m|h|d|mo)"
            questions[2] = "ما هي جائزة الجفاوي؟"
        answers = []

        def check(m):
            return m.author == ctx.author and m.channel == ctx.channel

        for i in questions:
            await ctx.send(
                embed=discord.Embed(description=i, color=discord.Colour.red()))
            try:
                msg = await self.client.wait_for('message',
                                                 timeout=120.0,
                                                 check=check)
            except asyncio.TimeoutError:
                msg = "You didn\'t answer in time, please be quicker next time!"
                if db.get_lang(ctx) == "ar":
                    msg = "لم تجب في الوقت المناسب ، من فضلك كن أسرع في المرة القادمة!"
                await ctx.send(embed=discord.Embed(description=msg,
                                                   color=discord.Colour.red()))
                return
            else:
                answers.append(msg.content)
        try:

            c_id = int(answers[0][2:-1])
        except:
            msg = f"You didn't mention a channel properly. Do it like this {ctx.channel.mention} next time."
            if db.get_lang(ctx) == "ar":
                msg = f"لم تذكر القناة بشكل صحيح. افعل ذلك مثل {ctx.channel.mention} في المرة القادمة."
            await ctx.send(embed=discord.Embed(description=msg,
                                               color=discord.Colour.red()))
            return
        channel = self.client.get_channel(c_id)

        def convert(timer):

            pos = ["s", "m", "h", "d", "mo"]
            time_dict = {
                "s": 1,
                "m": 60,
                "h": 60 * 60,
                "d": 3600 * 24,
                "mo": 86400 * 30
            }
            unit = timer[-1]
            if unit not in pos:
                return -1
            try:
                val = int(timer[:-1])

            except:
                return -2

            return val * time_dict[unit]

        time = convert(answers[1])
        if time == -1:
            msg = f"You didn't answer the time with a proper unit. Use (s|m|h|d|mo) next time!"
            if db.get_lang(ctx) == "ar":
                msg = "لم ترد على الوقت بوحدة مناسبة. استخدم (s|m|h|d|mo) في المرة القادمة!"
            await ctx.send(embed=discord.Embed(description=msg,
                                               color=discord.Colour.red()))
            return
        elif time == -2:
            msg = "The time must be an integer. Please enter an integer next time!!"
            if db.get_lang(ctx) == "ar":
                msg = "يجب أن يكون الوقت عددًا صحيحًا. الرجاء إدخال عدد صحيح في المرة القادمة!!"
            await ctx.send(embed=discord.Embed(description=msg,
                                               color=discord.Colour.red()))
            return
        prize = answers[2]
        message = f"The Giveaway will be in {channel.mention} and will last `{answers[1]}`!"
        if db.get_lang(ctx) == "ar":
            message = f"الجفاوي في روم {channel.mention} و الوقت المحدد هو `{answers[1]}`!"
        await ctx.send(embed=discord.Embed(description=message,
                                           color=discord.Colour.green()))
        pr, end, host, win = "prize", "Ends At", "Host By", "winner"
        if db.get_lang(ctx) == "ar":
            pr, end, host, win = "الجائزه", "ينتهي بعد", "المسؤول", "الفائز"
        embed = discord.Embed(
            color=ctx.author.color,
            timestamp=ctx.message.created_at,
            description='**{}:** {}\n**{}** {}\n**{}:** {}'.format(
                pr, prize, end, answers[1], host, ctx.author.mention))
        embed.set_footer(text=ctx.guild.name, icon_url=ctx.guild.icon_url)
        embed.set_author(name=self.client.user.name,
                         icon_url=self.client.user.avatar_url)
        give = "giveaway"
        if db.get_lang(ctx) == "ar":
            give = "الجيفاوي"
        my_msg = await channel.send(f'🎉 {give}! 🎉', embed=embed)
        await my_msg.add_reaction("🎉")
        await asyncio.sleep(time)
        new_msg = await channel.fetch_message(my_msg.id)
        users = await new_msg.reactions[0].users().flatten()
        users.pop(users.index(self.client.user))
        winner = random.choice(users)

        embed = discord.Embed(
            color=ctx.author.color,
            timestamp=ctx.message.created_at,
            description="**{}:** {}\n**{}:** {}\n**{}:** {}".format(
                pr, prize, host, ctx.author.mention, win, winner.mention))
        embed.set_footer(text=ctx.guild.name, icon_url=ctx.guild.icon_url)
        embed.set_author(name=self.client.user.name,
                         icon_url=self.client.user.avatar_url)
        await my_msg.edit(embed=embed)
        msg = f"the winner is {winner.mention} Won in **{prize}**!"
        if db.get_lang(ctx) == "ar":
            msg = f"الفائز هو {winner.mention} فاز في ** {prize} **!"
        await channel.send(
            embed=discord.Embed(description=msg, color=discord.Colour.red()))
Esempio n. 25
0
    async def _play_song(self, ctx, *, track: str):
        reaction = await ctx.message.add_reaction(
            "<a:loading:797134049939816478>")

        async def uconnect(self, ctx):
            vchannel = await is_connected(ctx)
            error1 = "❌ Already connected to a voice channel"
            error2 = "❌ Please join a voice channel or enter the command in guild chat"
            if db.get_lang(ctx) == "ar":
                error1 = "❌ متصل بالفعل بقناة صوتية"
                error2 = "❌ يرجى الانضمام إلى قناة صوتية أو إدخال الأمر في دردشة النقابة"
            if vchannel is not None:
                await ctx.send(embed=discord.Embed(description=error1,
                                                   color=discord.Colour.red()))
                return

            current_guild = get_guild(self.client, ctx.message)

            if current_guild is None:
                await ctx.send(embed=discord.Embed(description=error2,
                                                   color=discord.Colour.red()))
                return
            # await ctx.message.add_reaction("<a:loading:797134049939816478>")
            guild_to_audiocontroller[current_guild] = AudioController(
                self.client, current_guild)
            await guild_to_audiocontroller[
                current_guild].register_voice_channel(ctx.author.voice.channel)
            msg_connected = "Connected to"
            if db.get_lang(ctx) == "ar":
                msg_connected = "تم الاتصال في"
            await ctx.send(embed=discord.Embed(description="✅ {} {} {}".format(
                msg_connected, ctx.author.voice.channel.name,
                ":white_check_mark:"),
                                               color=discord.Colour.green()))

        if (await is_connected(ctx) == None):
            await uconnect(self, ctx)
        if track.isspace() or not track:
            return

        if await play_check(ctx) == False:
            return

        current_guild = get_guild(self.client, ctx.message)
        audiocontroller = guild_to_audiocontroller[current_guild]

        if audiocontroller.playlist.loop == True:
            await ctx.message.remove_reaction(reaction, ctx.author)
            await ctx.message.add_reaction("🔁")
            return

        song = await audiocontroller.process_song(track)

        if song is None:
            await ctx.message.remove_reaction(reaction, ctx.author)
            await ctx.message.add_reaction("❌")
            return

        if song.origin == Origins.Default:

            if len(audiocontroller.playlist.playque) == 1:
                now_Playing, mode = "Now Playing", "Mode"
                if db.get_lang(ctx) == "ar":
                    now_Playing, mode = "المشغل الان", "الوضع"
                await ctx.send(embed=song.info.format_output(
                    now_Playing,
                    color=ctx.author.color,
                    timestamp=ctx.message.created_at,
                    text_fooder=ctx.author,
                    icon_fooder=ctx.author.avatar_url,
                    text_author=self.client.user,
                    icon_author=self.client.user.avatar_url,
                    mode=mode))
            else:
                qu, mode = "Added to queue", "Mode"
                if db.get_lang(ctx) == "ar":
                    qu, mode = "تمت الإضافة إلى قائمة الانتظار", "الوضع"
                await ctx.send(embed=song.info.format_output(
                    qu,
                    color=ctx.author.color,
                    timestamp=ctx.message.created_at,
                    text_fooder=ctx.author,
                    icon_fooder=ctx.author.avatar_url,
                    text_author=self.client.user,
                    icon_author=self.client.user.avatar_url,
                    mode=mode))

        elif song.origin == Origins.Playlist:
            msg = "Queued playlist"
            if db.get_lang(ctx) == "ar":
                msg = "تمت الإضافة إلى قائمة الانتظار"
            await ctx.send(f"{msg} :page_with_curl:")