Browse Source

Custom commands and admin roles done

tags/v1.1.0
roxie 6 years ago
parent
commit
29a0b752b0
3 changed files with 19 additions and 13 deletions
  1. +7
    -0
      cogs/customcommands.py
  2. +11
    -12
      cogs/settings.py
  3. +1
    -1
      config/servers.json

+ 7
- 0
cogs/customcommands.py View File

@@ -1,4 +1,5 @@
import discord
import checks
from discord.ext.commands import group
from config.server_config import ServerConfig
import load_config
@@ -25,12 +26,15 @@ class CustomCommands():
return await self.bot.send_message(channel, self.servers[server]["custom_commands"]["0"][msg.split(" ")[0]])

@group(pass_context=True, aliases=["cc"])
@checks.is_owner_or_admin()
async def custom(self, ctx):
"A group of commands to manage custom commands for your server."
if ctx.invoked_subcommand is None:
return await self.bot.say('Missing Argument')

@custom.command(pass_context=True)
async def add(self, ctx, command, output, prefix_required = "0"):
"Adds a custom command to the list of custom commands."
command = command.lower()
output = output.lower()
zero = self.servers[ctx.message.server.id]["custom_commands"]["0"]
@@ -53,6 +57,7 @@ class CustomCommands():

@custom.command(pass_context=True)
async def edit(self, ctx, command, edit):
"Edits an existing custom command."
zero = self.servers[ctx.message.server.id]["custom_commands"]["0"]
one = self.servers[ctx.message.server.id]["custom_commands"]["1"]

@@ -72,6 +77,7 @@ class CustomCommands():

@custom.command(pass_context=True)
async def remove(self, ctx, command):
"Removes a custom command."
command = command.lower()
if command in self.servers[ctx.message.server.id]["custom_commands"]["1"]:
self.servers[ctx.message.server.id]["custom_commands"]["1"].pop(command)
@@ -87,6 +93,7 @@ class CustomCommands():

@custom.command(pass_context=True)
async def list(self, ctx):
"Lists all custom commands for this server."
l = self.servers[ctx.message.server.id]["custom_commands"]
listzero = ""
listone = ""

+ 11
- 12
cogs/settings.py View File

@@ -21,15 +21,12 @@ class Settings():
self.con = ServerConfig()
self.servers = self.con.servers

@bot.command(pass_context=True, hidden=True)
@checks.is_bot_owner()
@bot.command(pass_context=True)
@checks.is_owner_or_admin()
async def blacklist(self, ctx, option, *args):
"""
Usage:
.blacklist [ + | - | add | remove ] @UserName [@UserName2 ...]
Add or remove users to the blacklist.
OWNER OR ADMIN ONLY: Add or remove users to the blacklist.
Blacklisted users are forbidden from using bot commands.
Only the bot owner can use this command
"""
blacklist_amount = 0
mentions = ctx.message.mentions
@@ -74,9 +71,10 @@ class Settings():
blacklist_amount += 1
return await self.bot.say('{} user(s) have been removed from the blacklist'.format(blacklist_amount))

@bot.command(pass_context=True, hidden=True)
@checks.is_bot_owner()
@bot.command(pass_context=True)
@checks.is_owner_or_admin()
async def enablesetting(self, ctx, setting):
"OWNER OR ADMIN ONLY: Enables settings in the server config."
self.serverconfig = self.con.load_config()
server_id = ctx.message.server.id
if setting in self.serverconfig[server_id]:
@@ -92,12 +90,13 @@ class Settings():
return await self.bot.say("That module dont exist fam. You made the thing")

@bot.command(pass_context=True)
@checks.is_bot_owner()
@checks.is_owner_or_admin()
async def printsettings(self, ctx):
"OWNER OR ADMIN ONLY: Prints the servers config file."
self.serverconfig = self.con.load_config()
config = self.serverconfig[ctx.message.server.id]
em = discord.Embed(colour=0xDEADBF)
em.set_author(name="RoxBot settings for {}.".format(ctx.message.server.name), icon_url=self.bot.user.avatar_url)
em.set_author(name="{} settings for {}.".format(self.bot.user.name, ctx.message.server.name), icon_url=self.bot.user.avatar_url)

for settings in config:
settingcontent = ""
@@ -188,7 +187,7 @@ class Settings():
self.servers = self.con.load_config()
try:
self.servers[ctx.message.server.id]["perm_roles"]["admin"].remove(role.id)
except KeyError:
except ValueError:
return await self.bot.say("That role was not in the list.")
self.con.update_config(self.servers)
return await self.bot.say("'{}' has been removed from the Admin role list.".format(role.name))
@@ -198,7 +197,7 @@ class Settings():
self.servers = self.con.load_config()
try:
self.servers[ctx.message.server.id]["perm_roles"]["mod"].remove(role.id)
except KeyError:
except ValueError:
return await self.bot.say("That role was not in the list.")
self.con.update_config(self.servers)
return await self.bot.say("'{}' has been removed from the Mod role list.".format(role.name))

+ 1
- 1
config/servers.json View File

@@ -1 +1 @@
{"304048071963312130": {"greets": {"enabled": 0, "welcome-channel": "", "member-role": "", "custom-message": "hellow", "default-message": "Be sure to read the rules."}, "goodbyes": {"enabled": 0, "goodbye-channel": ""}, "self_assign": {"enabled": 0, "roles": []}, "twitch": {"enabled": 0, "twitch-channel": "", "whitelist": {"enabled": 0, "list": []}}, "mute": {"role": "", "admin-role": []}, "nsfw": {"enabled": 0}, "admin_role": {"role": ""}, "custom_commands": {"0": {"test": "\"testedit\"", "hello": "<:tingles:346838411639914506>", "benis": "\ud83c\udd71enis", "sophie": "<@136619052994002944>", "myra": "<@342213251372941312>", "roxieee": "<@!142735312626515979>", "customs": "\"\ud83d\udec3\"", "zzz": "\ud83d\udca4", "lewd!": "\ud83d\udea8 lewd! \ud83d\udea8"}, "1": {}}, "perm_roles": {"admin": ["308082456743903233", "308083509866659850"], "mod": ["307330606348632064"]}}}
{"304048071963312130": {"greets": {"enabled": 0, "welcome-channel": "", "member-role": "", "custom-message": "hellow", "default-message": "Be sure to read the rules."}, "goodbyes": {"enabled": 0, "goodbye-channel": ""}, "self_assign": {"enabled": 0, "roles": []}, "twitch": {"enabled": 0, "twitch-channel": "", "whitelist": {"enabled": 0, "list": []}}, "mute": {"role": "", "admin-role": []}, "nsfw": {"enabled": 0}, "admin_role": {"role": ""}, "custom_commands": {"0": {"test": "\"testedit\"", "hello": "<:tingles:346838411639914506>", "benis": "\ud83c\udd71enis", "sophie": "<@136619052994002944>", "myra": "<@342213251372941312>", "roxieee": "<@!142735312626515979>", "customs": "\"\ud83d\udec3\"", "zzz": "\ud83d\udca4", "lewd!": "\ud83d\udea8 lewd! \ud83d\udea8"}, "1": {}}, "perm_roles": {"admin": [], "mod": []}}}

Loading…
Cancel
Save