Merge pull request #14 from bobloy/forcemention-update

Forcemention update
pull/15/head
bobloy 7 years ago committed by GitHub
commit 3e4730a497
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -7,7 +7,7 @@ from redbot.core.bot import Red
class ForceMention: class ForceMention:
""" """
V3 Cog Template Mention the unmentionables
""" """
def __init__(self, bot: Red): def __init__(self, bot: Red):
@ -21,18 +21,18 @@ class ForceMention:
@checks.admin_or_permissions(manage_roles=True) @checks.admin_or_permissions(manage_roles=True)
@commands.command() @commands.command()
async def forcemention(self, ctx: commands.Context, role: str): async def forcemention(self, ctx: commands.Context, role: str, *, message=''):
""" """
Mentions that role, regardless if it's unmentionable Mentions that role, regardless if it's unmentionable
""" """
role = get(ctx.guild.roles, name=role) role_obj = get(ctx.guild.roles, name=role)
if role is None: if role_obj is None:
await ctx.maybe_send_embed("Couldn't find role with that name") await ctx.maybe_send_embed("Couldn't find role named {}".format(role))
return return
if not role.mentionable: if not role_obj.mentionable:
await role.edit(mentionable=True) await role_obj.edit(mentionable=True)
await ctx.send(role.mention) await ctx.send("{}\n{}".format(role_obj.mention, message))
await role.edit(mentionable=False) await role_obj.edit(mentionable=False)
else: else:
await ctx.send(role.mention) await ctx.send("{}\n{}".format(role_obj.mention, message))

@ -10,7 +10,7 @@
"description": "Keep track of when users were last seen online", "description": "Keep track of when users were last seen online",
"hidden": true, "hidden": true,
"install_msg": "Thank you for installing LastSeen. Get started with `[p]help LastSeen`", "install_msg": "Thank you for installing LastSeen. Get started with `[p]help LastSeen`",
"requirements": [], "requirements": ["nudepy"],
"short": "Last seen tracker", "short": "Last seen tracker",
"tags": [ "tags": [
"bobloy", "bobloy",

@ -1,7 +1,8 @@
from datetime import datetime from datetime import datetime
import dateutil.parser
import discord import discord
import nude
from nude import Nude
from redbot.core import Config from redbot.core import Config
from redbot.core import commands from redbot.core import commands
from redbot.core.bot import Red from redbot.core.bot import Red
@ -21,65 +22,24 @@ class Nudity:
self.config = Config.get_conf(self, identifier=9811198108111121, force_registration=True) self.config = Config.get_conf(self, identifier=9811198108111121, force_registration=True)
default_guild = { default_guild = {
"enabled": True "enabled": False
} }
self.config.register_guild(**default_guild) self.config.register_guild(**default_guild)
@staticmethod @commands.command(aliases=['togglenudity'], name='nudity')
def get_date_time(s): async def nudity(self, ctx: commands.Context):
d = dateutil.parser.parse(s) """Toggle nude-checking on or off"""
return d is_on = await self.config.guild(ctx.guild).enabled()
await self.config.guild(ctx.guild).enabled.set(not is_on)
await ctx.send("Nude checking is now set to {}".format(not is_on))
@commands.group(aliases=['setlseen'], name='lseenset') async def on_message(self, message: discord.Message):
async def lset(self, ctx: commands.Context): is_on = await self.config.guild(message.guild).enabled()
"""Change settings for lseen""" if not is_on:
if ctx.invoked_subcommand is None:
await ctx.send_help()
@lset.command(name="toggle")
async def lset_toggle(self, ctx: commands.Context):
"""Toggles tracking seen for this server"""
enabled = not await self.config.guild(ctx.guild).enabled()
await self.config.guild(ctx.guild).enabled.set(
enabled)
await ctx.send(
"Seen for this server is now {}".format(
"Enabled" if enabled else "Disabled"))
@commands.command(aliases=['lastseen'])
async def lseen(self, ctx: commands.Context, member: discord.Member):
"""
Just says the time the user was last seen
"""
if member.status != self.offline_status:
last_seen = datetime.utcnow()
else:
last_seen = await self.config.member(member).seen()
if last_seen is None:
await ctx.send(embed=discord.Embed(description="I've never seen this user"))
return return
last_seen = self.get_date_time(last_seen)
# embed = discord.Embed(
# description="{} was last seen at this date and time".format(member.display_name),
# timestamp=self.get_date_time(last_seen))
embed = discord.Embed(timestamp=last_seen) if not message.attachments:
await ctx.send(embed=embed) return
# async def on_socket_raw_receive(self, data):
# try:
# if type(data) == str:
# raw = json.loads(data)
# print(data)
# except:
# print(data)
async def on_member_update(self, before: discord.Member, after: discord.Member):
if before.status != self.offline_status and after.status == self.offline_status:
if not await self.config.guild(before.guild).enabled():
return
await self.config.member(before).seen.set(datetime.utcnow().isoformat())

Loading…
Cancel
Save