internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: Cog-Creators/Red-DiscordBot

Issue:
` ctx.clean_prefix` sanitizes only bot's mention (documentation issue)
# Other bugs

#### What were you trying to do?

Sanitize mentions with `Context.clean_prefix`

#### What were you expecting to happen?

All mentions are sanitized to `@%display_name%` state

#### What actually happened?

Only bot's mention sanitized

---

As explained in the comments below, this is a documentation issue.


Discussion:
This is a documentation issue, not a bug with the `Context.clean_prefix`.
Docstring should be made a lot clearer:
a) rather than saying that it makes a mention prefix "display nicer", it should say that it's a prefix with bot mention sanitized (could possibly be worded even better than that)
b) it should specify that it's only sanitizing mentions of bot user
c) it should (imo) say some intended use case, i.e. that it should be used instead of `ctx.prefix` in places where discord mentions aren't rendered

Resolving patch:
diff --git a/redbot/core/commands/context.py b/redbot/core/commands/context.py
--- a/redbot/core/commands/context.py
+++ b/redbot/core/commands/context.py
@@ -259,14 +259,18 @@ async def maybe_send_embed(self, message: str) -> discord.Message:
 
     @property
     def clean_prefix(self) -> str:
-        """str: The command prefix, but a mention prefix is displayed nicer."""
+        """
+        str: The command prefix, but with a sanitized version of the bot's mention if it was used as prefix.
+        This can be used in a context where discord user mentions might not render properly.
+        """
         me = self.me
         pattern = re.compile(rf"<@!?{me.id}>")
         return pattern.sub(f"@{me.display_name}".replace("\\", r"\\"), self.prefix)
 
     @property
     def me(self) -> Union[discord.ClientUser, discord.Member]:
