Skip to content
This repository has been archived by the owner on Oct 15, 2023. It is now read-only.

Commit

Permalink
[dpy2] fix Context.trigger_typing() not being an attribute anymore …
Browse files Browse the repository at this point in the history
…on dpy v2.1.0 (#152)

* [BanChart] fix `ctx.trigger_typing`

* [Baron] Fix `ctx.trigger_typing()`

* [Lock] Fix `ctx.trigger_typing()`

* [PfpImgen] Fix `ctx.trigger_typing()`

* [Tags] FIx `ctx.trigger_typing()`

* [Baron] shift `ctx.send` outside `ctx.typing`

* [Lock] remove try excepts

* [Lock] shift `ctx.send` outside `ctx.typing`

* [PfpImgen] fix duplicate]

* [Baron] shift back to `await ctx.typing()`

* [Lock] shift to `await ctx.typing()`

* [Lock] shift to `await ctx.typing()`

* style reformatting (Black)

---------

Co-authored-by: PhenoM4n4n <61065078+phenom4n4n@users.noreply.github.com>
  • Loading branch information
japandotorg and phenom4n4n committed May 9, 2023
1 parent 5c85958 commit 53b3b0c
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 39 deletions.
2 changes: 1 addition & 1 deletion banchart/banchart.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class BanChart(commands.Cog):
Display a chart of the moderators with the most bans.
"""

__version__ = "1.1.0"
__version__ = "1.1.1"

def __init__(self, bot: Red) -> None:
self.bot = bot
Expand Down
2 changes: 1 addition & 1 deletion baron/baron.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ async def guildgrowth(
]
if len(guilds) <= 1:
return await ctx.send("There aren't enough server joins during that time.")

task = functools.partial(self.create_graph, guilds)
task = self.bot.loop.run_in_executor(None, task)
try:
Expand Down
30 changes: 19 additions & 11 deletions lock/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ async def lock(
`[p]lock 737958453905063977 @members`
"""
try:
await ctx.trigger_typing()
except discord.Forbidden: # when another bot is faster to lock
await ctx.typing()
except discord.Forbidden:
return

if not channel:
Expand Down Expand Up @@ -154,8 +154,8 @@ async def viewlock(
`[p]viewlock 7382395026348520 @nubs`
"""
try:
await ctx.trigger_typing()
except discord.Forbidden: # when another bot is faster to lock
await ctx.typing()
except discord.Forbidden:
return

if not channel:
Expand Down Expand Up @@ -242,7 +242,11 @@ async def lock_perms(
if not permissions:
raise commands.BadArgument

await ctx.trigger_typing()
try:
await ctx.typing()
except discord.Forbidden:
return

channel = channel or ctx.channel
roles_or_members = roles_or_members or [ctx.guild.default_role]

Expand Down Expand Up @@ -288,8 +292,8 @@ async def unlock(
`[p]unlock 739562845027353 true`
"""
try:
await ctx.trigger_typing()
except discord.Forbidden: # when another bot is faster to lock
await ctx.typing()
except discord.Forbidden:
return

if not channel:
Expand Down Expand Up @@ -325,9 +329,9 @@ async def unlock(
succeeded.append(inline(role.name))
except:
failed.append(inline(role.name))

else:
cancelled.append(inline(role.name))

msg = ""
if succeeded:
msg += f"{channel.mention} has unlocked for {humanize_list(succeeded)} with state `{'true' if state else 'default'}`.\n"
Expand Down Expand Up @@ -360,8 +364,8 @@ async def unviewlock(
`[p]unviewlock 746284923572835 @boosters`
"""
try:
await ctx.trigger_typing()
except discord.Forbidden: # when another bot is faster to lock
await ctx.typing()
except discord.Forbidden:
return

if not channel:
Expand Down Expand Up @@ -455,7 +459,11 @@ async def unlock_perms(
if not permissions:
raise commands.BadArgument

await ctx.trigger_typing()
try:
await ctx.typing()
except discord.Forbidden:
return

channel = channel or ctx.channel
roles_or_members = roles_or_members or [ctx.guild.default_role]

Expand Down
13 changes: 6 additions & 7 deletions pfpimgen/pfpimgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,13 @@ async def neko(self, ctx, *, member: FuzzyMember = None):
@commands.command(cooldown_after_parsing=True)
async def bonk(self, ctx, *, member: FuzzyMember = None):
"""Bonk! Go to horny jail."""
await ctx.trigger_typing()
bonker = False
if member:
bonker = ctx.author
else:
member = ctx.author

async with ctx.typing():
bonker = False
if member:
bonker = ctx.author
else:
member = ctx.author

victim_avatar = await self.get_avatar(member)
if bonker:
bonker_avatar = await self.get_avatar(bonker)
Expand Down
38 changes: 19 additions & 19 deletions tags/mixins/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,25 +445,25 @@ async def tag_docs(self, ctx: commands.Context, keyword: str = None):
**Example:**
`[p]tag docs embed`
"""
await ctx.trigger_typing()
e = discord.Embed(color=await ctx.embed_color(), title="Tags Documentation")
if keyword:
matched_labels = await self.doc_search(keyword)
description = [f"Search for: `{keyword}`"]
for name, url in matched_labels.items():
description.append(f"[`{name}`]({url})")
url = f"{DOCS_URL}/search.html?q={quote_plus(keyword)}&check_keywords=yes&area=default"
e.url = url
embeds = []
description = "\n".join(description)
for page in pagify(description):
embed = e.copy()
embed.description = page
embeds.append(embed)
await menu(ctx, embeds)
else:
e.url = DOCS_URL
await ctx.send(embed=e)
async with ctx.typing():
e = discord.Embed(color=await ctx.embed_color(), title="Tags Documentation")
if keyword:
matched_labels = await self.doc_search(keyword)
description = [f"Search for: `{keyword}`"]
for name, url in matched_labels.items():
description.append(f"[`{name}`]({url})")
url = f"{DOCS_URL}/search.html?q={quote_plus(keyword)}&check_keywords=yes&area=default"
e.url = url
embeds = []
description = "\n".join(description)
for page in pagify(description):
embed = e.copy()
embed.description = page
embeds.append(embed)
await menu(ctx, embeds)
else:
e.url = DOCS_URL
await ctx.send(embed=e)

@commands.is_owner()
@tag.command("run", aliases=["execute"])
Expand Down

0 comments on commit 53b3b0c

Please sign in to comment.