Making the VC command and restricting it to only adminsitrators

This commit is contained in:
Luke Robles 2022-05-03 17:18:33 -07:00
parent 019f2dd1f8
commit e570616b61
5 changed files with 71 additions and 27 deletions

View File

@ -5,4 +5,7 @@
- How? - How?
* `briefly describe what this PR is doing to remedy the issue` * `briefly describe what this PR is doing to remedy the issue`
- Why? - Why?
* `is there an open issue associated with this PR? if so, reference it with #56 (or whatever the issue number is)` * `is there an open issue associated with this PR? if so, reference it with #56 (or whatever the issue number is)`
- Is it...?
* [ ] Based?
* [ ] Dale-pilled?

5
app/bot.py Executable file → Normal file
View File

@ -16,10 +16,7 @@ cogfiles = [
] ]
for cogfile in cogfiles: for cogfile in cogfiles:
try: bot.load_extension(cogfile)
bot.load_extension(cogfile)
except Exception as e:
print(e)
@bot.event @bot.event

View File

@ -1,6 +1,6 @@
from discord.ext import commands from discord.ext import commands
import os
import discord import discord
import os
class ServerUtils(commands.Cog): class ServerUtils(commands.Cog):
@ -60,6 +60,7 @@ class ServerUtils(commands.Cog):
return return
@commands.command() @commands.command()
@commands.has_permissions(administrator=True)
async def timeout( async def timeout(
self, self,
ctx: commands.Context, ctx: commands.Context,
@ -68,9 +69,6 @@ class ServerUtils(commands.Cog):
*, *,
reason=None, reason=None,
): ):
if not ctx.message.author.discriminator in ["2528", "4082"]:
return
import humanfriendly import humanfriendly
import datetime import datetime
@ -169,6 +167,46 @@ class ServerUtils(commands.Cog):
await ctx.message.delete() await ctx.message.delete()
await ctx.message.guild.leave() await ctx.message.guild.leave()
@commands.command(name="vc")
@commands.has_permissions(administrator=True)
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
):
await ctx.send(
":x: A role named `%s` already exists :x:" % channel_role_name
)
return
# Create a role and assign it a random color
try:
role = await ctx.message.guild.create_role(
name=channel_role_name,
mentionable=True,
hoist=True,
color=discord.Color.random(),
)
overwrites = {
role: discord.PermissionOverwrite(connect=True, speak=True),
ctx.message.guild.default_role: discord.PermissionOverwrite(
connect=False
),
}
await ctx.message.guild.create_voice_channel(
name=channel_role_name, bitrate=96000, overwrites=overwrites
)
await ctx.send(
":white_check_mark: Created a role + voice channel for %s"
% role.mention
)
except Exception as e:
await ctx.send(":x: Error: %s :x:" % e)
@commands.command(name="help") @commands.command(name="help")
async def help(self, ctx: commands.Context, method): async def help(self, ctx: commands.Context, method):

View File

@ -178,6 +178,11 @@ def get_help_message(method):
"\nUsage: !youtube sick bmx tricks", "\nUsage: !youtube sick bmx tricks",
], ],
"wink": ["returns a anime girl winking at you", "\nUsage: !wink"], "wink": ["returns a anime girl winking at you", "\nUsage: !wink"],
"vc": [
"Creates a role and voice channel named whatever you pass in. Only takes one argument\n",
"\nGives the role permissions to enter the voice channel\n"
"\nUsage: !vc some_role_name",
],
"verify": [ "verify": [
"Adds the twitter blue check mark to the previous message\n", "Adds the twitter blue check mark to the previous message\n",
"\nLiterally thats all it does\n" "\nUsage: !verify", "\nLiterally thats all it does\n" "\nUsage: !verify",
@ -190,40 +195,41 @@ def get_help_message(method):
def get_help_embed(bot): def get_help_embed(bot):
categories = { categories = {
"fun": [ "fun": [
"nft",
"bf5", "bf5",
"ffxiv",
"clap", "clap",
"youtube",
"excuse", "excuse",
"ffxiv",
"greentext", "greentext",
"lewd",
"message",
"meme",
"homepage", "homepage",
"horny",
"lewd",
"meme",
"message",
"nft",
"owo",
"pout", "pout",
"roll", "roll",
"smug",
"owo",
"wink",
"verify",
"horny",
"wasted",
"simp", "simp",
"smug",
"trackdays", "trackdays",
"verify",
"wasted",
"wink",
"youtube",
], ],
"util": [ "util": [
"8ball",
"ask", "ask",
"corona", "corona",
"emoji",
"8ball",
"decide", "decide",
"info", "emoji",
"icon", "icon",
"wallpaper", "info",
"issue",
"stock", "stock",
"tts", "tts",
"issue", "vc",
"wallpaper",
], ],
"users": ["help", "invite", "purge", "roles", "source"], "users": ["help", "invite", "purge", "roles", "source"],
"pictures of animals": [ "pictures of animals": [

View File

@ -6,7 +6,7 @@ replicaCount: 1
image: image:
# Overrides the image tag whose default is the chart appVersion. # Overrides the image tag whose default is the chart appVersion.
tag: "171" tag: "172"
repository: ldooks/dragon-bot repository: ldooks/dragon-bot
pullPolicy: IfNotPresent pullPolicy: IfNotPresent