команда настройки бота Discord - PullRequest
0 голосов
/ 05 августа 2020

Я пытаюсь создать команду настройки для своего бота Discord, так как ему придется проверять связь с ролями и т. Д. c. Я пробовал кое-что, но это закончилось катастрофой (см. Ниже) . Если бы я мог получить некоторую помощь с очисткой кода + заставить его работать, было бы здорово! Когда вы запускаете команду, она должна запрашивать у вас 2 роли и 1 канал в качестве входных данных. Он будет использовать их в других командах. Проблема в том, что он не сохраняет каналы и роли должным образом ...

Результат должен выглядеть примерно так: https://gyazo.com/7f91b8ce918918ec5614a5fb2e7fb025*

@commands.command()
    @commands.check(is_guild_owner)
    async def setup(self, ctx):
        def msgcheck(m):
            return m.channel == ctx.channel and m.author == ctx.author

        await ctx.send("Starting the setup...")
        await ctx.send("What role should I ping for paid splashes?")
        try:
            splashping = await self.bot.wait_for('message', timeout=600.0, check=msgcheck)
        except asyncio.TimeoutError:
            await ctx.send("You were too slow, make a new request", delete_after=10)
        splashpingrole = splashping.content
        await ctx.send(f"Role confirmed, I will ping {splashpingrole} to announce paid splashes.")
        await ctx.send("What role is used for all staff?")
        try:
            staffping = await self.bot.wait_for('message', timeout=600.0, check=msgcheck)
        except asyncio.TimeoutError:
            await ctx.send("You were too slow, make a new request", delete_after=10)
        staffpingrole = staffping.content
        await ctx.send(f"Role confirmed, {staffpingrole} has access to my staff commands.")
        await ctx.send("Where do you want me to announce the paid splashes?")
        try:
            splashchannel = await self.bot.wait_for('message', timeout=600.0, check=msgcheck)
        except asyncio.TimeoutError:
            await ctx.send("You were too slow, make a new request", delete_after=10)
        splashchannels = splashchannel.content
        await ctx.send(f"Channel confirmed, I will send the paid splashes in {splashchannels}.")
        await ctx.channel.purge(limit=11)

        with open("serversettings.json", 'w') as f:
            json.dump(splashpingrole, f, indent=4)
            json.dump(staffpingrole, f, indent=4)
            json.dump(splashchannels, f, indent=4)



        embed = discord.Embed(
            title=f'⚙ Bot Settings:',
            colour=discord.Colour(0xC0C0C0), )
        embed.add_field(name="__Splash Ping Role:__", value=f"{splashpingrole}", inline=True)
        embed.add_field(name="__Staff Role:__", value=f"{staffpingrole}", inline=True)
        embed.add_field(name="__Splash Announcement channel:__", value=f"{splashchannels}", inline=True)
        embed.set_footer(text="If you want to change these settings, run the setup command again.")
        await ctx.send(embed=embed)

нет ответа более 24 часов wtf ??

...