More 3.4 compatibility, mentions and listeners
This commit is contained in:
parent
3d4a6578fd
commit
151eca1c76
@ -229,7 +229,7 @@ class CCRole(commands.Cog):
|
||||
cmd_list = "Custom commands:\n\n" + cmd_list
|
||||
|
||||
if (
|
||||
len(cmd_list) < 1500
|
||||
len(cmd_list) < 1500
|
||||
): # I'm allowed to have arbitrary numbers for when it's too much to dm dammit
|
||||
await ctx.send(box(cmd_list))
|
||||
else:
|
||||
@ -254,6 +254,9 @@ class CCRole(commands.Cog):
|
||||
if len(message.content) < 2 or is_private or not user_allowed or message.author.bot:
|
||||
return
|
||||
|
||||
if await self.bot.cog_disabled_in_guild(self, message.guild):
|
||||
return
|
||||
|
||||
ctx = await self.bot.get_context(message)
|
||||
|
||||
if ctx.prefix is None:
|
||||
@ -273,28 +276,6 @@ class CCRole(commands.Cog):
|
||||
if cmd is not None:
|
||||
await self.eval_cc(cmd, message, ctx)
|
||||
|
||||
# @commands.Cog.listener()
|
||||
# async def on_message(self, message: discord.Message):
|
||||
# if len(message.content) < 2 or message.guild is None:
|
||||
# return
|
||||
#
|
||||
# ctx: commands.Context = await self.bot.get_context(message)
|
||||
# cmd = ctx.invoked_with
|
||||
# guild = message.guild
|
||||
# # try:
|
||||
# # prefix = await self.get_prefix(message)
|
||||
# # except ValueError:
|
||||
# # return
|
||||
#
|
||||
# # prefix = ctx.prefix
|
||||
#
|
||||
# cmdlist = self.config.guild(guild).cmdlist
|
||||
# # cmd = message.content[len(prefix) :].split()[0].lower()
|
||||
# cmd = await cmdlist.get_raw(cmd, default=None)
|
||||
#
|
||||
# if cmd is not None:
|
||||
# await self.eval_cc(cmd, message, ctx)
|
||||
|
||||
async def _get_roles_from_content(self, ctx, content):
|
||||
content_list = content.split(",")
|
||||
try:
|
||||
@ -325,10 +306,10 @@ class CCRole(commands.Cog):
|
||||
return p
|
||||
raise ValueError
|
||||
|
||||
async def eval_cc(self, cmd, message, ctx):
|
||||
async def eval_cc(self, cmd, message: discord.Message, ctx: commands.Context):
|
||||
"""Does all the work"""
|
||||
if cmd["proles"] and not (
|
||||
set(role.id for role in message.author.roles) & set(cmd["proles"])
|
||||
set(role.id for role in message.author.roles) & set(cmd["proles"])
|
||||
):
|
||||
return # Not authorized, do nothing
|
||||
|
||||
@ -400,7 +381,7 @@ class CCRole(commands.Cog):
|
||||
await message.channel.send("Permission error: Unable to remove roles")
|
||||
|
||||
out_message = self.format_cc(cmd, message, target)
|
||||
await message.channel.send(out_message)
|
||||
await message.channel.send(out_message, allowed_mentions=discord.AllowedMentions())
|
||||
|
||||
def format_cc(self, cmd, message, target):
|
||||
out = cmd["text"]
|
||||
|
@ -427,6 +427,9 @@ class Chatter(Cog):
|
||||
if len(message.content) < 2 or is_private or not user_allowed or message.author.bot:
|
||||
return
|
||||
|
||||
if await self.bot.cog_disabled_in_guild(self, message.guild):
|
||||
return
|
||||
|
||||
ctx: commands.Context = await self.bot.get_context(message)
|
||||
|
||||
if ctx.prefix is not None:
|
||||
|
@ -89,6 +89,9 @@ class Dad(Cog):
|
||||
if guild is None:
|
||||
return
|
||||
|
||||
if await self.bot.cog_disabled_in_guild(self, guild):
|
||||
return
|
||||
|
||||
guild_config = self.config.guild(guild)
|
||||
is_on = await guild_config.enabled()
|
||||
if not is_on:
|
||||
@ -113,7 +116,8 @@ class Dad(Cog):
|
||||
else:
|
||||
out = cleaned_content[4:]
|
||||
try:
|
||||
await message.channel.send(f"Hi {out}, I'm {guild.me.display_name}!")
|
||||
await message.channel.send(f"Hi {out}, I'm {guild.me.display_name}!",
|
||||
allowed_mentions=discord.AllowedMentions)
|
||||
except discord.HTTPException:
|
||||
return
|
||||
|
||||
|
@ -97,6 +97,9 @@ class ExclusiveRole(Cog):
|
||||
if before.roles == after.roles:
|
||||
return
|
||||
|
||||
if await self.bot.cog_disabled_in_guild(self, after.guild):
|
||||
return
|
||||
|
||||
await asyncio.sleep(1)
|
||||
|
||||
role_set = set(await self.config.guild(after.guild).role_list())
|
||||
|
@ -1,5 +1,6 @@
|
||||
import asyncio
|
||||
|
||||
import discord
|
||||
from discord.utils import get
|
||||
from redbot.core import Config, checks, commands
|
||||
from redbot.core.bot import Red
|
||||
@ -38,8 +39,18 @@ class ForceMention(Cog):
|
||||
|
||||
if not role_obj.mentionable:
|
||||
await role_obj.edit(mentionable=True)
|
||||
await ctx.send("{}\n{}".format(role_obj.mention, message))
|
||||
await ctx.send(
|
||||
"{}\n{}".format(role_obj.mention, message),
|
||||
allowed_mentions=discord.AllowedMentions(
|
||||
everyone=False, users=False, roles=[role_obj]
|
||||
),
|
||||
)
|
||||
await asyncio.sleep(5)
|
||||
await role_obj.edit(mentionable=False)
|
||||
else:
|
||||
await ctx.send("{}\n{}".format(role_obj.mention, message))
|
||||
await ctx.send(
|
||||
"{}\n{}".format(role_obj.mention, message),
|
||||
allowed_mentions=discord.AllowedMentions(
|
||||
everyone=False, users=False, roles=[role_obj]
|
||||
),
|
||||
)
|
||||
|
@ -2,7 +2,7 @@
|
||||
"author": [
|
||||
"Bobloy"
|
||||
],
|
||||
"min_bot_version": "3.3.0",
|
||||
"min_bot_version": "3.4.0",
|
||||
"description": "Mentions roles that are unmentionable",
|
||||
"hidden": false,
|
||||
"install_msg": "Thank you for installing ForceMention! Get started with `[p]load forcemention`, then `[p]forcemention`",
|
||||
|
@ -1,5 +1,6 @@
|
||||
from collections import defaultdict
|
||||
from random import randint
|
||||
from typing import Union
|
||||
|
||||
import discord
|
||||
from redbot.core import Config, checks, commands
|
||||
@ -280,15 +281,22 @@ class Hangman(Cog):
|
||||
await self._reprintgame(message)
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_react(self, reaction, user):
|
||||
async def on_react(self, reaction, user: Union[discord.User, discord.Member]):
|
||||
""" Thanks to flapjack reactpoll for guidelines
|
||||
https://github.com/flapjax/FlapJack-Cogs/blob/master/reactpoll/reactpoll.py"""
|
||||
|
||||
if reaction.message.id != self.the_data[user.guild]["trackmessage"]:
|
||||
guild: discord.Guild = getattr(user, "guild", None)
|
||||
if guild is None:
|
||||
return
|
||||
|
||||
if reaction.message.id != self.the_data[guild]["trackmessage"]:
|
||||
return
|
||||
|
||||
if user.bot:
|
||||
return # Don't react to bot reactions
|
||||
|
||||
if await self.bot.cog_disabled_in_guild(self, guild):
|
||||
return
|
||||
|
||||
if user == self.bot.user:
|
||||
return # Don't react to bot's own reactions
|
||||
message = reaction.message
|
||||
emoji = reaction.emoji
|
||||
|
||||
|
@ -273,14 +273,20 @@ class InfoChannel(Cog):
|
||||
|
||||
@Cog.listener()
|
||||
async def on_member_join(self, member: discord.Member):
|
||||
if await self.bot.cog_disabled_in_guild(self, member.guild):
|
||||
return
|
||||
await self.update_infochannel_with_cooldown(member.guild)
|
||||
|
||||
@Cog.listener()
|
||||
async def on_member_remove(self, member: discord.Member):
|
||||
if await self.bot.cog_disabled_in_guild(self, member.guild):
|
||||
return
|
||||
await self.update_infochannel_with_cooldown(member.guild)
|
||||
|
||||
@Cog.listener()
|
||||
async def on_member_update(self, before: discord.Member, after: discord.Member):
|
||||
if await self.bot.cog_disabled_in_guild(self, after.guild):
|
||||
return
|
||||
onlinecount = await self.config.guild(after.guild).online_count()
|
||||
if onlinecount:
|
||||
if before.status != after.status:
|
||||
|
@ -38,6 +38,10 @@ class Leaver(Cog):
|
||||
@commands.Cog.listener()
|
||||
async def on_member_remove(self, member: discord.Member):
|
||||
guild = member.guild
|
||||
|
||||
if await self.bot.cog_disabled_in_guild(self, guild):
|
||||
return
|
||||
|
||||
channel = await self.config.guild(guild).channel()
|
||||
|
||||
if channel != "":
|
||||
|
@ -89,6 +89,8 @@ class LastSeen(Cog):
|
||||
@commands.Cog.listener()
|
||||
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():
|
||||
if await self.bot.cog_disabled_in_guild(self, after.guild):
|
||||
return
|
||||
if not await self.config.guild(after.guild).enabled():
|
||||
return
|
||||
await self.config.member(before).seen.set(datetime.utcnow().isoformat())
|
||||
|
@ -96,6 +96,9 @@ class Nudity(commands.Cog):
|
||||
# print("did not qualify")
|
||||
return
|
||||
|
||||
if await self.bot.cog_disabled_in_guild(self, message.guild):
|
||||
return
|
||||
|
||||
try:
|
||||
is_on = await self.config.guild(message.guild).enabled()
|
||||
except AttributeError:
|
||||
|
@ -281,6 +281,9 @@ class ReactRestrict(Cog):
|
||||
if member.bot:
|
||||
return
|
||||
|
||||
if await self.bot.cog_disabled_in_guild(self, member.guild):
|
||||
return
|
||||
|
||||
try:
|
||||
roles = [self._get_role(member.guild, c.role_id) for c in combos]
|
||||
except LookupError:
|
||||
|
@ -181,6 +181,10 @@ class StealEmoji(Cog):
|
||||
# print("Collecting is off")
|
||||
return
|
||||
|
||||
guild: discord.Guild = getattr(user, "guild", None)
|
||||
if await self.bot.cog_disabled_in_guild(self, guild): # Handles None guild just fine
|
||||
return
|
||||
|
||||
emoji: discord.Emoji = reaction.emoji
|
||||
if emoji in self.bot.emojis:
|
||||
# print("Emoji already in bot.emojis")
|
||||
|
@ -3,12 +3,13 @@
|
||||
"Bobloy"
|
||||
],
|
||||
"min_bot_version": "3.3.0",
|
||||
"max_bot_version": "3.3.12",
|
||||
"description": "Customizable Werewolf Game",
|
||||
"hidden": true,
|
||||
"install_msg": "Thank you for installing Werewolf! Get started with `[p]load werewolf`\n Use `[p]wwset` to run inital setup",
|
||||
"requirements": [],
|
||||
"short": "Werewolf Game",
|
||||
"end_user_data_statement": "This store user IDs in memory while they're actively using the cog, and store no persistent End User Data.",
|
||||
"end_user_data_statement": "This store user IDs in memory while they're actively using the cog, and stores no persistent End User Data.",
|
||||
"tags": [
|
||||
"mafia",
|
||||
"werewolf",
|
||||
|
Loading…
x
Reference in New Issue
Block a user