Ejemplo n.º 1
0
    async def leave(self, ctx: commands.Context) -> None:
        async with ctx.channel.typing():

            server = self.bot.voice_manager.get(ctx.guild.id)
            if server is None:
                await ctx.send(
                    embed=error_embed("このサーバーは接続されていません。", ctx)
                )
                return

            if (ctx.author.voice is None) or (ctx.author.voice.channel is None):
                await ctx.send(embed=error_embed("ボイスチャンネルに接続した状態で実行してください。", ctx))
                return

            if server.read_text_channel.id != ctx.channel.id:
                await ctx.send(
                    embed=error_embed('読み上げるチャンネルと同じチャンネルで実行してください。', ctx)
                )

            if ctx.author.voice.channel.id != server.send_voice_channel.id:
                await ctx.send(
                    embed=error_embed("Botと同じボイスチャンネルで実行してください。", ctx)
                )
                return

            # 処理を終了させる
            await self.bot.voice_manager.close(ctx.guild.id)
Ejemplo n.º 2
0
    async def move_error(self, ctx: commands.Context, exception: Exception) -> None:
        exception = getattr(exception, 'original', exception)

        if isinstance(exception, discord.ClientException):
            await ctx.send(embed=error_embed("失敗しました。もう一度実行してください。人数が埋まっているなどの理由が考えられます。", ctx))
        else:
            await ctx.send(
                embed=error_embed('予期せぬエラーが発生しました。再度お試しください。それでも表示される場合は公式サポートサーバーよりご連絡ください。', ctx)
            )
            print(exception)
Ejemplo n.º 3
0
    async def move(self, ctx: commands.Context) -> None:
        """Botを移動させる"""
        async with ctx.channel.typing():
            server = self.bot.voice_manager.get(ctx.guild.id)
            if server is None:
                await ctx.send(embed=error_embed("このサーバーは接続されていません。", ctx))
                return

            if (ctx.author.voice is None) or (ctx.author.voice.channel is None):
                await ctx.send(embed=error_embed("ボイスチャンネルに接続した状態で実行してください。", ctx))
                return

            # VoiceClient.move_toを実行
            await server.move_voice_channel(ctx.author.voice.channel, ctx.channel)
            await ctx.send(embed=success_embed('移動しました。', ctx))
Ejemplo n.º 4
0
    async def join_error(self, ctx: commands.Context, exception: Exception) -> None:
        exception = getattr(exception, 'original', exception)

        if isinstance(exception, discord.ClientException):
            await ctx.send(embed=error_embed("このサーバー内で既に利用されています。moveコマンドを使用するか、切断してから再度お試しください。", ctx))

        elif isinstance(exception, asyncio.TimeoutError):
            await ctx.send(
                embed=error_embed('接続できませんでした。ユーザー数が埋まっている可能性があります。再度お試しください。', ctx)
            )

        else:
            await ctx.send(
                embed=error_embed('予期せぬエラーが発生しました。再度お試しください。それでも表示される場合は公式サポートサーバーよりご連絡ください。', ctx)
            )
            print(exception)
Ejemplo n.º 5
0
    async def speed(self, ctx: commands.Context, speed: float = 1.0) -> None:
        if speed < 0.5 or 4.0 < speed:
            await ctx.send(embed=error_embed('スピードは0.5から4.0の間で指定してください。', ctx))
            return

        await change_speed(self.bot, ctx, speed)
        await self.refresh(ctx)
Ejemplo n.º 6
0
    async def pitch(self, ctx: commands.Context, pitch: float = 0.0) -> None:
        if pitch < -6.5 or 6.5 < pitch:
            await ctx.send(embed=error_embed('ピッチは-6.5から6.5の間で指定してください。', ctx))
            return

        await change_pitch(self.bot, ctx, pitch)
        await self.refresh(ctx)
Ejemplo n.º 7
0
async def ja_setting(bot: 'BardBot', ctx: commands.Context,
                     voice_type: str) -> None:
    if voice_type.upper() not in JA_VOICE_TYPES:
        await ctx.send(embed=error_embed(
            f"ボイスの設定は`{get_types_text(JA_VOICE_TYPES)}`から選んでください。", ctx))
        return

    await edit_voice_type(bot, ctx, 'ja', voice_type.upper())
