Update to d.py 1.5.1, explicitly request privileged intents (#4423)

Co-authored-by: Draper <27962761+Drapersniper@users.noreply.github.com>
This commit is contained in:
jack1142
2020-10-21 20:55:25 +02:00
committed by GitHub
parent 34fe88da29
commit e1226c6c88
8 changed files with 69 additions and 6 deletions

View File

@@ -500,7 +500,8 @@ async def bank_prune(bot: Red, guild: discord.Guild = None, user_id: int = None)
group = _config._get_base_group(_config.MEMBER, str(guild.id))
if user_id is None:
await bot.request_offline_members(*_guilds)
for _guild in _guilds:
await _guild.chunk()
accounts = await group.all()
tmp = accounts.copy()
members = bot.get_all_members() if global_bank else guild.members

View File

@@ -172,6 +172,12 @@ class RedBase(
if "owner_id" in kwargs:
raise RuntimeError("Red doesn't accept owner_id kwarg, use owner_ids instead.")
if "intents" not in kwargs:
intents = discord.Intents.all()
for intent_name in cli_flags.disable_intent:
setattr(intents, intent_name, False)
kwargs["intents"] = intents
self._owner_id_overwrite = cli_flags.owner
if "owner_ids" in kwargs:

View File

@@ -4,6 +4,7 @@ import logging
import sys
from typing import Optional
import discord
from discord import __version__ as discord_version
@@ -236,6 +237,18 @@ def parse_cli_flags(args):
parser.add_argument(
"--no-message-cache", action="store_true", help="Disable the internal message cache."
)
parser.add_argument(
"--disable-intent",
action="append",
choices=list(discord.Intents.VALID_FLAGS), # DEP-WARN
default=[],
help="Unsupported flag that allows disabling the given intent."
" Currently NOT SUPPORTED (and not covered by our version guarantees)"
" as Red is not prepared to work without all intents.\n"
f"Go to https://discordpy.readthedocs.io/en/v{discord_version}/api.html#discord.Intents"
" to see what each intent does.\n"
"This flag can be used multiple times to specify multiple intents.",
)
args = parser.parse_args(args)

View File

@@ -127,6 +127,7 @@ from discord.ext.commands import (
Greedy as Greedy,
ExpectedClosingQuoteError as ExpectedClosingQuoteError,
ColourConverter as ColourConverter,
ColorConverter as ColorConverter,
VoiceChannelConverter as VoiceChannelConverter,
NSFWChannelRequired as NSFWChannelRequired,
IDConverter as IDConverter,
@@ -145,4 +146,15 @@ from discord.ext.commands import (
MaxConcurrencyReached as MaxConcurrencyReached,
bot_has_guild_permissions as bot_has_guild_permissions,
CommandRegistrationError as CommandRegistrationError,
MessageNotFound as MessageNotFound,
MemberNotFound as MemberNotFound,
UserNotFound as UserNotFound,
ChannelNotFound as ChannelNotFound,
ChannelNotReadable as ChannelNotReadable,
BadColourArgument as BadColourArgument,
RoleNotFound as RoleNotFound,
BadInviteArgument as BadInviteArgument,
EmojiNotFound as EmojiNotFound,
PartialEmojiConversionFailure as PartialEmojiConversionFailure,
BadBoolArgument as BadBoolArgument,
)

View File

@@ -2579,6 +2579,14 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
osver = "Could not parse OS, report this on Github."
user_who_ran = getpass.getuser()
driver = storage_type()
disabled_intents = (
", ".join(
intent_name.replace("_", " ").title()
for intent_name, enabled in self.bot.intents
if not enabled
)
or "None"
)
if await ctx.embed_requested():
e = discord.Embed(color=await ctx.embed_colour())
e.title = "Debug Info for Red"
@@ -2595,6 +2603,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
inline=False,
)
e.add_field(name="Storage type", value=driver, inline=False)
e.add_field(name="Disabled intents", value=disabled_intents, inline=False)
await ctx.send(embed=e)
else:
info = (