Added the ability to change user notifications
This commit is contained in:
parent
95b28f87c1
commit
8e30e32f8b
2 changed files with 18 additions and 3 deletions
8
bot.py
8
bot.py
|
@ -49,7 +49,9 @@ async def on_member_join(member):
|
||||||
server_notifications = notifications.get(member.server.id)
|
server_notifications = notifications.get(member.server.id)
|
||||||
if not server_notifications:
|
if not server_notifications:
|
||||||
return
|
return
|
||||||
await bot.send_message(member.server, "Welcome to the '{0.server.name}' server {0.mention}!".format(member))
|
|
||||||
|
channel = discord.utils.get(member.server.channels,id=server_notifications)
|
||||||
|
await bot.send_message(channel, "Welcome to the '{0.server.name}' server {0.mention}!".format(member))
|
||||||
|
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
|
@ -58,7 +60,9 @@ async def on_member_remove(member):
|
||||||
server_notifications = notifications.get(member.server.id)
|
server_notifications = notifications.get(member.server.id)
|
||||||
if not server_notifications:
|
if not server_notifications:
|
||||||
return
|
return
|
||||||
await bot.send_message(member.server,
|
|
||||||
|
channel = discord.utils.get(member.server.channels,id=server_notifications)
|
||||||
|
await bot.send_message(channel,
|
||||||
"{0} has left the server, I hope it wasn't because of something I said :c".format(member))
|
"{0} has left the server, I hope it wasn't because of something I said :c".format(member))
|
||||||
|
|
||||||
|
|
||||||
|
|
11
cogs/mod.py
11
cogs/mod.py
|
@ -12,6 +12,17 @@ class Mod:
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
@commands.command(pass_context=True, no_pm=True)
|
||||||
|
async def usernotify(self, ctx, on_off:str):
|
||||||
|
"""This command can be used to set whether or not you want user notificaitons to show
|
||||||
|
This will save what channel you run this command in, that will be the channel used to send the notification to
|
||||||
|
Provide on, yes, or true to set it on; otherwise it will be turned off"""
|
||||||
|
on_off = ctx.message.channel.id if re.search("(on|yes|true)",on_off.lower()) else None
|
||||||
|
notifications = config.getContent('user_notifications') or {}
|
||||||
|
notifications[ctx.message.server.id] = on_off
|
||||||
|
config.saveContent('user_notifications',notifications)
|
||||||
|
fmt = "notify, in this channel" if on_off else "not notify"
|
||||||
|
await self.bot.say("This server will now {} if someone has joined or left".format(fmt))
|
||||||
|
|
||||||
@commands.group(pass_context=True, no_pm=True)
|
@commands.group(pass_context=True, no_pm=True)
|
||||||
async def nsfw(self, ctx):
|
async def nsfw(self, ctx):
|
||||||
|
|
Loading…
Reference in a new issue