Browse Source

Rework no-subject help

wizards
Cassidy Dingenskirchen 5 months ago
parent
commit
facdcef9fd
Signed by: StDingenskirchen GPG Key ID: 14FE9712CC42FE8B
14 changed files with 81 additions and 57 deletions
  1. +2
    -1
      .gitignore
  2. +23
    -18
      blimp/__main__.py
  3. +7
    -9
      blimp/cogs/__init__.py
  4. +0
    -0
      blimp/cogs/aliasing.py
  5. +4
    -2
      blimp/cogs/board.py
  6. +2
    -2
      blimp/cogs/botlog.py
  7. +2
    -2
      blimp/cogs/longslowmode.py
  8. +5
    -2
      blimp/cogs/moderation.py
  9. +5
    -4
      blimp/cogs/reminders.py
  10. +8
    -4
      blimp/cogs/rolekiosk.py
  11. +14
    -6
      blimp/cogs/tickets.py
  12. +1
    -1
      blimp/cogs/tools.py
  13. +6
    -4
      blimp/cogs/triggers.py
  14. +2
    -2
      blimp/cogs/welcomelog.py

+ 2
- 1
.gitignore View File

@ -2,4 +2,5 @@ __pycache__
blimp.cfg
blimp.db
*.egg-info
result
result
.vscode

+ 23
- 18
blimp/__main__.py View File

@ -25,20 +25,22 @@ for source in config["log"]["suppress"].split(","):
)
bot = Blimp(
config, case_insensitive=True, activity=Blimp.random_status(), help_command=None,
config,
case_insensitive=True,
activity=Blimp.random_status(),
help_command=None,
)
for cog in [
cogs.RoleKiosk,
cogs.Aliasing,
cogs.Welcome,
cogs.Board,
cogs.BotLog,
cogs.LongSlowmode,
cogs.Malarkey,
cogs.Tools,
cogs.Logging,
cogs.Slowmode,
cogs.Moderation,
cogs.Tickets,
cogs.Trigger,
cogs.Tools,
cogs.Triggers,
cogs.WelcomeLog,
]:
bot.add_cog(cog(bot))
@ -71,24 +73,27 @@ async def _help(ctx: Blimp.Context, *, subject: Optional[str]):
"with individual commands or any of the larger features "
"listed below.\nThere's also an [online manual]"
f"({ctx.bot.config['info']['manual']}) and, of course, the [source "
f"code]({ctx.bot.config['info']['source']})."
f"code]({ctx.bot.config['info']['source']}).\n\n"
)
embed.add_field(name="Core", value=signature(_help))
for name, cog in ctx.bot.cogs.items(): # pylint: disable=redefined-outer-name
for name, cog in sorted( # pylint: disable=redefined-outer-name
ctx.bot.cogs.items(), key=lambda tup: tup[0]
):
all_commands = []
for command in cog.get_commands():
if isinstance(command, commands.Group):
all_commands.extend([signature(sub) for sub in command.commands])
all_commands.extend(
[f"`{command.name} {sub.name}`" for sub in command.commands]
)
else:
all_commands.append(signature(command))
all_commands.append(f"`{command.name}`")
embed.add_field(
name=name,
value=cog.description.split("\n")[0]
embed.description += (
f"**{name}** "
+ cog.description.split("\n")[0]
+ "\n"
+ "\n".join(sorted(all_commands)),
inline=False,
+ " ".join(all_commands)
+ "\n\n"
)
else:
for name, cog in ctx.bot.cogs.items():
@ -153,7 +158,7 @@ async def on_command_error(ctx, error):
)
def main():
def main(): # pylint: disable=missing-function-docstring
bot.run(config["discord"]["token"])


+ 7
- 9
blimp/cogs/__init__.py View File

@ -1,15 +1,13 @@
from discord.ext import commands
from .alias import Aliasing
from .aliasing import Aliasing
from .board import Board
from .botlog import BotLog
from .longslowmode import LongSlowmode
from .malarkey import Malarkey
from .reminders import Reminders
from .rolekiosk import RoleKiosk
from .welcome import Welcome
from .tools import Tools
from .logging import Logging
from .slowmode import Slowmode
from .moderation import Moderation
from .reminders import Reminders
from .tickets import Tickets
from .trigger import Trigger
from .tools import Tools
from .triggers import Triggers
from .welcomelog import WelcomeLog

