@@ -80,14 +80,14 @@ class Admin(): | |||
if not owner(ctx): | |||
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) | |||
else: | |||
if module in self.con.serverconfig[ctx.message.server.id]: | |||
if setting in self.con.serverconfig[ctx.message.server.id]: | |||
if not self.con.serverconfig[ctx.message.server.id][setting]["enabled"]: | |||
self.con.serverconfig[ctx.message.server.id][setting]["enabled"] = 1 | |||
self.con.updateconfig(self.con.serverconfig) | |||
self.con.updateconfig() | |||
return await self.bot.say("'{}' was enabled!".format(setting)) | |||
else: | |||
self.con.serverconfig[ctx.message.server.id][setting]["enabled"] = 0 | |||
self.con.updateconfig(self.con.serverconfig) | |||
self.con.updateconfig() | |||
return await self.bot.say("'{}' was disabled :cry:".format(setting)) | |||
else: | |||
return await self.bot.say("That module dont exist fam. You made the thing") | |||
@@ -97,7 +97,7 @@ class Admin(): | |||
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(self.con.serverconfig) | |||
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) | |||
@@ -105,7 +105,7 @@ class Admin(): | |||
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(self.con.serverconfig) | |||
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) | |||
@@ -113,9 +113,15 @@ class Admin(): | |||
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(self.con.serverconfig) | |||
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() | |||
return await self.bot.say("Custom message set to '{}'".format(' '.join(message)), delete_after=10) | |||
@bot.command(pass_context=True, hidden=True) | |||
async def changeavatar(self, ctx, url=None): | |||
""" |
@@ -34,11 +34,11 @@ class Twitch(): | |||
else: | |||
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(self.con.serverconfig) | |||
self.con.updateconfig() | |||
return await self.bot.reply("Whitelist for Twitch shilling has been enabled.") | |||
else: | |||
self.con.serverconfig[ctx.server.id]["twitch_shilling"]["whitelist"]["enabled"] = 0 | |||
self.con.updateconfig(self.con.serverconfig) | |||
self.con.updateconfig() | |||
return await self.bot.reply("Whitelist for Twitch shilling has been disabled.") | |||
@bot.command(pass_context=True, hidden=True) | |||
@@ -57,7 +57,7 @@ class Twitch(): | |||
if option in ['+', 'add']: | |||
for user in ctx.message.mentions: | |||
self.con.serverconfig[ctx.message.server.id]["twitch_shilling"]["whitelist"]["list"].append(user.id) | |||
self.con.updateconfig(self.con.serverconfig) | |||
self.con.updateconfig() | |||
whitelist_count += 1 | |||
return await self.bot.say('{} user(s) have been added to the whitelist'.format(whitelist_count)) | |||
@@ -65,7 +65,7 @@ class Twitch(): | |||
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) | |||
self.con.updateconfig(self.con.serverconfig) | |||
self.con.updateconfig() | |||
whitelist_count += 1 | |||
return await self.bot.say('{} user(s) have been removed to the whitelist'.format(whitelist_count)) | |||
@@ -91,7 +91,7 @@ class selfAssign(): | |||
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) | |||
else: | |||
self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"].append(role.id) | |||
self.con.updateconfig(self.con.serverconfig) | |||
self.con.updateconfig() | |||
return await self.bot.say('Role "{}" added'.format(str(role))) | |||
@bot.command(pass_context=True, hidden=True) | |||
@@ -101,7 +101,7 @@ class selfAssign(): | |||
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(self.con.serverconfig) | |||
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.") |
@@ -1 +1 @@ | |||
{"304048071963312130": {"greets": {"enabled": 0, "welcome-channel": "", "member-role": ""}, "goodbyes": {"enabled": 0, "goodbye-channel": ""}, "self-assign_roles": {"enabled": 0, "roles": []}, "twitch_shilling": {"enabled": 1, "twitch-channel": "304048071963312130", "whitelist": {"enabled": 0, "list": ["259869304369971200"]}}}, "175285455204384768": {"greets": {"enabled": 0, "welcome-channel": "", "member-role": ""}, "goodbyes": {"enabled": 0, "goodbye-channel": ""}, "self-assign_roles": {"enabled": 0, "roles": []}, "twitch_shilling": {"enabled": 1, "twitch-channel": "334812611575283712", "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": 0, "roles": ["307330606348632064", "308083509866659850"]}, "twitch_shilling": {"enabled": 0, "twitch-channel": "", "whitelist": {"enabled": 0, "list": []}}}} |
@@ -1,4 +1,5 @@ | |||
import json | |||
from pprint import pprint | |||
class Config(): | |||
@@ -8,11 +9,13 @@ class Config(): | |||
"greets": { | |||
"enabled": 0, | |||
"welcome-channel": "", | |||
"member-role": "" | |||
"member-role": "", | |||
"custom-message": "", | |||
"default-message:": "Be sure to read the rules." | |||
}, | |||
"goodbyes": { | |||
"enabled": 0, | |||
"goodbye-channel": "" | |||
"goodbye-channel": "", | |||
}, | |||
"self-assign_roles": { | |||
"enabled": 0, | |||
@@ -35,26 +38,28 @@ class Config(): | |||
async def on_server_join(self, server): | |||
self.serverconfig[server.id] = self.serverconfig_template["example"] | |||
self.updateconfig(self.serverconfig) | |||
self.updateconfig() | |||
async def on_server_remove(self, server): | |||
self.serverconfig.pop(server.id) | |||
self.updateconfig(self.serverconfig) | |||
self.updateconfig() | |||
def load_config(self): | |||
with open('config/config.json', 'r') as config_file: | |||
return json.load(config_file) | |||
def updateconfig(self, config): | |||
def updateconfig(self): | |||
with open('config/config.json', 'w') as conf_file: | |||
json.dump(config, conf_file) | |||
json.dump(self.serverconfig, conf_file) | |||
pprint(self.serverconfig) | |||
def config_errorcheck(self): | |||
# Checks for errors in the config files and fixes them automatically | |||
# TODO: Fix so that it checks for problems in children of module settings. i.e children of 'greets' | |||
# TODO: Fix issue where a setting can be enabled when it has no channel to post to. | |||
for server in self.bot.servers: | |||
if server.id not in self.serverconfig: | |||
self.serverconfig[server.id] = self.serverconfig_template["example"] | |||
self.updateconfig(self.serverconfig) | |||
self.updateconfig() | |||
print( | |||
"WARNING: The config file for {} was not found. A template has been loaded and saved. All modules are turned off by default.".format( | |||
server.name.upper())) | |||
@@ -63,10 +68,11 @@ class Config(): | |||
if module_setting not in self.serverconfig[server.id]: | |||
self.serverconfig[server.id][module_setting] = self.serverconfig_template["example"][ | |||
module_setting] | |||
self.updateconfig(self.serverconfig) | |||
self.updateconfig() | |||
print( | |||
"WARNING: The config file for {} was missing the {} module. This has been fixed with the template version. It is disabled by default.".format( | |||
server.name.upper(), module_setting.upper())) | |||
print("") | |||
def setup(bot): |
@@ -1,6 +1,6 @@ | |||
[Credentials] | |||
; Put your token here. | |||
Token = MzA4MDc3ODg3MDYyNTQwMjg5.DEwCbA.Bj933S3guhHY4KnbtZyuwESJ_b4 | |||
Token = MzA4MDc3ODg3MDYyNTQwMjg5.DFBkcw.RxM8VtNHgt5hDyjuFwPT2X61guw | |||
[RoxBot] | |||
OwnerID = 142735312626515979 |
@@ -1,13 +1,11 @@ | |||
#!/usr/env python | |||
############## | |||
# To-do List # | |||
############## | |||
# High Priority # | |||
# TODO: Command Review, look at all commands and flesh them out. Maybe some randomised dialogue so that not every command has only one response. Make sure user experience feels nice. | |||
# TODO: Also self delete timers. | |||
# TODO: Full Docs on the commands and their use | |||
# TODO: iam remove command | |||
# TODO: Welcome and goodbye default messages and changable messages | |||
# TODO: Fix Config Bug | |||
# Mid Priority # | |||
# TODO: Move away from using ID's for everthing. Maybe replace list with dict | |||
@@ -15,12 +13,12 @@ | |||
# TODO: On member role assign, welcome member using on_member_update | |||
# Low Priority # | |||
# TODO: Command Review, look at all commands and flesh them out. Make sure user experience feels nice | |||
# TODO: Better help menu- AutoGen using <command>.help | |||
# TODO: Overwatch stats - Using Overwatch-API lib | |||
# TODO: Add check for no channel id when a module is enabled | |||
# TODO: Maybe some randomised dialogue so that not every command has only one response. | |||
import random | |||
import configparser | |||
import discord | |||
@@ -31,7 +29,6 @@ from cogs import cogs | |||
__version__ = '0.3.0' | |||
settings = configparser.ConfigParser() | |||
settings.read('config/settings.ini') | |||
@@ -85,17 +82,22 @@ async def on_member_join(member): | |||
""" | |||
if not con.serverconfig[member.server.id]["greets"]["enabled"]: | |||
return | |||
print("Passes Enabled Check") | |||
if con.serverconfig[member.server.id]["greets"]["custom-message"]: | |||
message = con.serverconfig[member.server.id]["greets"]["custom-message"] | |||
else: | |||
message = con.serverconfig[member.server.id]["greets"]["default-message"] | |||
print("passed message check") | |||
em = discord.Embed( | |||
title="Welcome to {}!".format(member.server), | |||
description='Hey {}! Welcome to {}! Be sure to read the rules.'.format(member.mention, member.server), | |||
description='Hey {}! Welcome to **{}**! {}'.format(member.mention, member.server, message), | |||
colour=0xDEADBF) | |||
if con.serverconfig[member.server.id]["greets"]["welcome-channel"]: | |||
channel = discord.Object(con.serverconfig[member.server.id]["greets"]["welcome-channel"]) | |||
else: | |||
channel = member.server.default_channel | |||
print("passed channel getting") | |||
return await bot.send_message(channel,embed=em) | |||
@@ -108,6 +110,5 @@ async def on_member_remove(member): | |||
description="{}#{} has left or been beaned.".format(member.name, member.discriminator), colour=0xDEADBF)) | |||
if __name__ == "__main__": | |||
bot.run(token) |