Ejemplo n.º 8
0
    async def remove(self, ctx: commands.Context, *, key: str) -> None:
        document = self.bot.firestore.dict.get(ctx.guild.id)
        if not await document.remove(key):

            await ctx.send(embed=error_embed(f'{key}は存在しません。', ctx))
            return

        self.bot.guild_dicts.set(ctx.guild.id, await document.data())
        await ctx.send(embed=success_embed(f'{key}を削除しました。', ctx))
Ejemplo n.º 9
0
 async def limit(self, ctx: commands.Context, limit: int = 100) -> None:
     if limit <= 0 or 2000 < limit:
         await ctx.send(embed=error_embed('文字数は1から2000の間で指定してください。', ctx))
         return
     document = self.bot.firestore.setting.get(ctx.guild.id)
     data = await document.data()
     await document.edit(limit=limit)
     await self.refresh(ctx, document)
     await ctx.send(embed=success_embed(
         f'文字数制限を`{data.limit}`文字から`{limit}`文字に変更しました。', ctx))
Ejemplo n.º 10
0
    async def join(self, ctx: commands.Context) -> None:
        async with ctx.channel.typing():
            # サーバー内で既に利用されていた場合
            if self.bot.voice_manager.get(ctx.guild.id) is not None:
                await ctx.send(
                    embed=error_embed("このサーバー内で既に利用されています。moveコマンドを使用するか、切断してから再度お試しください。", ctx)
                )
                return

            # 実行したユーザーがVCにいない場合
            if (ctx.author.voice is None) or (ctx.author.voice.channel is None):
                await ctx.send(
                    embed=error_embed("ボイスチャンネルに接続した状態で実行してください。", ctx)
                )
                return

            # 残り文字数が足りているか
            data = await self.bot.firestore.guild.get(ctx.guild.id).data()
            if data.count == 0:
                await ctx.send(
                    embed=error_embed("今月の利用可能文字数を超えています。\nまだご利用になりたい場合は、公式サイトより購入してください。", ctx)
                )
                return

            voice_channel = ctx.author.voice.channel
            voice_client = await voice_channel.connect(timeout=5.0)

            # ボイスサーバーの作成
            server = VoiceServer(self.bot, voice_channel, ctx.channel, voice_client)
            await server.setup()

            self.bot.voice_manager.set(ctx.guild.id, server)

            await ctx.send(embed=success_embed("接続しました。", ctx))
            await self.bot.get_channel(733199945930113074).send(f"{ctx.guild.name} が接続しました。")

            try:
                # 多くのbotがやってるからつけてみた
                await ctx.guild.me.edit(deafen=True)
            except Exception:
                pass
Ejemplo n.º 11
0
    async def predicate(ctx: commands.Context) -> bool:
        role = [r for r in ctx.guild.roles if r.name == "BardManager"]
        if not role:
            return True

        if ctx.author.guild_permissions.administrator:
            return True

        for role in ctx.author.roles:
            if role.name == "BardManager":
                return True

        await ctx.send(
            embed=error_embed("あなたは`BardManager` 役職を持っていないため、このコマンドを実行することができません。", ctx)
        )

        return False
Ejemplo n.º 12
0
    async def on_message(self, message: discord.Message):
        if message.author.bot:
            return

        context = await self.get_context(message)

        if context.command is not None:
            if context.command.name in [
                    'help', 'voice', 'pitch', 'speed', 'cmd'
            ]:
                await self.invoke(context)
                return
            if message.guild is None:
                await message.channel.send(
                    embed=error_embed('このコマンドはサーバー内でのみ使用可能です。', context))
                return
            await self.invoke(context)
Ejemplo n.º 13
0
 async def leave_error(self, ctx: commands.Context, exception: Exception) -> None:
     await ctx.send(
         embed=error_embed('予期せぬエラーが発生しました。再度お試しください。それでも表示される場合は公式サポートサーバーよりご連絡ください。', ctx)
     )
     print(exception)