mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
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:
parent
34fe88da29
commit
e1226c6c88
@ -300,7 +300,7 @@ def handle_edit(cli_flags: Namespace):
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
data_manager.load_basic_configuration(cli_flags.instance_name)
|
||||
red = Red(cli_flags=cli_flags, description="Red V3", dm_help=None, fetch_offline_members=True)
|
||||
red = Red(cli_flags=cli_flags, description="Red V3", dm_help=None)
|
||||
try:
|
||||
driver_cls = drivers.get_driver_class()
|
||||
loop.run_until_complete(driver_cls.initialize(**data_manager.storage_details()))
|
||||
@ -391,6 +391,13 @@ async def run_bot(red: Red, cli_flags: Namespace) -> None:
|
||||
print("Token has been reset.")
|
||||
sys.exit(0)
|
||||
sys.exit(1)
|
||||
except discord.PrivilegedIntentsRequired:
|
||||
print(
|
||||
"Red requires all Privileged Intents to be enabled.\n"
|
||||
"You can find out how to enable Privileged Intents with this guide:\n"
|
||||
"https://docs.discord.red/en/stable/bot_application_guide.html#enabling-privileged-intents"
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
return None
|
||||
|
||||
@ -487,9 +494,7 @@ def main():
|
||||
|
||||
data_manager.load_basic_configuration(cli_flags.instance_name)
|
||||
|
||||
red = Red(
|
||||
cli_flags=cli_flags, description="Red V3", dm_help=None, fetch_offline_members=True
|
||||
)
|
||||
red = Red(cli_flags=cli_flags, description="Red V3", dm_help=None)
|
||||
|
||||
if os.name != "nt":
|
||||
# None of this works on windows.
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
@ -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,
|
||||
)
|
||||
|
||||
@ -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 = (
|
||||
|
||||
@ -44,7 +44,7 @@ install_requires =
|
||||
click==7.1.2
|
||||
colorama==0.4.3
|
||||
contextlib2==0.6.0.post1
|
||||
discord.py==1.4.1
|
||||
discord.py==1.5.1
|
||||
distro==1.5.0; sys_platform == "linux"
|
||||
fuzzywuzzy==0.18.0
|
||||
idna==2.10
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
import inspect
|
||||
|
||||
import pytest
|
||||
from discord.ext import commands as dpy_commands
|
||||
|
||||
from redbot.core import commands
|
||||
|
||||
|
||||
@ -32,3 +36,16 @@ def test_group_decorator_methods(group, coroutine):
|
||||
def test_bot_decorator_methods(red, coroutine):
|
||||
assert is_Command(red.command(name="cmd")(coroutine))
|
||||
assert is_Group(red.group(name="grp")(coroutine))
|
||||
|
||||
|
||||
def test_dpy_commands_reexports():
|
||||
dpy_attrs = set()
|
||||
for attr_name, attr_value in dpy_commands.__dict__.items():
|
||||
if attr_name.startswith("_") or inspect.ismodule(attr_value):
|
||||
continue
|
||||
|
||||
dpy_attrs.add(attr_name)
|
||||
|
||||
missing_attrs = dpy_attrs - set(commands.__dict__.keys())
|
||||
|
||||
assert not missing_attrs
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user