reformat/refactor
This commit is contained in:
56
cogs/misc.py
56
cogs/misc.py
@ -6,7 +6,6 @@ import random
|
||||
from typing import Optional
|
||||
import logging
|
||||
import discord
|
||||
import aiosqlite as sqlite3
|
||||
from sh import cowsay as cow_say, fortune
|
||||
from discord.ext import bridge, commands
|
||||
from disc_havoc import Havoc
|
||||
@ -67,10 +66,11 @@ class Misc(commands.Cog):
|
||||
|
||||
def predicate(ctx):
|
||||
try:
|
||||
if not ctx.channel.id in BOT_CHANIDS:
|
||||
if ctx.channel.id not in BOT_CHANIDS:
|
||||
logging.debug("%s not found in %s", ctx.channel.id, BOT_CHANIDS)
|
||||
return ctx.channel.id in BOT_CHANIDS
|
||||
except:
|
||||
except Exception as e:
|
||||
logging.debug("Exception: %s", str(e))
|
||||
traceback.print_exc()
|
||||
return False
|
||||
|
||||
@ -82,7 +82,7 @@ class Misc(commands.Cog):
|
||||
def predicate(ctx):
|
||||
try:
|
||||
if (
|
||||
not ctx.channel.id in BOT_CHANIDS
|
||||
ctx.channel.id not in BOT_CHANIDS
|
||||
and not ctx.channel.id == DRUGS_CHANID
|
||||
):
|
||||
logging.debug(
|
||||
@ -92,7 +92,8 @@ class Misc(commands.Cog):
|
||||
DRUGS_CHANID,
|
||||
)
|
||||
return ctx.channel.id in BOT_CHANIDS or ctx.channel.id == DRUGS_CHANID
|
||||
except:
|
||||
except Exception as e:
|
||||
logging.debug("Exception: %s", str(e))
|
||||
traceback.print_exc()
|
||||
return False
|
||||
|
||||
@ -246,7 +247,7 @@ class Misc(commands.Cog):
|
||||
return
|
||||
authorDisplay: str = (
|
||||
ctx.author.display_name
|
||||
if not (ctx.author.display_name is None)
|
||||
if (ctx.author.display_name is not None)
|
||||
else ctx.message.author.display_name
|
||||
)
|
||||
|
||||
@ -285,7 +286,7 @@ class Misc(commands.Cog):
|
||||
try:
|
||||
authorDisplay: str = (
|
||||
ctx.author.display_name
|
||||
if not (ctx.author.display_name is None)
|
||||
if (ctx.author.display_name is not None)
|
||||
else ctx.message.author.display_name
|
||||
)
|
||||
|
||||
@ -416,7 +417,7 @@ class Misc(commands.Cog):
|
||||
"""
|
||||
authorDisplay: str = (
|
||||
ctx.author.display_name
|
||||
if not (ctx.author.display_name is None)
|
||||
if (ctx.author.display_name is not None)
|
||||
else ctx.message.author.display_name
|
||||
)
|
||||
|
||||
@ -456,7 +457,7 @@ class Misc(commands.Cog):
|
||||
"""
|
||||
authorDisplay: str = (
|
||||
ctx.author.display_name
|
||||
if not (ctx.author.display_name is None)
|
||||
if (ctx.author.display_name is not None)
|
||||
else ctx.message.author.display_name
|
||||
)
|
||||
|
||||
@ -498,7 +499,7 @@ class Misc(commands.Cog):
|
||||
|
||||
authorDisplay: str = (
|
||||
ctx.author.display_name
|
||||
if not (ctx.author.display_name is None)
|
||||
if (ctx.author.display_name is not None)
|
||||
else ctx.message.author.display_name
|
||||
)
|
||||
|
||||
@ -571,7 +572,7 @@ class Misc(commands.Cog):
|
||||
if not cowfile:
|
||||
cowfile = random.choice(self.COWS).replace(".cow", "")
|
||||
|
||||
if not f"{cowfile}.cow" in self.COWS:
|
||||
if f"{cowfile}.cow" not in self.COWS:
|
||||
return await ctx.respond(f"Unknown cow {cowfile}, who dat?")
|
||||
|
||||
fortune_said: str = str(fortune("-n1000", "-s"))
|
||||
@ -609,7 +610,7 @@ class Misc(commands.Cog):
|
||||
"""
|
||||
authorDisplay: str = (
|
||||
ctx.author.display_name
|
||||
if not (ctx.author.display_name is None)
|
||||
if (ctx.author.display_name is not None)
|
||||
else ctx.message.author.display_name
|
||||
)
|
||||
|
||||
@ -656,7 +657,7 @@ class Misc(commands.Cog):
|
||||
"""
|
||||
authorDisplay: str = (
|
||||
ctx.author.display_name
|
||||
if not (ctx.author.display_name is None)
|
||||
if (ctx.author.display_name is not None)
|
||||
else ctx.message.author.display_name
|
||||
)
|
||||
|
||||
@ -703,7 +704,7 @@ class Misc(commands.Cog):
|
||||
"""
|
||||
authorDisplay: str = (
|
||||
ctx.author.display_name
|
||||
if not (ctx.author.display_name is None)
|
||||
if (ctx.author.display_name is not None)
|
||||
else ctx.message.author.display_name
|
||||
)
|
||||
|
||||
@ -751,7 +752,7 @@ class Misc(commands.Cog):
|
||||
|
||||
authorDisplay: str = (
|
||||
ctx.author.display_name
|
||||
if not (ctx.author.display_name is None)
|
||||
if (ctx.author.display_name is not None)
|
||||
else ctx.message.author.display_name
|
||||
)
|
||||
|
||||
@ -794,7 +795,7 @@ class Misc(commands.Cog):
|
||||
recipient_id: Optional[int] = None # Used for mentions
|
||||
authorDisplay: str = (
|
||||
ctx.author.display_name
|
||||
if not (ctx.author.display_name is None)
|
||||
if (ctx.author.display_name is not None)
|
||||
else ctx.message.author.display_name
|
||||
)
|
||||
|
||||
@ -847,7 +848,7 @@ class Misc(commands.Cog):
|
||||
"""
|
||||
authorDisplay: str = (
|
||||
ctx.author.display_name
|
||||
if not (ctx.author.display_name is None)
|
||||
if (ctx.author.display_name is not None)
|
||||
else ctx.message.author.display_name
|
||||
)
|
||||
|
||||
@ -893,7 +894,7 @@ class Misc(commands.Cog):
|
||||
"""
|
||||
authorDisplay: str = (
|
||||
ctx.author.display_name
|
||||
if not (ctx.author.display_name is None)
|
||||
if (ctx.author.display_name is not None)
|
||||
else ctx.message.author.display_name
|
||||
)
|
||||
|
||||
@ -933,7 +934,7 @@ class Misc(commands.Cog):
|
||||
"""
|
||||
authorDisplay = (
|
||||
ctx.author.display_name
|
||||
if not (ctx.author.display_name is None)
|
||||
if (ctx.author.display_name is not None)
|
||||
else ctx.message.author.display_name
|
||||
)
|
||||
|
||||
@ -977,7 +978,7 @@ class Misc(commands.Cog):
|
||||
"""
|
||||
authorDisplay: str = (
|
||||
ctx.author.display_name
|
||||
if not (ctx.author.display_name is None)
|
||||
if (ctx.author.display_name is not None)
|
||||
else ctx.message.author.display_name
|
||||
)
|
||||
|
||||
@ -1017,7 +1018,7 @@ class Misc(commands.Cog):
|
||||
"""
|
||||
authorDisplay: str = (
|
||||
ctx.author.display_name
|
||||
if not (ctx.author.display_name is None)
|
||||
if (ctx.author.display_name is not None)
|
||||
else ctx.message.author.display_name
|
||||
)
|
||||
|
||||
@ -1057,7 +1058,7 @@ class Misc(commands.Cog):
|
||||
"""
|
||||
authorDisplay: str = (
|
||||
ctx.author.display_name
|
||||
if not (ctx.author.display_name is None)
|
||||
if (ctx.author.display_name is not None)
|
||||
else ctx.message.author.display_name
|
||||
)
|
||||
|
||||
@ -1103,7 +1104,7 @@ class Misc(commands.Cog):
|
||||
"""
|
||||
authorDisplay: str = (
|
||||
ctx.author.display_name
|
||||
if not (ctx.author.display_name is None)
|
||||
if (ctx.author.display_name is not None)
|
||||
else ctx.message.author.display_name
|
||||
)
|
||||
|
||||
@ -1151,7 +1152,7 @@ class Misc(commands.Cog):
|
||||
"""
|
||||
authorDisplay = (
|
||||
ctx.author.display_name
|
||||
if not (ctx.author.display_name is None)
|
||||
if (ctx.author.display_name is not None)
|
||||
else ctx.message.author.display_name
|
||||
)
|
||||
|
||||
@ -1303,7 +1304,7 @@ class Misc(commands.Cog):
|
||||
"""
|
||||
authorDisplay: str = (
|
||||
ctx.author.display_name
|
||||
if not (ctx.author.display_name is None)
|
||||
if (ctx.author.display_name is not None)
|
||||
else ctx.message.author.display_name
|
||||
)
|
||||
|
||||
@ -1446,7 +1447,10 @@ class Misc(commands.Cog):
|
||||
) # known: cannot react to interaction
|
||||
|
||||
def cog_unload(self) -> None:
|
||||
"""Run on Cog Unload"""
|
||||
"""
|
||||
Run on Cog Unload
|
||||
Not currently used.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user