Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock command if you need it (I saw it in TODO.md) #50

Closed
Ravost99 opened this issue Nov 18, 2021 · 2 comments
Closed

Lock command if you need it (I saw it in TODO.md) #50

Ravost99 opened this issue Nov 18, 2021 · 2 comments

Comments

@Ravost99
Copy link

Ravost99 commented Nov 18, 2021

I don't really know how slash commands work but here you go.

@commands.command(name="lock")
@commands.has_permissions(manage_channels=True)
async def lock(self, context, channel: discord.TextChannel=None):
    channel = channel or context.channel
    overwrite = channel.overwrites_for(context.guild.default_role)
    overwrite.send_messages = False
    overwrite.add_reactions = False
    await channel.set_permissions(context.guild.default_role, overwrite=overwrite)
    await context.send(':lock: Channel locked.')
    
@commands.command(name="unlock")
@commands.has_permissions(manage_channels=True)
async def unlock(self, context, channel: discord.TextChannel=None):
    channel = channel or context.channel
    overwrite = channel.overwrites_for(context.guild.default_role)
    overwrite.send_messages = True
    overwrite.add_reactions = True
    await channel.set_permissions(context.guild.default_role, overwrite=overwrite)
    await context.send(':closed_lock_with_key: Channel unlocked.')
@kkrypt0nn
Copy link
Owner

It's actually already finished with slash command, just working on moving to disnake or something similar, therefore it will take a little bit longer.
But thanks!

@Ravost99
Copy link
Author

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants