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

import discord import discord
import checks
from discord.ext.commands import group from discord.ext.commands import group
from config.server_config import ServerConfig from config.server_config import ServerConfig
import load_config import load_config
return await self.bot.send_message(channel, self.servers[server]["custom_commands"]["0"][msg.split(" ")[0]]) return await self.bot.send_message(channel, self.servers[server]["custom_commands"]["0"][msg.split(" ")[0]])


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


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


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




@custom.command(pass_context=True) @custom.command(pass_context=True)
async def remove(self, ctx, command): async def remove(self, ctx, command):
"Removes a custom command."
command = command.lower() command = command.lower()
if command in self.servers[ctx.message.server.id]["custom_commands"]["1"]: if command in self.servers[ctx.message.server.id]["custom_commands"]["1"]:
self.servers[ctx.message.server.id]["custom_commands"]["1"].pop(command) self.servers[ctx.message.server.id]["custom_commands"]["1"].pop(command)


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

+ 11
- 12
cogs/settings.py View File

self.con = ServerConfig() self.con = ServerConfig()
self.servers = self.con.servers 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): 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. Blacklisted users are forbidden from using bot commands.
Only the bot owner can use this command
""" """
blacklist_amount = 0 blacklist_amount = 0
mentions = ctx.message.mentions mentions = ctx.message.mentions
blacklist_amount += 1 blacklist_amount += 1
return await self.bot.say('{} user(s) have been removed from the blacklist'.format(blacklist_amount)) 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): async def enablesetting(self, ctx, setting):
"OWNER OR ADMIN ONLY: Enables settings in the server config."
self.serverconfig = self.con.load_config() self.serverconfig = self.con.load_config()
server_id = ctx.message.server.id server_id = ctx.message.server.id
if setting in self.serverconfig[server_id]: if setting in self.serverconfig[server_id]:
return await self.bot.say("That module dont exist fam. You made the thing") return await self.bot.say("That module dont exist fam. You made the thing")


@bot.command(pass_context=True) @bot.command(pass_context=True)
@checks.is_bot_owner()
@checks.is_owner_or_admin()
async def printsettings(self, ctx): async def printsettings(self, ctx):
"OWNER OR ADMIN ONLY: Prints the servers config file."
self.serverconfig = self.con.load_config() self.serverconfig = self.con.load_config()
config = self.serverconfig[ctx.message.server.id] config = self.serverconfig[ctx.message.server.id]
em = discord.Embed(colour=0xDEADBF) 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: for settings in config:
settingcontent = "" settingcontent = ""
self.servers = self.con.load_config() self.servers = self.con.load_config()
try: try:
self.servers[ctx.message.server.id]["perm_roles"]["admin"].remove(role.id) 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.") return await self.bot.say("That role was not in the list.")
self.con.update_config(self.servers) self.con.update_config(self.servers)
return await self.bot.say("'{}' has been removed from the Admin role list.".format(role.name)) return await self.bot.say("'{}' has been removed from the Admin role list.".format(role.name))
self.servers = self.con.load_config() self.servers = self.con.load_config()
try: try:
self.servers[ctx.message.server.id]["perm_roles"]["mod"].remove(role.id) 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.") return await self.bot.say("That role was not in the list.")
self.con.update_config(self.servers) self.con.update_config(self.servers)
return await self.bot.say("'{}' has been removed from the Mod role list.".format(role.name)) return await self.bot.say("'{}' has been removed from the Mod role list.".format(role.name))

+ 1
- 1
config/servers.json View File

{"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