-        """discord.abc.User: The bot member or user object.
+        """
+        discord.abc.User: The bot member or user object.
 
         If the context is DM, this will be a `discord.User` object.
         """


Test patch:
Repository: Cog-Creators/Red-DiscordBot

Issue:
`[p]report` sends unhelpful error if report channel is not set
# Command bugs

#### Command name

`[p]report`

#### What cog is this command from?

Reports

#### What were you expecting to happen?

Get some meaningful error.

#### What actually happened?

I got a generic "There was an error sending your report, please contact a server admin."

#### How can we reproduce this issue?

Run these in a server which never had a report channel set.
```
[p]load reports
[p]reportset toggle
[p]report
```



Discussion:

Resolving patch:
diff --git a/redbot/cogs/reports/reports.py b/redbot/cogs/reports/reports.py
--- a/redbot/cogs/reports/reports.py
+++ b/redbot/cogs/reports/reports.py
@@ -271,9 +271,16 @@ async def report(self, ctx: commands.Context, *, _report: str = ""):
 
         with contextlib.suppress(discord.Forbidden, discord.HTTPException):
             if val is None:
-                await author.send(
-                    _("There was an error sending your report, please contact a server admin.")
-                )
+                if await self.config.guild(ctx.guild).output_channel() is None:
+                    await author.send(
+                        _(
+                            "This server has no reports channel set up. Please contact a server admin."
+                        )
+                    )
+                else:
+                    await author.send(
+                        _("There was an error sending your report, please contact a server admin.")
+                    )
             else:
                 await author.send(_("Your report was submitted. (Ticket #{})").format(val))
                 self.antispam[guild.id][author.id].stamp()


Test patch:
Repository: Cog-Creators/Red-DiscordBot

Issue:
[Streams] youtubestream returns APIError for invalid channel names/ID
# Command bugs

<!-- 
Did you find a bug with a command? Fill out the following:
-->

#### Command name

youtubestream

#### What cog is this command from?

Streams

#### What were you expecting to happen?

More descriptive error

#### What actually happened?

Command returns a "something went wrong whilst trying to contact the stream services API"
- The status code returned is also a 200.
[Image](https://i.flaree.xyz/_LumberingStudiousChevrotain_.png)

#### How can we reproduce this issue?

[p]youtubestream account name
[p]youtubestream account ID



[Streams] youtubestream returns APIError for invalid channel names/ID
# Command bugs

<!-- 
Did you find a bug with a command? Fill out the following:
-->

#### Command name

youtubestream

#### What cog is this command from?

Streams

#### What were you expecting to happen?

More descriptive error

#### What actually happened?

Command returns a "something went wrong whilst trying to contact the stream services API"
- The status code returned is also a 200.
[Image](https://i.flaree.xyz/_LumberingStudiousChevrotain_.png)

#### How can we reproduce this issue?

[p]youtubestream account name
[p]youtubestream account ID





Discussion:
:Thonk: 200 and an error? do you have anything in the logs that would suggest there was an error in the cog rather than API? otherwise.... Yayyyy for youtube sending 200 on errors, lets give them a round of applause for breaking convention.
[image](https://i.flaree.xyz/_VainAnguishedMosquito_.png)

This is the params, resp status and resp data returned
Ah awesome .. handling is broken then rather than YouTube breaking shit again.
:Thonk: 200 and an error? do you have anything in the logs that would suggest there was an error in the cog rather than API? otherwise.... Yayyyy for youtube sending 200 on errors, lets give them a round of applause for breaking convention.
[image](https://i.flaree.xyz/_VainAnguishedMosquito_.png)

This is the params, resp status and resp data returned
Ah awesome .. handling is broken then rather than YouTube breaking shit again.

Resolving patch:
diff --git a/redbot/cogs/streams/streamtypes.py b/redbot/cogs/streams/streamtypes.py
--- a/redbot/cogs/streams/streamtypes.py
+++ b/redbot/cogs/streams/streamtypes.py
@@ -190,6 +190,12 @@ async def _fetch_channel_resource(self, resource: str):
             raise StreamNotFound()
         elif "items" in data:
             return data["items"][0][resource]
+        elif (
+            "pageInfo" in data
+            and "totalResults" in data["pageInfo"]
+            and data["pageInfo"]["totalResults"] < 1
+        ):
+            raise StreamNotFound()
         raise APIError()
 
     def __repr__(self):


Test patch:
Repository: Cog-Creators/Red-DiscordBot

Issue:
[Cleanup] bot reports incorrect number of messages it mass deleted
# Command bugs

<!-- 
Did you find a bug with a command? Fill out the following:
-->

#### Command name

[p]cleanup messages [>100]

#### What cog is this command from?

Cleanup

#### What were you expecting to happen?

Bot should report the exact or correct amount of messages it deleted from the given channel in console/logs.

#### What actually happened?

Bot reports incorrect amount of messages deleted in console. I think it passes the same number we give as input.

#### How can we reproduce this issue?

Load cleanup cog, if haven't.
Try to delete more than 100 messages in a given channel with `[p]cleanup messages`. Confirm when prompted to. 
Try to pass an integer larger than the total number of messages of last 2 weeks which exists in the target channel. <- This step is essential to reproduce this bug.
Observe in your console/logs the amount the bot returns as deleted messages.
![image](https://user-images.githubusercontent.com/24418520/89275927-94ceb280-d660-11ea-9bc9-2f6441c2a9c8.png)
(^^for context in this screenshot, I used `[p]cleanup messages 500` in a channel.)

Now check your guild audit logs and see how many messages the bot actually deleted and cross-verify with the output bot provided in console/logs.
![image](https://user-images.githubusercontent.com/24418520/89275865-7b2d6b00-d660-11ea-8933-29ecbd9d930d.png)
You should be able to confirm that bot reports incorrect number of messages it mass deleted.

-----
While I have only observed and tested this with `[p]cleanup messages` subcommand, I assume the same bug should occur with other cleanup subcommands becuase of how `check_100_plus()` staticmethod is handled, though I could be wrong, but please verify it with other `cleanup` subcommands.



Discussion:

Resolving patch:
diff --git a/redbot/cogs/cleanup/cleanup.py b/redbot/cogs/cleanup/cleanup.py
--- a/redbot/cogs/cleanup/cleanup.py
+++ b/redbot/cogs/cleanup/cleanup.py
@@ -378,7 +378,7 @@ async def messages(
         to_delete.append(ctx.message)
 
         reason = "{}({}) deleted {} messages in channel {}.".format(
-            author.name, author.id, number, channel.name
+            author.name, author.id, len(to_delete), channel.name
         )
         log.info(reason)
 


Test patch:
Repository: Cog-Creators/Red-DiscordBot

Issue:
Update Lavalink build
This serves solely as an informational issue to put in milestone so that it's not forgotten.


Discussion:

Resolving patch:
diff --git a/redbot/cogs/audio/manager.py b/redbot/cogs/audio/manager.py
--- a/redbot/cogs/audio/manager.py
+++ b/redbot/cogs/audio/manager.py
@@ -20,7 +20,7 @@
 
 log = logging.getLogger("red.audio.manager")
 JAR_VERSION: Final[str] = "3.3.1"
-JAR_BUILD: Final[int] = 1068
+JAR_BUILD: Final[int] = 1069
 LAVALINK_DOWNLOAD_URL: Final[str] = (
     "https://github.com/Cog-Creators/Lavalink-Jars/releases/download/"
     f"{JAR_VERSION}_{JAR_BUILD}/"


Test patch:
Repository: Cog-Creators/Red-DiscordBot

Issue:
[Permissions] DM notification for command in DM
# Command bugs

#### Command name

`permissions acl getglobal`

#### What cog is this command from?

`Permissions`

#### What were you expecting to happen?

Get YAML without notification about DM

#### What actually happened?

Got YAML file and `I've just sent the file to you via DM.` message in DM

#### How can we reproduce this issue?

Execute `[p]permissions acl getglobal` in DM



Discussion:
 I've reproduced this myself and the issue makes sense, there's no need for the bot to tell you the file will be sent via DM if you're already DMing the bot for it.
 Can I make a PR to fix this?
@douglas-cpp Of course, feel free to take it :)

Resolving patch:
diff --git a/redbot/cogs/permissions/permissions.py b/redbot/cogs/permissions/permissions.py
--- a/redbot/cogs/permissions/permissions.py
+++ b/redbot/cogs/permissions/permissions.py
@@ -10,7 +10,6 @@
 from redbot.core import checks, commands, config
 from redbot.core.bot import Red
 from redbot.core.i18n import Translator, cog_i18n
-from redbot.core.utils import AsyncIter
 from redbot.core.utils.chat_formatting import box
 from redbot.core.utils.menus import start_adding_reactions
 from redbot.core.utils.predicates import ReactionPredicate, MessagePredicate
@@ -333,7 +332,8 @@ async def permissions_acl_getglobal(self, ctx: commands.Context):
         except discord.Forbidden:
             await ctx.send(_("I'm not allowed to DM you."))
         else:
-            await ctx.send(_("I've just sent the file to you via DM."))
+            if not isinstance(ctx.channel, discord.DMChannel):
+                await ctx.send(_("I've just sent the file to you via DM."))
         finally:
             file.close()
 


Test patch:
Repository: Cog-Creators/Red-DiscordBot

Issue:
[serverinfo/userinfo] Pluralize strings
# Commands improvement

#### Command name

`[p]userinfo` and `[p]serverinfo`

#### What cog is this command from?

From `Mod` cog.

#### What improvement are you expecting to?

I would like to see all strings pluralized (ie. `Text Channels` being `Text Channel` if there's only one channel and so on).

#### What actually happened?

Roles and previous nickname/names aren't pluralized.


Discussion:

Resolving patch:
diff --git a/redbot/cogs/mod/names.py b/redbot/cogs/mod/names.py
--- a/redbot/cogs/mod/names.py
+++ b/redbot/cogs/mod/names.py
@@ -245,15 +245,25 @@ async def userinfo(self, ctx, *, user: discord.Member = None):
         data.add_field(name=_("Joined Discord on"), value=created_on)
         data.add_field(name=_("Joined this server on"), value=joined_on)
         if role_str is not None:
-            data.add_field(name=_("Roles"), value=role_str, inline=False)
+            data.add_field(
+                name=_("Roles") if len(roles) > 1 else _("Role"), value=role_str, inline=False
+            )
         if names:
             # May need sanitizing later, but mentions do not ping in embeds currently
             val = filter_invites(", ".join(names))
-            data.add_field(name=_("Previous Names"), value=val, inline=False)
+            data.add_field(
+                name=_("Previous Names") if len(names) > 1 else _("Previous Name"),
+                value=val,
+                inline=False,
+            )
         if nicks:
             # May need sanitizing later, but mentions do not ping in embeds currently
             val = filter_invites(", ".join(nicks))
-            data.add_field(name=_("Previous Nicknames"), value=val, inline=False)
+            data.add_field(
+                name=_("Previous Nicknames") if len(nicks) > 1 else _("Previous Nickname"),
+                value=val,
+                inline=False,
+            )
         if voice_state and voice_state.channel:
             data.add_field(
                 name=_("Current voice channel"),


Test patch:
Repository: Cog-Creators/Red-DiscordBot

Issue:
Add an method to the bot object to allow for fetch_user to be cached
# Feature request

<!-- This template is for feature requests. Please fill out the following: -->


#### Select the type of feature you are requesting:

<!-- To check a box, replace the space between the [] with a x -->

- [ ] Cog
- [ ] Command
- [ x ] API functionality

#### Describe your requested feature

Add a simple method to the bot object that can be used instead of bot.fetch_user, this would cache the user object so that repeated uses on this on same id would return the cached object, this could also be expanded to anything that uses fetch (fetch channel, fetch guild, fetch message)



Discussion:

Resolving patch:
diff --git a/redbot/core/bot.py b/redbot/core/bot.py
--- a/redbot/core/bot.py
+++ b/redbot/core/bot.py
@@ -665,6 +665,67 @@ async def get_embed_color(self, location: discord.abc.Messageable) -> discord.Co
 
         return self._color
 
+    async def get_or_fetch_user(self, user_id: int) -> discord.User:
+        """
+        Retrieves a `discord.User` based on their ID.
+        You do not have to share any guilds
+        with the user to get this information, however many operations
+        do require that you do.
+
+        .. warning::
+
+            This method may make an API call if the user is not found in the bot cache. For general usage, consider ``bot.get_user`` instead.
+
+        Parameters
+        -----------
+        user_id: int
+            The ID of the user that should be retrieved.
+
+        Raises
+        -------
+        Errors
+            Please refer to `discord.Client.fetch_user`.
+
+        Returns
+        --------
+        discord.User
+            The user you requested.
+        """
+
+        if (user := self.get_user(user_id)) is not None:
+            return user
+        return await self.fetch_user(user_id)
+
+    async def get_or_fetch_member(self, guild: discord.Guild, member_id: int) -> discord.Member:
+        """
+        Retrieves a `discord.Member` from a guild and a member ID.
+
+        .. warning::
+
+            This method may make an API call if the user is not found in the bot cache. For general usage, consider ``discord.Guild.get_member`` instead.
+
+        Parameters
+        -----------
+        guild: discord.Guild
+            The guild which the member should be retrieved from.
+        member_id: int
+            The ID of the member that should be retrieved.
+
+        Raises
+        -------
+        Errors
+            Please refer to `discord.Guild.fetch_member`.
+
+        Returns
+        --------
+        discord.Member
+            The user you requested.
+        """
+
+        if (member := guild.get_member(member_id)) is not None:
+            return member
+        return await guild.fetch_member(member_id)
+
     get_embed_colour = get_embed_color
 
     # start config migrations


Test patch:
Repository: Cog-Creators/Red-DiscordBot

Issue:
exception text for default Bucket concurrency
# Other bugs

#### What were you trying to do?

Add a max_concurrency to a command with default (global) bucket

#### What were you expecting to happen?

Red say something like "Too many people using this command. It can only be used 1 time(s) concurrently."

#### What actually happened?

Red says "Too many people using this command. It can only be used 1 time(s) *per default* concurrently.", which is confusing.

#### How can we reproduce this issue?

create any command with default bucket concurrency limit



Discussion:

Resolving patch:
diff --git a/redbot/core/events.py b/redbot/core/events.py
--- a/redbot/core/events.py
+++ b/redbot/core/events.py
@@ -297,12 +297,17 @@ async def on_command_error(ctx, error, unhandled_by_cog=False):
                 msg = _("This command is on cooldown. Try again in 1 second.")
             await ctx.send(msg, delete_after=error.retry_after)
         elif isinstance(error, commands.MaxConcurrencyReached):
-            await ctx.send(
-                _(
+            if error.per is commands.BucketType.default:
+                msg = _(
+                    "Too many people using this command."
+                    " It can only be used {number} time(s) concurrently."
+                ).format(number=error.number)
+            else:
+                msg = _(
                     "Too many people using this command."
                     " It can only be used {number} time(s) per {type} concurrently."
                 ).format(number=error.number, type=error.per.name)
-            )
+            await ctx.send(msg)
         else:
             log.exception(type(error).__name__, exc_info=error)
 


Test patch:
Repository: Cog-Creators/Red-DiscordBot

Issue:
Stop backing up lavalink logs
Lavalink logs are host specific, stop backing them up.


Discussion:

Resolving patch:
diff --git a/redbot/core/utils/_internal_utils.py b/redbot/core/utils/_internal_utils.py
--- a/redbot/core/utils/_internal_utils.py
+++ b/redbot/core/utils/_internal_utils.py
@@ -211,6 +211,7 @@ async def create_backup(dest: Path = Path.home()) -> Optional[Path]:
         os.path.join("Downloader", "lib"),
         os.path.join("CogManager", "cogs"),
         os.path.join("RepoManager", "repos"),
+        os.path.join("Audio", "logs"),
     ]
 
     # Avoiding circular imports


Test patch:
Repository: Cog-Creators/Red-DiscordBot

Issue:
Maybe_send_embed inconsistent behavior for cog developers
# Other bugs


#### What were you trying to do?

Use `maybe_send_embed` to send an empty string

#### What were you expecting to happen?

Consistent behavior with an error, failing to send an empty message per:
`discord.errors.HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message`

#### What actually happened?

Only caused an error when embeds were off, no error when embeds were on.

#### How can we reproduce this issue?

`[p]eval await ctx.maybe_send_embed("")`
`[p]embedset global`
`[p]eval await ctx.maybe_send_embed("")`



Discussion:

Resolving patch:
diff --git a/redbot/core/commands/context.py b/redbot/core/commands/context.py
--- a/redbot/core/commands/context.py
+++ b/redbot/core/commands/context.py
@@ -248,8 +248,11 @@ async def maybe_send_embed(self, message: str) -> discord.Message:
             see `discord.abc.Messageable.send`
         discord.HTTPException
             see `discord.abc.Messageable.send`
+        ValueError
+            when the message's length is not between 1 and 2000 characters.
         """
