Reapply case-insensitivity and get off that command_error train (#101)
* Reapply case-insensitivity and get off that command_error train * Can't forget their check, thanks again Cog-Creators This will continue with CCRole being a case-insensitive cog, until the day I change my mind by making this a subclass of CustomCom
This commit is contained in:
parent
9af8601124
commit
ebe59c9370
@ -1,14 +1,11 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import json
|
|
||||||
import re
|
import re
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext.commands.view import StringView
|
from discord.ext.commands.view import StringView
|
||||||
from redbot.core import Config, checks
|
from redbot.core import Config, checks, commands
|
||||||
from redbot.core import commands
|
|
||||||
from redbot.core.bot import Red
|
from redbot.core.bot import Red
|
||||||
from redbot.core.utils.chat_formatting import pagify, box
|
from redbot.core.utils.chat_formatting import box, pagify
|
||||||
|
|
||||||
|
|
||||||
class CCRole(commands.Cog):
|
class CCRole(commands.Cog):
|
||||||
@ -236,10 +233,30 @@ class CCRole(commands.Cog):
|
|||||||
await ctx.send("Command list DM'd")
|
await ctx.send("Command list DM'd")
|
||||||
|
|
||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
async def on_command_error(self, ctx: commands.Context, exception):
|
async def on_message_without_command(self, message: discord.Message):
|
||||||
|
|
||||||
|
"""Filtering credit to redbot.cogs.customcom's listener"""
|
||||||
|
###########
|
||||||
|
is_private = isinstance(message.channel, discord.abc.PrivateChannel)
|
||||||
|
|
||||||
|
# user_allowed check, will be replaced with self.bot.user_allowed or
|
||||||
|
# something similar once it's added
|
||||||
|
user_allowed = True
|
||||||
|
|
||||||
|
if len(message.content) < 2 or is_private or not user_allowed or message.author.bot:
|
||||||
|
return
|
||||||
|
|
||||||
|
ctx = await self.bot.get_context(message)
|
||||||
|
|
||||||
|
if ctx.prefix is None:
|
||||||
|
return
|
||||||
|
###########
|
||||||
|
# Thank you Cog-Creators
|
||||||
|
|
||||||
cmd = ctx.invoked_with
|
cmd = ctx.invoked_with
|
||||||
|
cmd = cmd.lower() # Continues the proud case_insentivity tradition of ccrole
|
||||||
guild = ctx.guild
|
guild = ctx.guild
|
||||||
message = ctx.message
|
# message = ctx.message # Unneeded since switch to `on_message_without_command` from `on_command_error`
|
||||||
|
|
||||||
cmdlist = self.config.guild(guild).cmdlist
|
cmdlist = self.config.guild(guild).cmdlist
|
||||||
# cmd = message.content[len(prefix) :].split()[0].lower()
|
# cmd = message.content[len(prefix) :].split()[0].lower()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user