diff --git a/app/cogs/server_utils.py b/app/cogs/server_utils.py index e01aa4a9..e3770329 100644 --- a/app/cogs/server_utils.py +++ b/app/cogs/server_utils.py @@ -1,4 +1,5 @@ from discord.ext import commands +from discord import option import core_utils import discord import os @@ -194,14 +195,15 @@ class ServerUtils(commands.Cog): await ctx.message.delete() await ctx.message.guild.leave() - @commands.command(name="vc") + @commands.slash_command( + name="vc", + description="Creates a role and voice channel of the same name", + ) @commands.has_permissions(administrator=True) - async def vc(self, ctx: commands.Context, *, channel_role_name): + async def vc(self, ctx: commands.Context, channel_role_name): # Check that the role/channel doesnt already exist # returns either a string or None, so we'll proceed on the None condition - if discord.utils.find( - lambda r: r.name == channel_role_name, ctx.message.guild.roles - ): + if discord.utils.find(lambda r: r.name == channel_role_name, ctx.guild.roles): await ctx.send( ":x: A role named `%s` already exists :x:" % channel_role_name ) @@ -209,7 +211,7 @@ class ServerUtils(commands.Cog): # Create a role and assign it a random color try: - role = await ctx.message.guild.create_role( + role = await ctx.guild.create_role( name=channel_role_name, mentionable=True, hoist=True, @@ -218,21 +220,19 @@ class ServerUtils(commands.Cog): overwrites = { role: discord.PermissionOverwrite(connect=True, speak=True), - ctx.message.guild.default_role: discord.PermissionOverwrite( - connect=False - ), + ctx.guild.default_role: discord.PermissionOverwrite(connect=False), } - await ctx.message.guild.create_voice_channel( + await ctx.guild.create_voice_channel( name=channel_role_name, bitrate=96000, overwrites=overwrites ) - await ctx.reply( + await ctx.respond( ":white_check_mark: Created a role + voice channel for %s" % role.mention ) except Exception as e: - await ctx.reply(":x: Error: %s :x:" % e) + await ctx.respond(":x: Error: %s :x:" % e) @commands.command(name="help") async def help(self, ctx: commands.Context, method=None):