Переглянути джерело

v0.3.1 Release: Fixed config.json write issues.

tags/v0.3.1
roxie 7 роки тому
джерело
коміт
ebb1ecb406
7 змінених файлів з 40 додано та 17 видалено
  1. +19
    -8
      cogs/Admin.py
  2. +3
    -0
      cogs/Twitch.py
  3. +3
    -0
      cogs/__init__.py
  4. +12
    -7
      cogs/selfAssign.py
  5. +1
    -1
      config/config.json
  6. +1
    -0
      config/config.py
  7. +1
    -1
      main.py

+ 19
- 8
cogs/Admin.py Переглянути файл

return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after)
else: else:
if setting in self.con.serverconfig[ctx.message.server.id]: 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"]: if not self.con.serverconfig[ctx.message.server.id][setting]["enabled"]:
self.con.serverconfig[ctx.message.server.id][setting]["enabled"] = 1 self.con.serverconfig[ctx.message.server.id][setting]["enabled"] = 1
self.con.updateconfig() self.con.updateconfig()
async def set_welcomechannel(self, ctx, channel: discord.Channel = None): async def set_welcomechannel(self, ctx, channel: discord.Channel = None):
if not owner(ctx): if not owner(ctx):
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) 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)) return await self.bot.say("{} has been set as the welcome channel!".format(channel.mention))


@bot.command(pass_context=True, hidden=True) @bot.command(pass_context=True, hidden=True)
async def set_goodbyechannel(self, ctx, channel: discord.Channel = None): async def set_goodbyechannel(self, ctx, channel: discord.Channel = None):
if not owner(ctx): if not owner(ctx):
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) 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)) return await self.bot.say("{} has been set as the goodbye channel!".format(channel.mention))


@bot.command(pass_context=True, hidden=True) @bot.command(pass_context=True, hidden=True)
async def set_twitchchannel(self, ctx, channel: discord.Channel = None): async def set_twitchchannel(self, ctx, channel: discord.Channel = None):
if not owner(ctx): if not owner(ctx):
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) 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)) return await self.bot.say("{} has been set as the twitch shilling channel!".format(channel.mention))


@bot.command(pass_context=True, visible=False) @bot.command(pass_context=True, visible=False)
async def set_customwelcomemessage(self, ctx, *message): 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) return await self.bot.say("Custom message set to '{}'".format(' '.join(message)), delete_after=10)


@bot.command(pass_context=True, hidden=True) @bot.command(pass_context=True, hidden=True)

+ 3
- 0
cogs/Twitch.py Переглянути файл

if not owner(ctx): if not owner(ctx):
return await self.bot.reply("You do not have permission to do this command.", delete_after=20) return await self.bot.reply("You do not have permission to do this command.", delete_after=20)
else: else:
self.con.serverconfig = self.con.load_config()
if not self.con.serverconfig[ctx.server.id]["twitch_shilling"]["whitelist"]["enabled"]: 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.serverconfig[ctx.server.id]["twitch_shilling"]["whitelist"]["enabled"] = 1
self.con.updateconfig() self.con.updateconfig()
return await self.bot.say('Invalid option "%s" specified, use +, -, add, or remove' % option, expire_in=20) return await self.bot.say('Invalid option "%s" specified, use +, -, add, or remove' % option, expire_in=20)


if option in ['+', 'add']: if option in ['+', 'add']:
self.con.serverconfig = self.con.load_config()
for user in ctx.message.mentions: for user in ctx.message.mentions:
self.con.serverconfig[ctx.message.server.id]["twitch_shilling"]["whitelist"]["list"].append(user.id) self.con.serverconfig[ctx.message.server.id]["twitch_shilling"]["whitelist"]["list"].append(user.id)
self.con.updateconfig() self.con.updateconfig()
return await self.bot.say('{} user(s) have been added to the whitelist'.format(whitelist_count)) return await self.bot.say('{} user(s) have been added to the whitelist'.format(whitelist_count))


elif option in ['-', 'remove']: elif option in ['-', 'remove']:
self.con.serverconfig = self.con.load_config()
for user in ctx.message.mentions: for user in ctx.message.mentions:
if user.id in self.con.serverconfig[ctx.message.server.id]["twitch_shilling"]["whitelist"]["list"]: 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.serverconfig[ctx.message.server.id]["twitch_shilling"]["whitelist"]["list"].remove(user.id)

+ 3
- 0
cogs/__init__.py Переглянути файл

import json
cogs = [ cogs = [
'cogs.Admin', 'cogs.Admin',
'cogs.Twitch', 'cogs.Twitch',
'cogs.selfAssign', 'cogs.selfAssign',
'cogs.Fun' 'cogs.Fun'
] ]
with open('config/config.json', 'r') as config_file:
serverconfig = json.load(config_file)

+ 12
- 7
cogs/selfAssign.py Переглянути файл

self.bot = Bot self.bot = Bot
self.con = Config(Bot) self.con = Config(Bot)



@bot.command(pass_context=True) @bot.command(pass_context=True)
async def listroles(self, ctx): async def listroles(self, ctx):
""" """
Example: Example:
.iam OverwatchPing .iam OverwatchPing
""" """
self.con.serverconfig = self.con.load_config()
if not self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["enabled"]: if not self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["enabled"]:
return return


Example: Example:
.iamn OverwatchPing .iamn OverwatchPing
""" """
self.con.serverconfig = self.con.load_config()
if not self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["enabled"]: if not self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["enabled"]:
return return


if not owner(ctx): if not owner(ctx):
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after)
else: 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.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"].append(role.id)
self.con.updateconfig() self.con.updateconfig()
return await self.bot.say('Role "{}" added'.format(str(role))) return await self.bot.say('Role "{}" added'.format(str(role)))
async def removerole(self, ctx, role: discord.Role = None): async def removerole(self, ctx, role: discord.Role = None):
if not owner(ctx): if not owner(ctx):
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) 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: 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): def setup(Bot):
Bot.add_cog(selfAssign(Bot)) Bot.add_cog(selfAssign(Bot))

+ 1
- 1
config/config.json Переглянути файл

{"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": []}}}}

+ 1
- 0
config/config.py Переглянути файл

} }
} }
} }
# Serverconfig is seperate here and shouldnt cause a bug like the cogs o.
self.serverconfig = self.load_config() self.serverconfig = self.load_config()
self.bot = bot self.bot = bot
self.no_perms_reponse = ":no_entry_sign: You do not have permission to use this command." self.no_perms_reponse = ":no_entry_sign: You do not have permission to use this command."

+ 1
- 1
main.py Переглянути файл

# TODO: Fix Config Bug # TODO: Fix Config Bug


# Mid Priority # # 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: Admin tools - For commands already in and things like purge a chat
# TODO: On member role assign, welcome member using on_member_update # TODO: On member role assign, welcome member using on_member_update



Завантаження…
Відмінити
Зберегти