blimp/cogs/alias.py → blimp/cogs/aliasing.py View File


+ 4
- 2
blimp/cogs/board.py View File

@ -6,7 +6,7 @@ import discord
from discord.ext import commands
from ..customizations import Blimp
from .alias import MaybeAliasedTextChannel
from .aliasing import MaybeAliasedTextChannel
class Board(Blimp.Cog):
@ -183,7 +183,9 @@ class Board(Blimp.Cog):
and react.count >= min_reacts
]
reaction = sorted(
possible_reactions, key=lambda react: react.count, reverse=True,
possible_reactions,
key=lambda react: react.count,
reverse=True,
)
if not reaction:
continue


blimp/cogs/logging.py → blimp/cogs/botlog.py View File

@ -1,10 +1,10 @@
from discord.ext import commands
from ..customizations import Blimp
from .alias import MaybeAliasedTextChannel
from .aliasing import MaybeAliasedTextChannel
class Logging(Blimp.Cog):
class BotLog(Blimp.Cog):
"""*Watching with ten thousand eyes.*
Set up logging for your server to keep you informed on BLIMP actions."""

blimp/cogs/slowmode.py → blimp/cogs/longslowmode.py View File

@ -5,10 +5,10 @@ import discord
from discord.ext import commands
from ..customizations import Blimp, ParseableTimedelta
from .alias import MaybeAliasedTextChannel
from .aliasing import MaybeAliasedTextChannel
class Slowmode(Blimp.Cog):
class LongSlowmode(Blimp.Cog):
"""*Deleting things that are just too new for your taste.*
Manages slowmode enforcement for arbitrary durations."""

+ 5
- 2
blimp/cogs/moderation.py View File

