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

764 lines
13 KiB
ReStructuredText

.. _mod:
===
Mod
===
This is the cog guide for the mod cog. You will
find detailed docs about usage and commands.
``[p]`` is considered as your prefix.
.. note:: To use this cog, load it by typing this::
[p]load mod
.. _mod-usage:
-----
Usage
-----
A range of highly customizable moderation tools used to protect your
guild from users who cannot follow the rules.
.. _mod-commands:
--------
Commands
--------
.. _mod-command-ban:
^^^
ban
^^^
.. note:: |admin-lock|
**Syntax**
.. code-block:: none
[p]ban <user> [days] [reason]
**Description**
Ban a user from this server and optionally delete days of messages.
``days`` is the amount of days of messages to cleanup on ban.
**Arguments**
* ``<user>``: The user to ban. |user-input|
* ``[days]``: The amount of days of messages to cleanup on ban. This parameter defaults to the defaultdays setting, or no days if this has not yet been configured.
* ``[reason]``: The reason why the user was banned (optional).
**Example Usage**
* ``[p]ban 428675506947227648 7 Continued to spam after told to stop.``
This will ban the user with ID 428675506947227648 and it will delete 7 days worth of messages.
* ``[p]ban @Twentysix 7 Continued to spam after told to stop.``
This will ban Twentysix and it will delete 7 days worth of messages.
A user ID should be provided if the user is not a member of this server.
If days is not a number, it's treated as the first word of the reason.
Minimum 0 days, maximum 7. If not specified, the defaultdays setting will be used instead.
.. _mod-command-kick:
^^^^
kick
^^^^
.. note:: |admin-lock|
**Syntax**
.. code-block:: none
[p]kick <member> [reason]
**Description**
Kick a user.
**Arguments**
* ``<member>``: The member to kick. |member-input|
* ``[reason]``: The reason why the user was kicked (optional).
**Example Usage**
* ``[p]kick 428675506947227648 wanted to be kicked.``
This will kick the user with ID 428675506947227648 from the server.
* ``[p]kick @Twentysix wanted to be kicked.``
This will kick Twentysix from the server.
If a reason is specified, it will be the reason that shows up
in the audit log.
.. _mod-command-massban:
^^^^^^^
massban
^^^^^^^
.. note:: |admin-lock|
**Syntax**
.. code-block:: none
[p]massban <user_ids...> [days] [reason]
.. tip:: Alias: ``hackban``
**Description**
Mass bans user(s) from the server.
**Arguments**
* ``<user_ids...>``: The users to ban. This must be a list of user IDs separated by spaces.
* ``[days]``: The amount of days of messages to cleanup on massban.
* ``[reason]``: The reason why these users were banned.
**Example Usage**
* ``[p]massban 345628097929936898 57287406247743488 7 they broke all rules.``
This will ban all the added userids and delete 7 days worth of their messages.
.. _mod-command-modset:
^^^^^^
modset
^^^^^^
.. note:: |guildowner-lock|
**Syntax**
.. code-block:: none
[p]modset
**Description**
Manage server administration settings.
.. _mod-command-modset-defaultdays:
""""""""""""""""""
modset defaultdays
""""""""""""""""""
**Syntax**
.. code-block:: none
[p]modset defaultdays [days=0]
**Description**
Set the default number of days worth of messages to be deleted when a user is banned.
The number of days must be between 0 and 7.
**Arguments**
* ``[days=0]``: The default number of days of messages to be deleted when a user is banned.
.. note:: This value must be between 0 and 7.
.. _mod-command-modset-defaultduration:
""""""""""""""""""""""
modset defaultduration
""""""""""""""""""""""
**Syntax**
.. code-block:: none
[p]modset defaultduration <duration>
**Description**
Set the default time to be used when a user is tempbanned.
Accepts: seconds, minutes, hours, days, weeks
**Arguments**
* ``<duration>``: The default duration for when a user is temporarily banned. Accepts seconds, minutes, hours, days or weeks.
**Example Usage**
* ``[p]modset defaultduration 7d12h10m``
* ``[p]modset defaultduration 7 days 12 hours 10 minutes``
.. _mod-command-modset-deletenames:
""""""""""""""""""
modset deletenames
""""""""""""""""""
.. note:: |owner-lock|
**Syntax**
.. code-block:: none
[p]modset deletenames [confirmation=False]
**Description**
Delete all stored usernames and nicknames.
**Arguments**
- ``<confirmation>``: Whether to delete all stored usernames and nicknames. |bool-input|
.. _mod-command-modset-deleterepeats:
""""""""""""""""""""
modset deleterepeats
""""""""""""""""""""
**Syntax**
.. code-block:: none
[p]modset deleterepeats [repeats]
**Description**
Enable auto-deletion of repeated messages.
**Arguments**
* ``[repeats]``: The number of repeated messages needed before further messages are deleted.
.. note:: Must be between 2 and 20. Set to -1 to disable this feature.
.. _mod-command-modset-dm:
"""""""""
modset dm
"""""""""
**Syntax**
.. code-block:: none
[p]modset dm [enabled]
**Description**
Toggle whether a message should be sent to a user when they are kicked/banned.
If this option is enabled, the bot will attempt to DM the user with the guild name
and reason as to why they were kicked/banned.
**Arguments**
* ``[enabled]``: Whether a message should be sent to a user when they are kicked/banned. |bool-input|
.. _mod-command-modset-hierarchy:
""""""""""""""""
modset hierarchy
""""""""""""""""
**Syntax**
.. code-block:: none
[p]modset hierarchy
**Description**
Toggle role hierarchy check for mods and admins.
.. warning:: Disabling this setting will allow mods to take actions on users above them in the role hierarchy!
This is enabled by default.
.. _mod-command-modset-mentionspam:
""""""""""""""""""
modset mentionspam
""""""""""""""""""
**Syntax**
.. code-block:: none
[p]modset mentionspam
**Description**
Manage the automoderation settings for mentionspam.
.. _mod-command-modset-mentionspam-ban:
""""""""""""""""""""""
modset mentionspam ban
""""""""""""""""""""""
**Syntax**
.. code-block:: none
[p]modset mentionspam ban <max_mentions>
**Description**
Set the autoban conditions for mention spam.
Users will be banned if they send any message which contains more than
``<max_mentions>`` mentions.
**Arguments**
* ``<max_mentions>``: Must be 0 or greater. Set to 0 to disable this feature.
.. _mod-command-modset-mentionspam-kick:
"""""""""""""""""""""""
modset mentionspam kick
"""""""""""""""""""""""
**Syntax**
.. code-block:: none
[p]modset mentionspam kick <max_mentions>
**Description**
Set the autokick conditions for mention spam.
Users will be kicked if they send any message which contains more than
``<max_mentions>`` mentions.
**Arguments**
* ``<max_mentions>``: Must be 0 or greater. Set to 0 to disable this feature.
.. _mod-command-modset-mentionspam-strict:
"""""""""""""""""""""""""
modset mentionspam strict
"""""""""""""""""""""""""
**Syntax**
.. code-block:: none
[p]modset mentionspam strict [enabled]
**Description**
Setting to account for duplicate mentions.
If enabled all mentions will count including duplicated mentions.
If disabled only unique mentions will count.
Use this command without any parameter to see the current setting.
**Arguments**
* ``[enabled]``: Whether all mentions will count, including duplicated mentions. |bool-input|
.. _mod-command-modset-mentionspam-warn:
"""""""""""""""""""""""
modset mentionspam warn
"""""""""""""""""""""""
**Syntax**
.. code-block:: none
[p]modset mentionspam warn <max_mentions>
**Description**
Sets the autowarn conditions for mention spam.
Users will be warned if they send any messages which contain more than
``<max_mentions>`` mentions.
**Arguments**
* ``<max_mentions>``: Must be 0 or greater. Set to 0 to disable this feature.
.. _mod-command-modset-reinvite:
"""""""""""""""
modset reinvite
"""""""""""""""
**Syntax**
.. code-block:: none
[p]modset reinvite
**Description**
Toggle whether an invite will be sent to a user when unbanned.
If this is True, the bot will attempt to create and send a single-use invite
to the newly-unbanned user.
.. _mod-command-modset-showsettings:
"""""""""""""""""""
modset showsettings
"""""""""""""""""""
**Syntax**
.. code-block:: none
[p]modset showsettings
**Description**
Show the current server administration settings.
.. _mod-command-modset-trackallnames:
""""""""""""""""""""
modset trackallnames
""""""""""""""""""""
.. note:: |owner-lock|
**Syntax**
.. code-block:: none
[p]modset trackallnames [enabled]
**Description**
Toggle whether all name changes should be tracked.
Toggling this off also overrides the tracknicknames setting.
**Arguments**
* ``[enabled]``: Whether all name changes should be tracked. |bool-input|
.. _mod-command-modset-tracknicknames:
"""""""""""""""""""""
modset tracknicknames
"""""""""""""""""""""
**Syntax**
.. code-block:: none
[p]modset tracknicknames [enabled]
**Description**
Toggle whether nickname changes should be tracked.
This setting will be overridden if trackallnames is disabled.
**Arguments**
* ``[enabled]``: Whether all nickname changes should be tracked. |bool-input|
.. _mod-command-movedeletedelay:
^^^^^^^^^^^^^^^
movedeletedelay
^^^^^^^^^^^^^^^
.. note:: |owner-lock|
**Syntax**
.. code-block:: none
[p]movedeletedelay
**Description**
Move deletedelay settings to core
.. _mod-command-moveignoredchannels:
^^^^^^^^^^^^^^^^^^^
moveignoredchannels
^^^^^^^^^^^^^^^^^^^
.. note:: |owner-lock|
**Syntax**
.. code-block:: none
[p]moveignoredchannels
**Description**
Move ignored channels and servers to core
.. _mod-command-names:
^^^^^
names
^^^^^
**Syntax**
.. code-block:: none
[p]names <member>
**Description**
Show previous names and nicknames of a member.
**Arguments**
* ``<member>``: |member-input|
.. _mod-command-rename:
^^^^^^
rename
^^^^^^
.. note:: |admin-lock|
**Syntax**
.. code-block:: none
[p]rename <member> [nickname]
**Description**
Change a member's nickname.
Leaving the nickname empty will remove it.
**Arguments**
* ``<member>``: |member-input|
* ``[nickname]``: The new nickname for the member.
.. _mod-command-slowmode:
^^^^^^^^
slowmode
^^^^^^^^
.. note:: |admin-lock|
**Syntax**
.. code-block:: none
[p]slowmode [interval=0:00:00]
**Description**
Changes thread's or channel's slowmode setting.
Interval can be anything from 0 seconds to 6 hours.
Use without parameters to disable.
**Arguments**
* ``[interval=0:00:00]``: The time for the thread's/channel's slowmode settings.
.. note::
Interval can be anything from 0 seconds to 6 hours.
Use without parameters to disable.
.. _mod-command-softban:
^^^^^^^
softban
^^^^^^^
.. note:: |admin-lock|
**Syntax**
.. code-block:: none
[p]softban <member> [reason]
**Description**
Kick a member and delete 1 day's worth of their messages.
**Arguments**
* ``<member>``: The member to softban. |member-input-quotes|
* ``[reason]``: Reason for the kick (optional).
.. _mod-command-tempban:
^^^^^^^
tempban
^^^^^^^
.. note:: |admin-lock|
**Syntax**
.. code-block:: none
[p]tempban <member> [duration] [days] [reason]
**Description**
Temporarily ban a user from this server.
**Arguments**
* ``<member>``: The member to temporarily ban. |member-input-quotes|
* ``[duration]``: The amount of time the user should be banned for.
* ``[days]``: The amount of days of messages to cleanup on tempban.
* ``[reason]``: The reason for the tempban (optional).
**Example Usage**
* ``[p]tempban @Twentysix Because I say so``
This will ban Twentysix for the default amount of time set by an administrator.
* ``[p]tempban @Twentysix 15m You need a timeout``
This will ban Twentysix for 15 minutes.
* ``[p]tempban 428675506947227648 1d2h15m 5 Evil person``
This will ban the user with ID 428675506947227648 for 1 day 2 hours 15 minutes and will delete the last 5 days of their messages.
.. _mod-command-unban:
^^^^^
unban
^^^^^
.. note:: |admin-lock|
**Syntax**
.. code-block:: none
[p]unban <user_id> [reason]
**Description**
Unban a user from this server.
**Arguments**
* ``<user_id>``: |user-input|
* ``[reason]``: The reason for the unban (optional).
.. _mod-command-userinfo:
^^^^^^^^
userinfo
^^^^^^^^
**Syntax**
.. code-block:: none
[p]userinfo [member]
**Description**
Show information about a user.
This includes fields for status, discord join date, server
join date, voice state and previous names/nicknames.
If the user has no roles, previous names or previous nicknames,
these fields will be omitted.
**Arguments**
* ``[member]``: |member-input|
.. _mod-command-voiceban:
^^^^^^^^
voiceban
^^^^^^^^
.. note:: |admin-lock|
**Syntax**
.. code-block:: none
[p]voiceban <member> [reason]
**Description**
Ban a user from speaking and listening in the server's voice channels.
**Arguments**
* ``<member>``: The member to ban from voice. |member-input|
* ``[reason]``: The reason for the voiceban (optional).
.. _mod-command-voicekick:
^^^^^^^^^
voicekick
^^^^^^^^^
.. note:: |mod-lock|
**Syntax**
.. code-block:: none
[p]voicekick <member> [reason]
**Description**
Kick a member from a voice channel.
**Arguments**
* ``<member>``: |member-input|
* ``[reason]``: The reason for the voicekick (optional).
.. _mod-command-voiceunban:
^^^^^^^^^^
voiceunban
^^^^^^^^^^
.. note:: |admin-lock|
**Syntax**
.. code-block:: none
[p]voiceunban <member> [reason]
**Description**
Unban a user from speaking and listening in the server's voice channels.
**Arguments**
* ``<member>``: The member to unban from voice. |member-input-quotes|
* ``[reason]``: The reason for the voiceunban (optional).