Skip to content

Commit

Permalink
add guild_only protection
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulMarisOUMary committed Mar 21, 2022
1 parent 6b4ed6f commit 1bc7dac
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cogs/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ async def kill_loop(self, ctx, cog):

@commands.command(name="deletechannel", aliases=["delc"], require_var_positional=True)
@commands.is_owner()
@commands.guild_only()
async def delete_channel(self, ctx, channel_name):
"""Delete the provided channel."""
channel = discord.utils.get(ctx.guild.channels, name=channel_name)
Expand All @@ -128,6 +129,7 @@ async def delete_channel(self, ctx, channel_name):

@commands.command(name="changeprefix", aliases=["cp"], require_var_positional=True)
@commands.has_guild_permissions(administrator=True)
@commands.guild_only()
async def change_guild_prefix(self, ctx, new_prefix):
"""Change the guild prefix."""
try:
Expand Down
4 changes: 4 additions & 0 deletions cogs/privatetextual.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def help_custom(self):

@commands.command(name="createprivate", aliases=["create", '+'], require_var_positional=True)
@commands.cooldown(1, 10, commands.BucketType.user)
@commands.guild_only()
async def create_private_channel(self, ctx, *members : discord.Member):
"""Create a private textual channel."""
users, mentions, down_role = [ctx.message.author], "", discord.utils.get(ctx.guild.roles, name="🎓Student")
Expand All @@ -59,6 +60,7 @@ async def create_private_channel(self, ctx, *members : discord.Member):
await ctx.message.add_reaction(emoji="<a:checkmark_a:842800730049871892>")

@commands.command(name="deleteprivate", aliases=["delete", '-'])
@commands.guild_only()
async def delete_private_channel(self, ctx):
"""Delete your private textual channel."""
channel, roles = ctx.channel, get_created_roles(ctx)
Expand All @@ -69,6 +71,7 @@ async def delete_private_channel(self, ctx):
raise commands.CommandError("You can't delete a non-team channel.")

@commands.command(name="renameprivate", aliases=["rename", '_'], require_var_positional=True)
@commands.guild_only()
async def rename_private_channel(self, ctx, custom_name : str):
"""Rename your private textual channel."""
channel, roles = ctx.channel, get_created_roles(ctx)
Expand All @@ -81,6 +84,7 @@ async def rename_private_channel(self, ctx, custom_name : str):
if forbidden: raise commands.CommandError(f"You can't use `{forbidden}` to rename a channel.")

@commands.command(name="addprivate", aliases=["add", '>'], require_var_positional=True)
@commands.guild_only()
async def addd_to_private_channel(self, ctx, *members : discord.Member):
"""Join a specified member to your team channel."""
roles = get_created_roles(ctx)
Expand Down
1 change: 1 addition & 0 deletions cogs/usefull.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def help_custom(self):
return emoji, label, description

@commands.command(name="strawpoll", aliases=["straw", "stp", "sond", "sondage"], require_var_positional=True)
@commands.guild_only()
async def strawpool(self, ctx, *, context):
"""Ask a sondage, and add 2 reactions to vote with your community."""
crossmark, checkmark = self.bot.get_emoji(842800737221607474), self.bot.get_emoji(842800730049871892)
Expand Down
3 changes: 3 additions & 0 deletions cogs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ def help_custom(self):
return emoji, label, description

@commands.command(name="bool")
@commands.guild_only()
async def boo(self, ctx):
"""Discover buttons feature with this command."""
view = bool.View(flabel="Agree", slabel="Disagree", sstyle=discord.ButtonStyle.red, emojis = True, source=ctx)
await ctx.send("Buttons demo right there !", view=view)

@commands.command(name="dropdown")
@commands.guild_only()
async def dro(self, ctx):
"""Discover select menu feature with this command."""
options = [
Expand Down Expand Up @@ -54,6 +56,7 @@ async def dro(self, ctx):
await ctx.send("Dropdown demo right there !", view=view)

@commands.command(name="link")
@commands.guild_only()
async def lin(self, ctx):
"""Discover button link with this feature."""
view = link.View(label="Source code on Github", url="https://github.com/PaulMarisOUMary/Algosup-Discord")
Expand Down

0 comments on commit 1bc7dac

Please sign in to comment.