70 Commits

Author SHA1 Message Date
Jakub Kuczys
dbb91dfce8
Fix poor fuzzy results due to changes in rapidfuzz 3.0 (#6224)
Co-authored-by: aikaterna <20862007+aikaterna@users.noreply.github.com>
2023-08-09 22:03:21 -07:00
Jakub Kuczys
cbe50bf82e
Use proper Parameter type in CustomCommands cog (#6149)
Co-authored-by: Jamie <31554168+flaree@users.noreply.github.com>
2023-05-13 16:55:10 +01:00
Vexed
2386b8363f
Fix visual issues with Discord's new Markdown (#6101)
Co-authored-by: Jakub Kuczys <me@jacken.men>
2023-05-13 12:39:57 +02:00
Kreusada
79d11e947c
Use the commands module instead of checks for permission decorators (#5463)
Co-authored-by: Flame442 <34169552+Flame442@users.noreply.github.com>
2023-04-13 14:16:12 -04:00
Jakub Kuczys
519acedf46
Make some dependency changes, support Python 3.10 and 3.11 (#5611)
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
2022-12-30 03:21:57 +01:00
Flame442
6c8b6eb71c
[CustomCom] Fix [p]cc cooldown docstring & docs (#5914) 2022-11-23 01:37:20 +01:00
Jakub Kuczys
27bed5010f
Make controls in menu() optional (#5678)
* Make `controls` in `menu()` optional

You might wonder, shouldn't we pass `None` to functions from controls?
No, we shouldn't because when `None` is passed, only DEFAULT_CONTROLS
can be used and that means that the length of pages list won't change.

* Update usage in core and core cogs

* Add missing docstrings to `redbot.core.utils.menus` module
2022-04-16 13:29:12 -06:00
jack1142
febca8ccbb
Migration to discord.py 2.0 (#5600)
* Temporarily set d.py to use latest git revision

* Remove `bot` param to Client.start

* Switch to aware datetimes

A lot of this is removing `.replace(...)` which while not technically
needed, simplifies the code base. There's only a few changes that are
actually necessary here.

* Update to work with new Asset design

* [threads] Update core ModLog API to support threads

- Added proper support for passing `Thread` to `channel`
  when creating/editing case
- Added `parent_channel_id` attribute to Modlog API's Case
    - Added `parent_channel` property that tries to get parent channel
- Updated case's content to show both thread and parent information

* [threads] Disallow usage of threads in some of the commands

- announceset channel
- filter channel clear
- filter channel add
- filter channel remove
- GlobalUniqueObjectFinder converter
    - permissions addglobalrule
    - permissions removeglobalrule
    - permissions removeserverrule
    - Permissions cog does not perform any validation for IDs
      when setting through YAML so that has not been touched
- streamalert twitch/youtube/picarto
- embedset channel
- set ownernotifications adddestination

* [threads] Handle threads in Red's permissions system (Requires)

- Made permissions system apply rules of (only) parent in threads

* [threads] Update embed_requested to support threads

- Threads don't have their own embed settings and inherit from parent

* [threads] Update Red.message_eligible_as_command to support threads

* [threads] Properly handle invocation of [p](un)mutechannel in threads

Usage of a (un)mutechannel will mute/unmute user in the parent channel
if it's invoked in a thread.

* [threads] Update Filter cog to properly handle threads

- `[p]filter channel list` in a threads sends list for parent channel
- Checking for filter hits for a message in a thread checks its parent
  channel's word list. There's no separate word list for threads.

* [threads] Support threads in Audio cog

- Handle threads being notify channels
- Update type hint for `is_query_allowed()`

* [threads] Update type hints and documentation to reflect thread support

- Documented that `{channel}` in CCs might be a thread
- Allowed (documented) usage of threads with `Config.channel()`
    - Separate thread scope is still in the picture though
      if it were to be done, it's going to be in separate in PR
- GuildContext.channel might be Thread

* Use less costy channel check in customcom's on_message_without_command

This isn't needed for d.py 2.0 but whatever...

* Update for in-place edits

* Embed's bool changed behavior, I'm hoping it doesn't affect us

* Address User.permissions_in() removal

* Swap VerificationLevel.extreme with VerificationLevel.highest

* Change to keyword-only parameters

* Change of `Guild.vanity_invite()` return type

* avatar -> display_avatar

* Fix metaclass shenanigans with Converter

* Update Red.add_cog() to be inline with `dpy_commands.Bot.add_cog()`

This means adding `override` keyword-only parameter and causing
small breakage by swapping RuntimeError with discord.ClientException.

* Address all DEP-WARNs

* Remove Context.clean_prefix and use upstream implementation instead

* Remove commands.Literal and use upstream implementation instead

Honestly, this was a rather bad implementation anyway...

Breaking but actually not really - it was provisional.

* Update Command.callback's setter

Support for functools.partial is now built into d.py

* Add new perms in HUMANIZED_PERM mapping (some from d.py 1.7 it seems)

BTW, that should really be in core instead of what we have now...

* Remove the part of do_conversion that has not worked for a long while

* Stop wrapping BadArgument in ConversionFailure

This is breaking but it's best to resolve it like this.

The functionality of ConversionFailure can be replicated with
Context.current_parameter and Context.current_argument.

* Add custom errors for int and float converters

* Remove Command.__call__ as it's now implemented in d.py

* Get rid of _dpy_reimplements

These were reimplemented for the purpose of typing
so it is no longer needed now that d.py is type hinted.

* Add return to Red.remove_cog

* Ensure we don't delete messages that differ only by used sticker

* discord.InvalidArgument->ValueError

* Move from raw <t:...> syntax to discord.utils.format_dt()

* Address AsyncIter removal

* Swap to pos-only for params that are pos-only in upstream

* Update for changes to Command.params

* [threads] Support threads in ignore checks and allow ignoring them

- Updated `[p](un)ignore channel` to accept threads
- Updated `[p]ignore list` to list ignored threads
- Updated logic in `Red.ignored_channel_or_guild()`

Ignores for guild channels now work as follows (only changes for threads):
- if channel is not a thread:
    - check if user has manage channels perm in channel
      and allow command usage if so
    - check if channel is ignored and disallow command usage if so
    - allow command usage if none of the conditions above happened
- if channel is a thread:
    - check if user has manage channels perm in parent channel
      and allow command usage if so
    - check if parent channel is ignored and disallow command usage
      if so
    - check if user has manage thread perm in parent channel
      and allow command usage if so
    - check if thread is ignored and disallow command usage if so
    - allow command usage if none of the conditions above happened

* [partial] Raise TypeError when channel is of PartialMessageable type

- Red.embed_requested
- Red.ignored_channel_or_guild

* [partial] Discard command messages when channel is PartialMessageable

* [threads] Add utilities for checking appropriate perms in both channels & threads

* [threads] Update code to use can_react_in() and @bot_can_react()

* [threads] Update code to use can_send_messages_in

* [threads] Add send_messages_in_threads perm to mute role and overrides

* [threads] Update code to use (bot/user)_can_manage_channel

* [threads] Update [p]diagnoseissues to work with threads

* Type hint fix

* [threads] Patch vendored discord.ext.menus to check proper perms in threads

I guess we've reached time when we have to patch the lib we vendor...

* Make docs generation work with non-final d.py releases

* Update discord.utils.oauth_url() usage

* Swap usage of discord.Embed.Empty/discord.embeds.EmptyEmbed to None

* Update usage of Guild.member_count to work with `None`

* Switch from Guild.vanity_invite() to Guild.vanity_url

* Update startup process to work with d.py's new asynchronous startup

* Use setup_hook() for pre-connect actions

* Update core's add_cog, remove_cog, and load_extension methods

* Update all setup functions to async and add awaits to bot.add_cog calls

* Modernize cogs by using async cog_load and cog_unload

* Address StoreChannel removal

* [partial] Disallow passing PartialMessageable to Case.channel

* [partial] Update cogs and utils to work better with PartialMessageable

- Ignore messages with PartialMessageable channel in CustomCommands cog
- In Filter cog, don't pass channel to modlog.create_case()
  if it's PartialMessageable
- In Trivia cog, only compare channel IDs
- Make `.utils.menus.menu()` work for messages
  with PartialMessageable channel
- Make checks in `.utils.tunnel.Tunnel.communicate()` more rigid

* Add few missing DEP-WARNs
2022-04-03 03:21:20 +02:00
jack1142
c69e8d31fd Reformat with Black 22.1.0 2022-03-22 18:37:17 +01:00
Kowlin
faab711ec8
Ensure Nitro users can't make CCs that are too long (#5499)
* Ensure Nitro users can't make CCs that are too long

Co-authored-by: TrustyJAID <TrustyJAID@gmail.com>

* Tox formatting

* Update to account for edits and better handling of randoms

Co-authored-by: TrustyJAID <TrustyJAID@gmail.com>
2021-12-31 01:39:39 +01:00
jack1142
4b70acb989
Do not include expected wait_for responses in translated strings (#5364)
* Do not include 'I agree' prompt in translation string

* Add more stuff

* Address review comment

* Address review comments
2021-10-16 00:02:35 +02:00
Kreusada
8a6aa41d86
[CustomCommands/Docs] Fix argument name in [p]cc show command docstring (#5149)
* [CustomCom] Fix argument name in ``[p]cc show`` command docstring

* update docs
2021-06-18 17:48:46 -04:00
jack1142
1697d90c53
Stop shadowing variable in customcom's arg handling 2021-05-04 16:53:39 +02:00
bobloy
80f0a297a9
[Docs] CustomCommands Cog Guide (#4490)
* Add to index, url matching links, and add link to customcommands.rst

* Some docstring rewriting

* Adding arguments and more details.

* Handle aliases, rest of arguments and examples.

* Black formatting

* Switch to alphabetical

* Apparently forgot to regenerate this.

* Update redbot/cogs/customcom/customcom.py

Co-authored-by: Flame442 <34169552+Flame442@users.noreply.github.com>

* Update docs/cog_guides/customcommands.rst

Co-authored-by: Flame442 <34169552+Flame442@users.noreply.github.com>

Co-authored-by: Flame442 <34169552+Flame442@users.noreply.github.com>
2020-10-28 23:49:51 -04:00
Stonedestroyer
08bd0567ad
Grammar fixes (#4500)
* Grammar fixes

* More changes

* Grammar

* Error grammar

* Spelling

* Grammar

* REsolves grammar

* grammar

* grammar

* grammar

* grammar

* grammar

* grammar

* grammar

* grammar

* "commited" > "committed"

* apostrophe

* more grammar

* grammar

* `funtion` to `function`

* grammar in alias cog

* grammar in cleanup cog

* grammar in customcom cog

* grammar in mod cog

* grammar in reports cog

* fix grammar in streams cog

* missing apostrophe

* grammar fix in trivia cog

Co-authored-by: Jyu Viole Grace <24418520+thisisjvgrace@users.noreply.github.com>
Co-authored-by: Jyu Viole Grace <thisisjvgrace@users.noreply.github.com>
2020-10-18 08:52:56 +01:00
zephyrkul
7d66263948
[cc] don't send success on failure 2020-08-18 18:40:32 -06:00
zephyrkul
7d6662e6b1
[customcom] properly catch TimeoutErrors 2020-08-18 18:32:06 -06:00
Michael H
c0b1e50a5f
Begin work on a data request API (#4045)
[Core] Data Deletion And Disclosure APIs

 - Adds a Data Deletion API
   - Deletion comes in a few forms based on who is requesting
   - Deletion must be handled by 3rd party
 - Adds a Data Collection Disclosure Command
   - Provides a dynamically generated statement from 3rd party
   extensions
 - Modifies the always available commands to be cog compatible
   - Also prevents them from being unloaded accidentally
2020-08-03 15:09:07 +02:00
Twentysix
6c68aa9dcd
[CustomCom] [p]cc show - Handle missing cooldowns (#4112)
The old dataconverter didn't add cooldowns by default and `[p]cc show` expects them to be present
2020-07-29 02:48:50 +02:00
Michael H
1d80fe9aec
Create cog disabling API (#4043)
* create cog disbale base

* Because defaults...

* lol

* announcer needs to respect this

* defaultdict mishap

* Allow None as guild

- Mostly for interop with with ctx.guild

* a whitespace issue

* Apparently, I broke this too

* Apply suggestions from code review

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>

* This can probably be more optimized later, but since this is a cached value, it's not a large issue

* Report tunnel closing

* mod too

* whitespace issue

* Fix Artifact of prior method naming

* these 3 places should have the check if i understood it correctly

* Announce the closed tunnels

* tunnel oversight

* Make the player stop at next track

* added where draper said to put it

* Apply suggestions from code review

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
Co-authored-by: Drapersniper <27962761+drapersniper@users.noreply.github.com>
2020-07-28 20:52:36 +02:00
Ryan
6ab007bc1d
[CustomCom] Add missing await (#4108) 2020-07-23 23:37:31 +02:00
Flame442
1a96f276f8
Fix typo in [p]customcom show (#3837) 2020-05-08 16:48:35 +02:00
Neuro Assassin
4a0f23b0ea
Stop allowing spaces in custom commands names (#3816) 2020-05-01 18:32:22 +02:00
Michael H
d5c960096e
Modify CustomCommands to use on_message_without_command (#3811) 2020-05-01 18:30:32 +02:00
Neuro Assassin
00d20f14b9
Add [p]cc raw command giving raw (escaped) response (#3795) 2020-04-27 01:31:43 +02:00
Neuro Assassin
9370b5110e
Add [p]cc search command (#2573)
* Add search command for Custom Commands

* Spelling mistake

* Create 2573.feature.rst

* Remove `bot.db` usage, improve returned message

* remove towncrier entry

* Fix CI errors

* Fix more CI errors

* Add `@staticmethod` decorator

Co-authored-by: Toby Harradine <Tobotimus@users.noreply.github.com>
Co-authored-by: Michael H <michael@michaelhall.tech>
Co-authored-by: Kowlin <Kowlin@users.noreply.github.com>
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
2020-03-28 02:11:36 +01:00
jack1142
eedec4ff02
fix: use clean prefix in code blocks (#3591) 2020-02-28 21:23:13 +01:00
Stonedestroyer
7f390df879 [Customcom] Fix error on exiting customcom interactive menu. (#3417)
* [Customcom] Fixes error on exit

* Changelog

* Fixed spelling.

* Typehinting
2020-01-19 18:08:31 +01:00
zephyrkul
45860ca2a6 [CustomCom] Use humanize_list for iterable arguments (#3277)
* [cc] use humanize_list on lists

* [cc] need classmethod

* add changelog
2020-01-06 16:49:08 -05:00
jack1142
62b679b1b9 Replace links to v3-develop docs with links to stable docs (#3186)
* Update customcom.py

* Update permissions.py

* Create 3186.docs.rst

* Create 3186.docs.rst

* Rename 3186.docs.rst to 3186.misc.rst

* Rename 3186.docs.rst to 3186.misc.rst
2020-01-02 08:48:33 -05:00
zephyrkul
60a1b3294d [CustomCom] add Query typehint for URI-based CCs (#3228)
* [cc] add Query typehint for URI query ccs

* Create 3228.enhance.rst
2019-12-27 11:43:25 -05:00
Michael H
83483abfa5
Reserves command names (#2977)
* Reserves command names

  - Currently, only reserving ``cancel``
  - This should only impact matching command qualified names
  - This also checks aliases
  - This makes cc and alias use the new module constant with info about
  this
  - Module constant is available for use by 3rd party cogs which may
  dynamically create responses.

* Change misleading var name

* style

* Thanks Flame!

* Handles issues with CC
2019-09-28 16:58:40 -04:00
Flame442
b9ed8b84f5 [CustomCom] Use simple by default (#3013)
* Allow creating simple CCs by default

* Create 3013.rst

* Screwed up the filename
2019-09-28 02:46:40 -04:00
Toby Harradine
3de9d15410
[CustomCom] Set Requires.ready_event before invoking CC (#2876)
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2019-07-15 20:13:06 +10:00
DevilXD
f894b62bfe [CustomCom] Fixed KeyError on specific message edge-case (#2739)
fixes #2679
2019-05-29 22:36:32 -04:00
Neuro Assassin
2e271d695b Add respectable aliases for consistency (#2731)
* Add respectable aliases for consistency

* General command name for alias.py

* Forgot one for alias

* General command for filter

* General command for warnings

* Whoops

Resolves #1749
2019-05-24 18:22:17 -04:00
Will
c58f566047 [CustomCom] Update command generator to work with dpy update (#2616)
* I think this works?

* Let's do it

Co-Authored-By: tekulvw <tekulvw@users.noreply.github.com>
2019-04-25 12:31:58 -04:00
Michael H
ad114295e7
Discord.py dep update 3.1 (#2587)
* Dependency update

discord.py==1.0.1
websockets<7

[style]
black==19.3b0

[Docs]
jinja==2.10.1
urllib3==1.24.2

Changes related to breaking changes from discord.py have also been made
to match

As of this commit, help formatter is back to discord.py's default
2019-04-23 21:40:38 -04:00
Toby Harradine
628073cbe1
Update Translations (#2486)
Also included a Makefile recipe which makes use of the Crowdin CLI's `crowdin download` command. This requires whoever is using it to provide the project's API key in an environment variable, but we may automate this at some point.

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2019-03-04 08:55:01 +11:00
Toby Harradine
e07408161a Merge branch 'V3/release/3.0.0' into V3/develop
# Conflicts:
#	redbot/cogs/mod/mod.py
2019-01-11 16:42:42 +11:00
Toby Harradine
aa854cf1f9 [CustomCom] Insert space before newline separating CC previews (#2350)
Resolves #2295.

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-12-29 16:54:32 +01:00
Toby Harradine
8b4e12da81 Merge branch 'V3/release/3.0.0' into V3/develop
# Conflicts:
#	redbot/cogs/customcom/customcom.py
#	redbot/core/errors.py
2018-10-16 09:42:38 +11:00
Toby Harradine
b5fd28ef7c
[CustomCom] Better display for [p]cc list (#2215)
Uses a menu, optionally embedded with respect to the embed settings, for scrolling through the custom command list, each cc with a ~50 character preview. Format is purposefully similar to the help menu.

Resolves #2104.

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-10-16 08:39:44 +11:00
Toby Harradine
ad51fa830b
[Cleanup] [p]cleanup bot includes aliases and CCs (#2213)
Resolves #1920.

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-10-15 22:29:07 +11:00
Twentysix
c464f5e7dc [CustomCommands] Add [p]cc show (#2204) 2018-10-10 10:27:25 +11:00
Toby Harradine
847f9fc8d1
[CustomCommands] Find default converters properly (#2199)
The new `redbot.core.commands.converter` module was causing default converters to never be found.

Also cleaned up some of the other code (made some methods static, fixed some typing violations)

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-10-07 12:58:08 +11:00
Toby Harradine
fa692ccc0b [i18n] Pass over economy, filter, general, image, mod
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-10-06 09:00:31 +10:00
Toby Harradine
0c3d8af8f4 [i18n] Pass over bank, cleanup, customcom, dataconverter, downloader
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-10-06 08:57:49 +10:00
Michael H
aa8c9c350e [i18n] Start work on named format arguments (#1795) 2018-10-06 08:42:38 +10:00
Toby Harradine
dea9dde637
[Utils] Finish and Refactor Predicate Utility (#2169)
* Uses classmethods to create predicates
* Classmethods allow using a combination of different parameters to describe context
* Some predicates assign a captured `result` to the predicate object on success
* Added `ReactionPredicate` equivalent to `MessagePredicate`
* Added `utils.menus.start_adding_reactions`, a non-blocking method for adding reactions asynchronously
* Added documentation
* Uses these new utils throughout the core bot
Happened to also find some bugs in places, and places where we were waiting for events without catching `asyncio.TimeoutError`

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-10-06 08:07:09 +10:00