@@ -81,6 +81,7 @@ class Admin(): | |||
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) | |||
else: | |||
if setting in self.con.serverconfig[ctx.message.server.id]: | |||
self.con.serverconfig = self.con.load_config() | |||
if not self.con.serverconfig[ctx.message.server.id][setting]["enabled"]: | |||
self.con.serverconfig[ctx.message.server.id][setting]["enabled"] = 1 | |||
self.con.updateconfig() | |||
@@ -96,30 +97,40 @@ class Admin(): | |||
async def set_welcomechannel(self, ctx, channel: discord.Channel = None): | |||
if not owner(ctx): | |||
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) | |||
self.con.serverconfig[ctx.message.server.id]["greets"]["welcome-channel"] = channel.id | |||
self.con.updateconfig() | |||
else: | |||
self.con.serverconfig = self.con.load_config() | |||
self.con.serverconfig[ctx.message.server.id]["greets"]["welcome-channel"] = channel.id | |||
self.con.updateconfig() | |||
return await self.bot.say("{} has been set as the welcome channel!".format(channel.mention)) | |||
@bot.command(pass_context=True, hidden=True) | |||
async def set_goodbyechannel(self, ctx, channel: discord.Channel = None): | |||
if not owner(ctx): | |||
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) | |||
self.con.serverconfig[ctx.message.server.id]["goodbyes"]["goodbye-channel"] = channel.id | |||
self.con.updateconfig() | |||
else: | |||
self.con.serverconfig = self.con.load_config() | |||
self.con.serverconfig[ctx.message.server.id]["goodbyes"]["goodbye-channel"] = channel.id | |||
self.con.updateconfig() | |||
return await self.bot.say("{} has been set as the goodbye channel!".format(channel.mention)) | |||
@bot.command(pass_context=True, hidden=True) | |||
async def set_twitchchannel(self, ctx, channel: discord.Channel = None): | |||
if not owner(ctx): | |||
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) | |||
self.con.serverconfig[ctx.message.server.id]["twitch_shilling"]["twitch-channel"] = channel.id | |||
self.con.updateconfig() | |||
else: | |||
self.con.serverconfig = self.con.load_config() | |||
self.con.serverconfig[ctx.message.server.id]["twitch_shilling"]["twitch-channel"] = channel.id | |||
self.con.updateconfig() | |||
return await self.bot.say("{} has been set as the twitch shilling channel!".format(channel.mention)) | |||
@bot.command(pass_context=True, visible=False) | |||
async def set_customwelcomemessage(self, ctx, *message): | |||
self.con.serverconfig[ctx.message.server.id]["greets"]["custom_message"] = ' '.join(message) | |||
self.con.updateconfig() | |||
if not owner(ctx): | |||
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) | |||
else: | |||
self.con.serverconfig = self.con.load_config() | |||
self.con.serverconfig[ctx.message.server.id]["greets"]["custom_message"] = ' '.join(message) | |||
self.con.updateconfig() | |||
return await self.bot.say("Custom message set to '{}'".format(' '.join(message)), delete_after=10) | |||
@bot.command(pass_context=True, hidden=True) |
@@ -32,6 +32,7 @@ class Twitch(): | |||
if not owner(ctx): | |||
return await self.bot.reply("You do not have permission to do this command.", delete_after=20) | |||
else: | |||
self.con.serverconfig = self.con.load_config() | |||
if not self.con.serverconfig[ctx.server.id]["twitch_shilling"]["whitelist"]["enabled"]: | |||
self.con.serverconfig[ctx.server.id]["twitch_shilling"]["whitelist"]["enabled"] = 1 | |||
self.con.updateconfig() | |||
@@ -55,6 +56,7 @@ class Twitch(): | |||
return await self.bot.say('Invalid option "%s" specified, use +, -, add, or remove' % option, expire_in=20) | |||
if option in ['+', 'add']: | |||
self.con.serverconfig = self.con.load_config() | |||
for user in ctx.message.mentions: | |||
self.con.serverconfig[ctx.message.server.id]["twitch_shilling"]["whitelist"]["list"].append(user.id) | |||
self.con.updateconfig() | |||
@@ -62,6 +64,7 @@ class Twitch(): | |||
return await self.bot.say('{} user(s) have been added to the whitelist'.format(whitelist_count)) | |||
elif option in ['-', 'remove']: | |||
self.con.serverconfig = self.con.load_config() | |||
for user in ctx.message.mentions: | |||
if user.id in self.con.serverconfig[ctx.message.server.id]["twitch_shilling"]["whitelist"]["list"]: | |||
self.con.serverconfig[ctx.message.server.id]["twitch_shilling"]["whitelist"]["list"].remove(user.id) |
@@ -1,6 +1,9 @@ | |||
import json | |||
cogs = [ | |||
'cogs.Admin', | |||
'cogs.Twitch', | |||
'cogs.selfAssign', | |||
'cogs.Fun' | |||
] | |||
with open('config/config.json', 'r') as config_file: | |||
serverconfig = json.load(config_file) |
@@ -14,7 +14,6 @@ class selfAssign(): | |||
self.bot = Bot | |||
self.con = Config(Bot) | |||
@bot.command(pass_context=True) | |||
async def listroles(self, ctx): | |||
""" | |||
@@ -38,6 +37,7 @@ class selfAssign(): | |||
Example: | |||
.iam OverwatchPing | |||
""" | |||
self.con.serverconfig = self.con.load_config() | |||
if not self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["enabled"]: | |||
return | |||
@@ -67,6 +67,7 @@ class selfAssign(): | |||
Example: | |||
.iamn OverwatchPing | |||
""" | |||
self.con.serverconfig = self.con.load_config() | |||
if not self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["enabled"]: | |||
return | |||
@@ -90,6 +91,9 @@ class selfAssign(): | |||
if not owner(ctx): | |||
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) | |||
else: | |||
if role.id in self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"]: | |||
return await self.bot.say("{} is already a self-assignable role.".format(role.name), delete_after=self.con.delete_after) | |||
self.con.serverconfig = self.con.load_config() | |||
self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"].append(role.id) | |||
self.con.updateconfig() | |||
return await self.bot.say('Role "{}" added'.format(str(role))) | |||
@@ -98,13 +102,14 @@ class selfAssign(): | |||
async def removerole(self, ctx, role: discord.Role = None): | |||
if not owner(ctx): | |||
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) | |||
if role.id in self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"]: | |||
self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"].remove(role.id) | |||
self.con.updateconfig() | |||
return await self.bot.say('"{}" has been removed from the self-assignable roles.'.format(str(role))) | |||
else: | |||
return await self.bot.say("That role was not in the list.") | |||
self.con.serverconfig = self.con.load_config() | |||
if role.id in self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"]: | |||
self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"].remove(role.id) | |||
self.con.updateconfig() | |||
return await self.bot.say('"{}" has been removed from the self-assignable roles.'.format(str(role))) | |||
else: | |||
return await self.bot.say("That role was not in the list.") | |||
def setup(Bot): | |||
Bot.add_cog(selfAssign(Bot)) |
@@ -1 +1 @@ | |||
{"175285455204384768": {"greets": {"enabled": 0, "welcome-channel": "", "member-role": "", "custom-message": "", "default-message:": "Be sure to read the rules."}, "goodbyes": {"enabled": 0, "goodbye-channel": ""}, "self-assign_roles": {"enabled": 0, "roles": []}, "twitch_shilling": {"enabled": 0, "twitch-channel": "", "whitelist": {"enabled": 0, "list": []}}}, "304048071963312130": {"greets": {"enabled": 1, "welcome-channel": "", "member-role": "", "custom-message": "", "default-message:": "Be sure to read the rules."}, "goodbyes": {"enabled": 1, "goodbye-channel": ""}, "self-assign_roles": {"enabled": 0, "roles": ["307330606348632064", "308083509866659850"]}, "twitch_shilling": {"enabled": 0, "twitch-channel": "", "whitelist": {"enabled": 0, "list": []}}}} | |||
{"175285455204384768": {"greets": {"enabled": 0, "welcome-channel": "", "member-role": "", "custom-message": "", "default-message:": "Be sure to read the rules."}, "goodbyes": {"enabled": 0, "goodbye-channel": ""}, "self-assign_roles": {"enabled": 0, "roles": []}, "twitch_shilling": {"enabled": 0, "twitch-channel": "", "whitelist": {"enabled": 0, "list": []}}}, "304048071963312130": {"greets": {"enabled": 1, "welcome-channel": "", "member-role": "", "custom-message": "", "default-message:": "Be sure to read the rules."}, "goodbyes": {"enabled": 1, "goodbye-channel": ""}, "self-assign_roles": {"enabled": 1, "roles": ["307330606348632064", "308083509866659850", "308083509866659850", "308082456743903233"]}, "twitch_shilling": {"enabled": 0, "twitch-channel": "", "whitelist": {"enabled": 0, "list": []}}}} |
@@ -31,6 +31,7 @@ class Config(): | |||
} | |||
} | |||
} | |||
# Serverconfig is seperate here and shouldnt cause a bug like the cogs o. | |||
self.serverconfig = self.load_config() | |||
self.bot = bot | |||
self.no_perms_reponse = ":no_entry_sign: You do not have permission to use this command." |
@@ -8,7 +8,7 @@ | |||
# TODO: Fix Config Bug | |||
# Mid Priority # | |||
# TODO: Move away from using ID's for everthing. Maybe replace list with dict | |||
# TODO: Move away from using ID's for everything. Maybe replace list with dict | |||
# TODO: Admin tools - For commands already in and things like purge a chat | |||
# TODO: On member role assign, welcome member using on_member_update | |||