-
+        if not message or len(message) > 2000:
+            raise ValueError("Message length must be between 1 and 2000")
         if await self.embed_requested():
             return await self.send(
                 embed=discord.Embed(description=message, color=(await self.embed_colour()))


Test patch:
Repository: Cog-Creators/Red-DiscordBot

Issue:
Show what color you use on embed in `set showsettings`.
# Feature request

- [ ] Cog
- [x] Command
- [ ] API functionality

#### Describe your requested feature

Show what color you use on your embed in `set showsettings`, could be useful, as there isn't a settings to see what color you use currently. (at least what i've seen so far). iknow you can use eval / debug but, not everyone knows how to do that.


Discussion:

Resolving patch:
diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py
--- a/redbot/core/core_commands.py
+++ b/redbot/core/core_commands.py
@@ -1579,6 +1579,7 @@ async def set_showsettings(self, ctx: commands.Context):
         global_data = await ctx.bot._config.all()
         locale = global_data["locale"]
         regional_format = global_data["regional_format"] or _("Same as bot's locale")
+        colour = discord.Colour(global_data["color"])
 
         prefix_string = " ".join(prefixes)
         settings = _(
@@ -1586,13 +1587,15 @@ async def set_showsettings(self, ctx: commands.Context):
             "Prefixes: {prefixes}\n"
             "{guild_settings}"
             "Locale: {locale}\n"
-            "Regional format: {regional_format}"
+            "Regional format: {regional_format}\n"
+            "Default embed colour: {colour}"
         ).format(
             bot_name=ctx.bot.user.name,
             prefixes=prefix_string,
             guild_settings=guild_settings,
             locale=locale,
             regional_format=regional_format,
+            colour=colour,
         )
         for page in pagify(settings):
             await ctx.send(box(page))


Test patch: