Skip to content

Commit d0f6bf5

Browse files
authored
Merge pull request #51 from Cog-Creators/V3/develop
upstream updates
2 parents 3c821bc + c6ff219 commit d0f6bf5

File tree

5 files changed

+45
-18
lines changed

5 files changed

+45
-18
lines changed

docs/framework_config.rst

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,22 @@ Here is an example of the :code:`async with` syntax:
155155
blah.append(new_blah)
156156
await ctx.send("The new blah value has been added!")
157157
158+
There is also a :py:meth:`Group.all` method. This will return all the stored data associated
159+
with a specific config group as a :py:class:`dict`. By negating the need to excessively call config,
160+
this method can be particularly useful when multiple values are to be retrieved from the same group.
161+
162+
Here is an example of :py:meth:`Group.all` usage:
163+
164+
.. code-block:: python
165+
166+
@commands.command()
167+
async def getall(self, ctx):
168+
all_global_data = await self.config.all()
169+
await ctx.send("Foobar is {foobar}, foo baz is {foo_baz}".format(
170+
foobar=str(all_global_data["foobar"]),
171+
foo_baz=str(all_global_data["foo"]["baz"])
172+
))
173+
158174
159175
.. important::
160176

@@ -398,7 +414,7 @@ We're responsible pet owners here, so we've also got to have a way to feed our p
398414
# We could accomplish the same thing a slightly different way
399415
await self.config.user(ctx.author).pets.get_attr(pet_name).hunger.set(new_hunger)
400416

401-
await ctx.send("Your pet is now at {}/100 hunger!".format(new_hunger)
417+
await ctx.send("Your pet is now at {}/100 hunger!".format(new_hunger))
402418

403419
Of course, if we're less than responsible pet owners, there are consequences::
404420

@@ -481,7 +497,7 @@ Config prioritizes being a safe data store without developers needing to
481497
know how end users have configured their bot.
482498

483499
This does come with some performance costs, so keep the following in mind when choosing to
484-
develop using config
500+
develop using config.
485501

486502
* Config use in events should be kept minimal and should only occur
487503
after confirming the event needs to interact with config

docs/guide_publish_cogs.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Keys common to both repo and cog info.json (case sensitive)
4747
is installed or a repo is added
4848

4949
.. tip:: You can use the ``[p]`` key in your string to use the prefix
50-
used for installing.
50+
used for installing, and ``[botname]`` to show the bot's username.
5151

5252
- ``short`` (string) - A short description of the cog or repo. For cogs, this info
5353
is displayed when a user executes ``[p]cog list``

redbot/cogs/mod/names.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,9 @@ async def names(self, ctx: commands.Context, *, member: discord.Member):
309309
usernames, display_names, nicks = await self.get_names(member)
310310
parts = []
311311
for header, names in (
312-
(_("Past 20 usernames:"), usernames),
313-
(_("Past 20 global display names:"), display_names),
314-
(_("Past 20 server nicknames:"), nicks),
312+
(_("Past 20 usernames: "), usernames),
313+
(_("Past 20 global display names: "), display_names),
314+
(_("Past 20 server nicknames: "), nicks),
315315
):
316316
if names:
317317
parts.append(bold(header) + ", ".join(names))

redbot/cogs/reports/reports.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ async def report(self, ctx: commands.Context, *, _report: str = ""):
307307

308308
with contextlib.suppress(discord.Forbidden, discord.HTTPException):
309309
if val is None:
310-
if await self.config.guild(ctx.guild).output_channel() is None:
310+
if await self.config.guild(guild).output_channel() is None:
311311
await author.send(
312312
_(
313313
"This server has no reports channel set up. Please contact a server admin."

redbot/core/bot.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2464,23 +2464,34 @@ async def send_interactive(
24642464
msg = await channel.send(box(page, lang=box_lang))
24652465
ret.append(msg)
24662466
n_remaining = len(messages) - idx
2467+
files_perm = (
2468+
not channel.guild or channel.permissions_for(channel.guild.me).attach_files
2469+
)
2470+
options = ("more", "file") if files_perm else ("more",)
24672471
if n_remaining > 0:
24682472
if n_remaining == 1:
2469-
prompt_text = _(
2470-
"There is still one message remaining. Type {command_1} to continue"
2471-
" or {command_2} to upload all contents as a file."
2472-
)
2473+
if files_perm:
2474+
prompt_text = _(
2475+
"There is still one message remaining. Type {command_1} to continue or {command_2} to upload all contents as a file."
2476+
)
2477+
else:
2478+
prompt_text = _(
2479+
"There is still one message remaining. Type {command_1} to continue."
2480+
)
24732481
else:
2474-
prompt_text = _(
2475-
"There are still {count} messages remaining. Type {command_1} to continue"
2476-
" or {command_2} to upload all contents as a file."
2477-
)
2482+
if files_perm:
2483+
prompt_text = _(
2484+
"There are still {count} messages remaining. Type {command_1} to continue or {command_2} to upload all contents as a file."
2485+
)
2486+
else:
2487+
prompt_text = _(
2488+
"There are still {count} messages remaining. Type {command_1} to continue."
2489+
)
2490+
24782491
query = await channel.send(
24792492
prompt_text.format(count=n_remaining, command_1="`more`", command_2="`file`")
24802493
)
2481-
pred = MessagePredicate.lower_contained_in(
2482-
("more", "file"), channel=channel, user=user
2483-
)
2494+
pred = MessagePredicate.lower_contained_in(options, channel=channel, user=user)
24842495
try:
24852496
resp = await self.wait_for(
24862497
"message",

0 commit comments

Comments
 (0)