Exemplo n.º 1
0
async def change_speed(bot: 'BardBot', ctx: commands.Context,
                       speed: float) -> None:
    document = bot.firestore.user.get(ctx.author.id)
    data = await document.data()
    await document.edit(speed=speed)
    await ctx.send(
        embed=success_embed(f'スピードを{data.speed}から{speed}に変更しました。', ctx))
Exemplo n.º 2
0
    async def add(self, ctx: commands.Context, key: str, *,
                  value: str) -> None:
        document = self.bot.firestore.dict.get(ctx.guild.id)
        await document.add(key, value)

        self.bot.guild_dicts.set(ctx.guild.id, await document.data())
        await ctx.send(embed=success_embed(f'{key}を{value}として登録しました。', ctx))
Exemplo n.º 3
0
async def change_pitch(bot: 'BardBot', ctx: commands.Context,
                       pitch: float) -> None:
    document = bot.firestore.user.get(ctx.author.id)
    data = await document.data()
    await document.edit(pitch=pitch)
    await ctx.send(
        embed=success_embed(f'ピッチを{data.pitch}から{pitch}に変更しました。', ctx))
Exemplo n.º 4
0
 async def bot(self, ctx: commands.Context) -> None:
     document = self.bot.firestore.setting.get(ctx.guild.id)
     data = await document.data()
     await document.edit(bot=not data.bot)
     await self.refresh(ctx, document)
     await ctx.send(embed=success_embed(
         f'Botのメッセージを `{t_or_f(data.bot)}` から `{t_or_f(not data.bot)}` に変更しました。',
         ctx))
Exemplo n.º 5
0
async def edit_voice_type(bot: 'BardBot', ctx: commands.Context, language: str,
                          voice_type: str) -> None:
    document = bot.firestore.user.get(ctx.author.id)
    data = await document.data()
    await document.edit(voice={language: voice_type})
    await ctx.send(embed=success_embed(
        f'{language}のボイスの設定を{data.voice[language]}から{voice_type}に変更しました。', ctx)
                   )
Exemplo n.º 6
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))
Exemplo n.º 7
0
 async def keep(self, ctx: commands.Context) -> None:
     document = self.bot.firestore.setting.get(ctx.guild.id)
     data = await document.data()
     await document.edit(keep=not data.keep)
     b = '再接続する' if data.keep else '再接続しない'
     a = '再接続する' if (not data.keep) else '再接続しない'
     await self.refresh(ctx, document)
     await ctx.send(
         embed=success_embed(f'接続が切られても `{b}` から `{a}` に変更しました。', ctx))
Exemplo n.º 8
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))
Exemplo n.º 9
0
    async def fleave(self, ctx: commands.Context) -> None:
        """強制的に終了させる"""
        server = self.bot.voice_manager.get(ctx.guild.id)
        if server is None:
            for client in self.bot.voice_clients:
                if client.guild.id == ctx.guild.id:
                    await client.disconnect()
        else:
            await self.bot.voice_manager.close(ctx.guild.id)

        await ctx.send(embed=success_embed('処理が完了しました。', ctx))
Exemplo n.º 10
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))
Exemplo n.º 11
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