@ -4,7 +4,7 @@ import discord
from discord.ext import commands
from ..customizations import Blimp
from .alias import MaybeAliasedTextChannel
from .aliasing import MaybeAliasedTextChannel
class Moderation(Blimp.Cog):
@ -126,7 +126,10 @@ class Moderation(Blimp.Cog):
log_str += f"<#{channel_id}> Error, auto-unbanning.\n"
self.bot.database.execute(
"DELETE FROM channelban_entries WHERE user_oid=:u_oid AND channel_oid=:c_oid",
{"u_oid": row["user_oid"], "c_oid": row["channel_oid"],},
{
"u_oid": row["user_oid"],
"c_oid": row["channel_oid"],
},
)
log_embed = discord.Embed(


+ 5
- 4
blimp/cogs/reminders.py View File

@ -69,14 +69,15 @@ class Reminders(Blimp.Cog):
raise
finally:
self.bot.database.execute(
"DELETE FROM reminders_entries WHERE id=:id", {"id": entry["id"]},
"DELETE FROM reminders_entries WHERE id=:id",
{"id": entry["id"]},
)
@commands.group()
async def reminders(self, ctx: Blimp.Context):
async def reminder(self, ctx: Blimp.Context):
"Manage timed reminders."
@commands.command(parent=reminders, name="list")
@commands.command(parent=reminder, name="list")
async def _list(self, ctx: Blimp.Context):
"List all pending reminders for you."
rems = ctx.database.execute(
@ -105,7 +106,7 @@ class Reminders(Blimp.Cog):
await ctx.reply("\n".join(rows))
@commands.command(parent=reminders)
@commands.command(parent=reminder)
async def delete(self, ctx: Blimp.Context, number: int):
"Delete one of your reminders."


+ 8
- 4
blimp/cogs/rolekiosk.py View File

@ -7,7 +7,7 @@ from discord.ext import commands
from discord.ext.commands import UserInputError
from ..customizations import Blimp
from .alias import MaybeAliasedMessage
from .aliasing import MaybeAliasedMessage
class RoleKiosk(Blimp.Cog):
@ -260,7 +260,9 @@ class RoleKiosk(Blimp.Cog):
@commands.command(parent=kiosk)
async def delete(
self, ctx: Blimp.Context, msg: MaybeAliasedMessage,
self,
ctx: Blimp.Context,
msg: MaybeAliasedMessage,
):
"Delete a role kiosk (but not the message)."
@ -322,7 +324,8 @@ class RoleKiosk(Blimp.Cog):
await self.bot.get_guild(payload.guild_id).get_member(
payload.user_id
).add_roles(
*roles, reason=f"Role Kiosk {payload.message_id}",
*roles,
reason=f"Role Kiosk {payload.message_id}",
)
@Blimp.Cog.listener()
@ -336,5 +339,6 @@ class RoleKiosk(Blimp.Cog):
await self.bot.get_guild(payload.guild_id).get_member(
payload.user_id
).remove_roles(
*roles, reason=f"Role Kiosk {payload.message_id}",
*roles,
reason=f"Role Kiosk {payload.message_id}",
)

+ 14
- 6
blimp/cogs/tickets.py View File

@ -5,7 +5,7 @@ from typing import Optional
import discord
from discord.ext import commands
from .alias import MaybeAliasedCategoryChannel, MaybeAliasedTextChannel
from .aliasing import MaybeAliasedCategoryChannel, MaybeAliasedTextChannel
from ..customizations import Blimp
from ..transcript import Transcript
@ -109,7 +109,8 @@ class Tickets(Blimp.Cog):
).fetchone()
if old:
log_embed.add_field(
name="Old Description", value=description,
name="Old Description",
value=description,
)
ctx.database.execute(
@ -124,7 +125,8 @@ class Tickets(Blimp.Cog):
)
log_embed.add_field(
name="New Description", value=description,
name="New Description",
value=description,
)
await self.bot.post_log(category.guild, embed=log_embed)
@ -257,7 +259,9 @@ class Tickets(Blimp.Cog):
@commands.command(parent=ticket)
async def delete(
self, ctx: Blimp.Context, channel: Optional[MaybeAliasedTextChannel],
self,
ctx: Blimp.Context,
channel: Optional[MaybeAliasedTextChannel],
):
"""Delete a ticket and post a transcript."""
@ -293,7 +297,10 @@ class Tickets(Blimp.Cog):
microseconds=ctx.message.created_at.microsecond
)
archive_embed = (
discord.Embed(title=f"#{channel.name}", color=ctx.Color.I_GUESS,)
discord.Embed(
title=f"#{channel.name}",
color=ctx.Color.I_GUESS,
)
.add_field(
name="Created",
value=str(created_timestamp) + f"\n<@{ticket['creator_id']}>",
@ -424,7 +431,8 @@ class Tickets(Blimp.Cog):
overwrites_without_member = channel.overwrites
overwrites_without_member.pop(member, None)
await channel.edit(
overwrites=overwrites_without_member, reason=str(ctx.author),
overwrites=overwrites_without_member,
reason=str(ctx.author),
)
ctx.database.execute(
"""DELETE FROM ticket_participants WHERE channel_oid = :channel_oid


+ 1
- 1
blimp/cogs/tools.py View File

@ -5,7 +5,7 @@ import discord
from discord.ext import commands
from ..customizations import Blimp, ParseableTimedelta
from .alias import MaybeAliasedCategoryChannel, MaybeAliasedTextChannel
from .aliasing import MaybeAliasedCategoryChannel, MaybeAliasedTextChannel
class Tools(Blimp.Cog):


blimp/cogs/trigger.py → blimp/cogs/triggers.py View File

@ -4,10 +4,10 @@ import discord
from discord.ext import commands
from ..customizations import Blimp
from .alias import MaybeAliasedMessage
from .aliasing import MaybeAliasedMessage
class Trigger(Blimp.Cog):
class Triggers(Blimp.Cog):
"""*The Big Red Button.*
Triggers allow your users to invoke pre-set commands by reacting to a specific message."""
@ -41,11 +41,13 @@ class Trigger(Blimp.Cog):
).fetchone()
if old:
log_embed.add_field(
name="Old", value=old["command"],
name="Old",
value=old["command"],
)
log_embed.add_field(
name="New", value=command,
name="New",
value=command,
)
await msg.add_reaction(emoji)

blimp/cogs/welcome.py → blimp/cogs/welcomelog.py View File

@ -5,10 +5,10 @@ import discord
from discord.ext import commands
from ..customizations import Blimp
from .alias import MaybeAliasedTextChannel
from .aliasing import MaybeAliasedTextChannel
class Welcome(Blimp.Cog):
class WelcomeLog(Blimp.Cog):
"""*Greeting and goodbye-ing people.*
Welcome and Goodbye allow you to greet and see off users that join/leave
your server. The messages allow you to mention the user in question, but

Loading…
Cancel
Save