brodycritchlow / Flipping-Bot

MIT License
0 stars 0 forks source link

Refactor main.py into separate cogs #5

Closed sweep-ai[bot] closed 10 months ago

sweep-ai[bot] commented 10 months ago

PR Feedback (click)

Summary

Fixes #3.


πŸŽ‰ Latest improvements to Sweep:


πŸ’‘ To get Sweep to edit this pull request, you can:

sweep-ai[bot] commented 10 months ago

Sandbox Executions

sweep-ai[bot] commented 10 months ago

Apply Sweep Rules to your PR?

brodycritchlow commented 10 months ago

You didn't seperate them into cogs? Below is an example of a cog:

class Greetings(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self._last_member = None

    @commands.Cog.listener()
    async def on_member_join(self, member):
        channel = member.guild.system_channel
        if channel is not None:
            await channel.send(f'Welcome {member.mention}.')

    @commands.command()
    async def hello(self, ctx, *, member: nextcord.Member = None):
        """Says hello"""
        member = member or ctx.author
        if self._last_member is None or self._last_member.id != member.id:
            await ctx.send(f'Hello {member.name}~')
        else:
            await ctx.send(f'Hello {member.name}... This feels familiar.')
        self._last_member = member

And then in main.py: bot.add_cog(Greetings(bot))

sweep-ai[bot] commented 10 months ago

πŸš€ Wrote Changes

I wasn't able to make changes. This could be due to an unclear request or a bug in my code. As a reminder, comments on a file only modify that file. Comments on a PR (at the bottom of the "conversation" tab) can modify the entire PR. Please try again or contact us on Discord