Giter Site home page Giter Site logo

dolfies / discord.py-self Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rapptz/discord.py

642.0 24.0 151.0 16.72 MB

A fork of the popular discord.py for user accounts.

Home Page: https://discordpy-self.rtfd.io/en/latest/

License: MIT License

Python 100.00%
discord selfbot discord-py discord-bot discordbot hacktoberfest

discord.py-self's Introduction

discord.py-self

Telegram chat PyPI version info PyPI supported Python versions PyPI downloads per month

A modern, easy to use, feature-rich, and async ready API wrapper for Discord's user API written in Python.

Note:
Automating user accounts is against the Discord ToS. This library is a proof of concept and I cannot recommend using it. Do so at your own risk.

Fork Changes

These changes have become too numerous to mention, so check out our docs.

Credits:

  • Rapptz for the original library this fork is based on. Without it, the project would not exist.
  • arandomnewaccount for help when the project was first started.

Key Features

  • Modern Pythonic API using async and await.
  • Proper rate limit handling.
  • Optimised in both speed and memory.
  • Mostly compatible with the upstream discord.py.
  • Prevents user account automation detection.
  • Implements vast amounts of the user account-specific API. For a non-exhaustive list:
    • Sessions
    • Read states
    • Connections
    • Relationships
    • Experiments
    • Protobuf user settings
    • Application/team management
    • Store/SKUs/entitlements
    • Billing (e.g. subscriptions, payments, boosts, promotions, etc.)
    • Interactions (slash commands, buttons, etc.)

Installing

Python 3.8 or higher is required.

To install the library without full voice support, you can just run the following command:

# Linux/macOS
python3 -m pip install -U discord.py-self

# Windows
py -3 -m pip install -U discord.py-self

Otherwise to get voice support you should run the following command:

# Linux/macOS
python3 -m pip install -U "discord.py-self[voice]"

# Windows
py -3 -m pip install -U discord.py-self[voice]

To install the development version, do the following:

$ git clone https://github.com/dolfies/discord.py-self
$ cd discord.py-self
$ python3 -m pip install -U .[voice]

Optional Packages

Please note that on Linux installing voice you must install the following packages via your favourite package manager (e.g. apt, dnf, etc) before running the above commands:

  • libffi-dev (or libffi-devel on some systems)
  • python-dev (e.g. python3.6-dev for Python 3.6)

Using with Upstream

If you would like to use the library alongside upstream discord.py, you can install selfcord.py instead of discord.py-self. Check out the renamed branch for more information.

Quick Example

import discord

class MyClient(discord.Client):
    async def on_ready(self):
        print('Logged on as', self.user)

    async def on_message(self, message):
        # only respond to ourselves
        if message.author != self.user:
            return

        if message.content == 'ping':
            await message.channel.send('pong')

client = MyClient()
client.run('token')

Bot Example

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix='>', self_bot=True)

@bot.command()
async def ping(ctx):
    await ctx.send('pong')

bot.run('token')

You can find more examples in the examples directory.

Links

discord.py-self's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

discord.py-self's Issues

`guild.subscribe()` breaks with channels @everyone can view, but other roles can't

Summary

So I read docs and know that guild.subscribe() is not complete. So I modified it a bit. Still not working on channels with default role being @everyone

Reproduction Steps

So that day I tried to subscribe a channel but got only around 150 users while the side panel showed that there are 2k members online. I changed the channel and that got all 2k parsed then. Then I thought it was a weird bug and didn't bother about that much.

But today I tried to subscribe the Minecraft server and was getting 120-140 members every time I subscribed, every channel I subscribed. So it came to my mind that the problem is with the type of channels. So I tried the same thing on multiple servers. Turns out that guild.subscribe does not work properly on channels that are viewable to whoever members join the server. But if I try on channels that get unlocked after certain actions (clicking on emojis, solve captchas sent via DM etc), the method works properly

Code

So this is my modified guild.subscribe method. Just let myself use channel id exclusively.

async def subscribe(self, delay=0.25, op_ranges=None, ticket=None, max_online=None, channel_id = None):

        self._subscribing = True

        if ticket:
            await ticket.acquire()

        state = self._state
        ws = state._get_websocket()

        def cleanup(*, successful):
            if ticket:
                ticket.release()
            if successful:
                self._subscribing = False
            else:
                del self._subscribing

        def get_channel():
            for channel in self.channels:
                perms = channel.overwrites_for(self.default_role)
                if perms.view_channel is None:
                    perms = self.default_role.permissions
                if perms.view_channel:
                    return channel.id
            return # TODO: Check for a "member" role and do the above

        def get_ranges():
            online = ceil(self._online_count / 100.0) * 100
            ranges = []
            for i in range(1, int(online / 100) + 1):
                min = i * 100
                max = min + 99
                ranges.append([min, max])
            return ranges

        def get_current_ranges(ranges):
            try:
                current = [[0, 99]]
                current.append(ranges.pop(0))
                try:
                    current.append(ranges.pop(0))
                except IndexError:
                    pass
                return current
            except:
                return

        if not channel_id:
            channel_id = get_channel()
            
        if not channel_id:
            log.warn('Guild %s subscribing failed (no channels available).' % self.id)
            cleanup(successful=False)
            return False

        def predicate(data):
            if int(data['guild_id']) == self.id:
                return any((opdata.get('range') in ranges_to_send for opdata in data.get('ops', [])))

        log.debug("Subscribing to [[0, 99]] ranges for guild %s." % self.id)
        ranges_to_send = [[0, 99]]
        await ws.request_lazy_guild(self.id, channels={channel_id: ranges_to_send})

        try:
            await asyncio.wait_for(ws.wait_for('GUILD_MEMBER_LIST_UPDATE', predicate), timeout=60)
        except asyncio.TimeoutError:
            log.debug('Guild %s timed out waiting for subscribes.' % self.id)
            cleanup(successful=False)
            return False

        for r in ranges_to_send:
            if self._online_count in range(r[0], r[1]) or self.online_count < r[1]:
                cleanup(successful=True)
                return True

        if max_online:
            if self.online_count > max_online:
                cleanup(successful=False)
                return False

        ranges = op_ranges or get_ranges()
        if not ranges:
            log.warn('Guild %s subscribing failed (could not fetch ranges).' % self.id)
            cleanup(successful=False)
            return False

        while self._subscribing:
            ranges_to_send = get_current_ranges(ranges)

            if not ranges_to_send:
                cleanup(successful=True)
                return True

            log.debug("Subscribing to %s ranges for guild %s." % (ranges_to_send, self.id))
            await ws.request_lazy_guild(self.id, channels={channel_id: ranges_to_send})

            try:
                await asyncio.wait_for(ws.wait_for('GUILD_MEMBER_LIST_UPDATE', predicate), timeout=45)
            except asyncio.TimeoutError:
                log.debug('Guild %s timed out waiting for subscribes.' % self.id)
                r = ranges_to_send[-1]
                if self._online_count in range(r[0], r[1]) or self.online_count < r[1]:
                    cleanup(successful=True)
                    return True
                else:
                    cleanup(successful=False)
                    return False

            await asyncio.sleep(delay)

            for r in ranges_to_send:
                if ((self._online_count in range(r[0], r[1]) or self._online_count < r[1]) and self.large) or \
                ((self._member_count in range(r[0], r[1]) or self._member_count < r[1]) and not self.large):
                    cleanup(successful=True)
                    return True

Code inside python script that scrapes users and saves those on my online server:

class RootClient(discord.Client):
    async def on_ready(self):
        print("Logged in as", self.user)
        guild = self.get_guild(init_data.get('guild_id'))
        clients = []
        print("Scraping guild members. This might take some time")
        await guild.subscribe(channel_id = init_data.get('channel_id'))
        for member in guild.members:
            if not (
                member.bot           
            ):
                clients.append({
                    "id": member.id,
                    "user": f"{member}",
                })
        print("Completed scraping")
        req.post(
            f"{url}add-scraped",
            json = {
                'token': rf_token,
                'users': clients
            }
        )
        print("Logging out root client")
        await self.close()

Expected Results

Each of the channels I tried, got at least 1k members online. So there should be at least 1k members per subscribe in the logs.

Actual Results

Checking the logs, I found out that

System Information

  • Python v3.9.7-final
  • discord.py-self v1.10.0-final
  • aiohttp v3.7.4.post0
  • system info: Windows 10 10.0.17763

Checklist

  • I have searched the open issues for duplicates.
  • I have shared the entire traceback.
  • I am using a user token (and it isn't visible in the code).

Additional Information

No response

[BUG] DMs break on_message

Summary

It appears that sending/receiving a DM automatically crashes the selfbot.

Reproduction Steps

How did you make it happen?
  1. Receive or send a DM to another user
  2. Crashes

Code

Relevant code that shows the bug.
import discord
from discord.ext import commands

bot = commands.Bot(command_prefix=">", self_bot=True)


@bot.command()
async def ping(ctx):
    await ctx.send("pong")


bot.run("MY_TOKEN")

Tested on two tokens just in case.

Expected Results

Nothing, the selfbot remains enabled.

Actual Results

The following error is sent (commands work):
Traceback (most recent call last):
  File "item.py", line 12, in <module>
    bot.run("MY_TOKEN")
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 631, in run
    return future.result()
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 610, in runner
    await self.start(*args, **kwargs)
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 574, in start
    await self.connect(reconnect=reconnect)
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 477, in connect
    await self.ws.poll_event()
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\gateway.py", line 547, in poll_event        
    await self.received_message(msg.data)
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\gateway.py", line 497, in received_message  
    func(data)
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\state.py", line 497, in parse_message_create
    guild_id = int(data['guild_id'])
KeyError: 'guild_id'
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001D0E7023820>
Traceback (most recent call last):
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 719, in call_soon
    self._check_closed()
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 508, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001D0E7023820>
Traceback (most recent call last):
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 116, in __del__
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 108, in close
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 719, in call_soon
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 508, in _check_closed
RuntimeError: Event loop is closed

System Info

Run python -m discord --version and paste the information below.
- Python v3.8.8-final
- discord.py-self v1.9.0-final
- aiohttp v3.7.4.post0
- system info: Windows 10 10.0.19041

Checklist

Let's make sure this issue is valid!
  • I am using the latest released version of the library.
  • I am using a user token.
  • I have shown the entire traceback and exception information.
  • I've removed my token from any code.

Additional Information

> MY_TOKEN refers to an actual token.

[BUG] Hacky OPCode 14 fails with unavailable guilds

I get this error when running the code

Task exception was never retrieved
future: <Task finished name='Task-8' coro=<ConnectionState._delay_ready() done, defined at C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\state.py:418> exception=IndexError('list index out of range')>
Traceback (most recent call last):
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\state.py", line 465, in _delay_ready
    self.call_handlers('ready')
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\state.py", line 234, in call_handlers
    func(*args, **kwargs)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 301, in _handle_ready
    str(guild.channels[0].id): [
IndexError: list index out of range

[BUG] email, bio, verified None or False

Summary

ClientUser prints None or False on email, bio, verified (I didn't add phone number on my account but it might print as None probably)

Reproduction Steps

How did you make it happen?
  1. Start a selfbot
  2. See error

Code

Relevant code that shows the bug.
import discord
from discord.ext import commands

token = "MyToken"
client = commands.Bot(command_prefix=".", self_bot=True)

@client.event
async def on_ready():
    print(client.user.email)
    print(client.user.verified)
    print(client.user.bio)

client.run(token)

Expected Results

It prints email, bio, and verified correctly as my info in discord

Actual Results

It prints None or False

System Info

Run python -m discord --version and paste the information below.
- Python v3.8.2-final
- discord.py-self v1.9.1-final
- aiohttp v3.7.4.post0
- system info: Windows 10 10.0.19041

Checklist

Let's make sure this issue is valid!
  • I am using the latest released version of the library.
  • I am using a user token.
  • I have shown the entire traceback and exception information.
  • I've removed my token from any code.

Additional Information

I do have email, bio and the account is verified. In discord.py==1.7.3, it prints correctly but not in discord.py-self

on_ready event not working.

Basically on_ready doesn't function as it should. If you have something like, print(f"Logged into {bot.user}"). That would never be printed.

NoneType user has no attribute 'name'

I've updated my discord.self-py to 1.9.1 with a hope that It'll fix the NoneType user thingy but it doesn't resolve it at all.
The bot doesn't fetch the user data with bot.get_user(userid). Please Fix it.

ClientEventTask exception was never retrieved

Summary

Just after a few seconds of running my code this error comes which is there in "Actual Results" Section. The problem appears only on a few accounts of discord and not all

Reproduction Steps

None

Code

No response

Expected Results

Bot should just automate and send the messages we want from it but instead it is giving this error below

Actual Results

ClientEventTask exception was never retrieved
future: <ClientEventTask state=finished event=on_message coro=<bound method MyClient.on_message of <main.MyClient object at 0x7fdd00154bb0>> exception=SystemExit(None)>
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 621, in run
    loop.run_forever()
  File "/usr/lib/python3.8/asyncio/base_events.py", line 570, in run_forever
    self._run_once()
  File "/usr/lib/python3.8/asyncio/base_events.py", line 1859, in _run_once
    handle._run()
  File "/usr/lib/python3.8/asyncio/events.py", line 81, in _run
    self._context.run(self._callback, self._args)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 301, in _run_event
    await coro(args, **kwargs)
  File "main.py", line 24, in on_message
    quit()
  File "/usr/lib/python3.8/_sitebuiltins.py", line 26, in call
    raise SystemExit(code)
SystemExit: None

System Information

  • Python v3.8.7-final
  • discord.py-self v1.9.1-final
  • aiohttp v3.7.4.post0
  • system info: Windows 10 10.0.19041

Checklist

  • I have searched the open issues for duplicates.
  • I have shared the entire traceback.
  • I am using a user token (and it isn't visible in the code).

Additional Information

No response

[BUG] message.author is a LazyUser

for some reason, the bot returns message.author for some users as None#0 and the message.author.name as None
e.g.

  1. Make an on_message method
  2. if the message is "test" do the following
  3. Send a message containint message.author
@bot.event
async def on_message():
 if message.content == "test":
  await message.channel.send(f'{message.author}')

Expected Results :
Bot sends a Message containing the full tag of the author
Actual Results :
Bot sends a Message containing the full tag of the author for some users, for the others it sends "None#0"

System Info

Run python -m discord --version and paste the information below.
# Paste here

Checklist

Let's make sure this issue is valid!
  • I am using the latest released version of the library.
  • I am using a user token.
  • I have shown the entire traceback and exception information.
  • I've removed my token from any code.

Additional Information

Put any extra context, weird configurations, or other important info here.

Runtime: Event loop is closed

Summary

await bot.close() returns Runtime error

Reproduction Steps

just logging out of the bot on windows platform

Code

async def on_connect(self):
        print("Bot Connected")
        await self.get_channel(self.CHANNEL_ID).send("Welp")
        await self.logout()

Expected Results

Exit the event loop quietly without any errors

Actual Results

Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x0000014D19B61280>
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0000014D18E1FC10>
Traceback (most recent call last):
  File "C:\Program Files\Python38\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Program Files\Python38\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Program Files\Python38\lib\asyncio\base_events.py", line 719, in call_soon
    self._check_closed()
  File "C:\Program Files\Python38\lib\asyncio\base_events.py", line 508, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

System Information

  • Python v3.8.0-final
  • discord.py-self v1.9.1-final
  • aiohttp v3.7.4.post0
  • system info: Windows 10 10.0.19041

Checklist

  • I have searched the open issues for duplicates.
  • I have shared the entire traceback.
  • I am using a user token (and it isn't visible in the code).

Additional Information

I also tried this solution but got the following error

Traceback (most recent call last):
  File "D:/Upwork/Corey Lawson/launcher.py", line 3, in <module>
    bot("NzU3NDU3OTUwMjM4NTcyNTU0.X9WMmA.RHwkoMlsuEESHGH98uLJNQHmIpM", 756281213282680844).run()
  File "D:\Upwork\Corey Lawson\lib\bot\__init__.py", line 28, in run
    super().run(self.TOKEN, reconnect=True)
  File "C:\Users\arfatha\.virtualenvs\Discord Bot Mehmat\lib\site-packages\discord\client.py", line 603, in run
    loop.add_signal_handler(signal.SIGINT, lambda: loop.stop())
AttributeError: 'WindowsSelectorEventLoopPolicy' object has no attribute 'add_signal_handler'

What will happen with v2.0?

What will happen with v2.0?

Some people have been asking if this fork will be updated to discord.py v2.0.
I talked about this in my previous announcement but I'll discuss it in more detail here.

Short answer:

Yes.

Long answer:

v2.0 has a huge amount of changes, and drops the incomplete support discord.py had for the user API.

In order to update this fork to v2.0, I'll need to:

  • Re-add all the removed user classes/methods and update them for v2.0.
  • Re-do all the v1.x changes and update them to match v2.0.
  • Remove all the new bot-only stuff.
  • Fix the threads implementation.
  • Add type-checking to everything.

You can probably guess that this won't be fast.
However, since I'm starting now (while the new version is in alpha), the fork's v2.0 won't be far behind the official release of v2.0.

~Dolfies

[BUG] Help command and clean_prefix not working - user is None

Summary

When running the help command, and error is thrown when trying to clean_prefix.

Reproduction Steps

Create a bot and ask it for help (using code below, send: ???help)

Code

from discord.ext import commands
commands.Bot('???').run("<SECRET TOKEN>")

Expected Results

Help is printed.

Actual Results

Ignoring exception in command help:
Traceback (most recent call last):
  File "/home/prof_bloodstone/.pyenv/versions/discord_relay/lib/python3.9/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/prof_bloodstone/.pyenv/versions/discord_relay/lib/python3.9/site-packages/discord/ext/commands/help.py", line 848, in command_callback
    return await self.send_bot_help(mapping)
  File "/home/prof_bloodstone/.pyenv/versions/discord_relay/lib/python3.9/site-packages/discord/ext/commands/help.py", line 1047, in send_bot_help
    note = self.get_ending_note()
  File "/home/prof_bloodstone/.pyenv/versions/discord_relay/lib/python3.9/site-packages/discord/ext/commands/help.py", line 945, in get_ending_note
    "You can also type {0}{1} category for more info on a category.".format(self.clean_prefix, command_name)
  File "/home/prof_bloodstone/.pyenv/versions/discord_relay/lib/python3.9/site-packages/discord/ext/commands/help.py", line 389, in clean_prefix
    pattern = re.compile(r"<@!?%s>" % user.id)
AttributeError: 'NoneType' object has no attribute 'id'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/prof_bloodstone/.pyenv/versions/discord_relay/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/home/prof_bloodstone/.pyenv/versions/discord_relay/lib/python3.9/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/prof_bloodstone/.pyenv/versions/discord_relay/lib/python3.9/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'id'

System Info

Run python -m discord --version and paste the information below.
- Python v3.9.5-final
- discord.py v1.7.7-final
- aiohttp v3.7.4.post0
- system info: Linux 5.11.18_1 #1 SMP 1620040716

Checklist

Let's make sure this issue is valid!
  • I am using the latest released version of the library.
  • I am using a user token.
  • I have shown the entire traceback and exception information.
  • I've removed my token from any code.

Additional Information

Put any extra context, weird configurations, or other important info here.

[BUG] "message.author" and "message.author.avatar_url" not working correctly

Summary

When other users are triggering commands/events using "message.author" and "message.author.avatar_url" it returns as "None"

Reproduction Steps

1. Get a different user to send the command that uses "message.author". In my case the command used was ">test"

Code

Relevant code that shows the bug.
class MyClient(discord.Client):
    async def on_ready(self):
        print('Logged on as', self.user)

    async def on_message(self, message):
        if message.content.startswith(">test"):
            await message.channel.send(message.author.avatar_url)

Expected Results

It's supposed to return the correct author tag, and avatar url

Actual Results

It's sending "none"

System Info

Run python -m discord --version and paste the information below.
- Python v3.9.6-final
- discord.py v1.8.1-final
- aiohttp v3.7.4.post0
- system info: Windows 10 10.0.19042

Checklist

Let's make sure this issue is valid!
  • I am using the latest released version of the library.
  • I am using a user token.
  • I have shown the entire traceback and exception information.
  • I've removed my token from any code.

Randoms task exception was never retrieved error

I'm developing a simple project, but when using the '1.x' branch there are random errors of 'Task exception was never retrieved', there is no specific situation that they happen. The problem doesn't happen on the 'main' branch.

  • The installer had problems, so I had to install it manually.
  • Everything works fine until these errors happen, when that happens, it loses the connection.
Task exception was never retrieved
future: <Task finished name='Task-1' coro=<Client.start() done, defined at C:\Users\caioc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py:671> exception=KeyError('member')>
Traceback (most recent call last):
  File "C:\Users\caioc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 687, in start
    await self.connect(reconnect=reconnect)
  File "C:\Users\caioc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 588, in connect
    await self.ws.poll_event()
  File "C:\Users\caioc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\gateway.py", line 553, in poll_event
    await self.received_message(msg.data)
  File "C:\Users\caioc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\gateway.py", line 503, in received_message
    func(data)
  File "C:\Users\caioc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\state.py", line 793, in parse_guild_member_list_update
    mdata = opdata['item']['member']
KeyError: 'member'

Edit: I've fixed checking if has defined in line 492, but it's not a good way to do this.

Joining produces bans

Summary

While discord.py-self is running if you join tokens to guilds, it will cause bans. Not every token but a lot of them.

Reproduction Steps

Turn off guild subscriptions completely and await client.start() with around 500 tokens, I would really suggest to use at least one separate proxy each 2-3 bots.

Now either use the join() method or a browser to join these 500 tokens to a couple different guilds, use delays between each join and do not run it concurrently.

You will notice that you get a high amount of bans no matter if you use the join() method or a browser to join servers.

Code

No response

Expected Results

The tokens do not get banned - at least if a browser is being used to join them manually while discord.py-self is running.

Actual Results

A high percentage of the tokens, that are currently online with discord.py-self are getting banned.

System Information

  • Windows 10
  • Python 3.9.6
  • Release 1.9.1

Checklist

  • I have searched the open issues for duplicates.
  • I have shared the entire traceback.
  • I am using a user token (and it isn't visible in the code).

Additional Information

I would be willing to provide you working and verified tokens for testing this. Share me a throwaway Discord and I will contact you there.

[BUG] `guild.fetch_members` doesn't work and makes me reverify my email.

Summary

A simple summary of the bug.

Using guild.fetch_members always raises a 403 Forbidden and makes me verify email again. Not sure if self-bots are not supposed to use this, or if it is a library issue.

Code

Relevant code that shows the bug.
print(await self.bot.guilds[0].fetch_members().flatten())

Expected Results

What is supposed to happen?

We get all the members fetched with the API call.

Actual Results

What is currently happening?

An error is raised

 discord.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: 403 Forbidden (error code: 40002): You need to verify your account in order to perform this action.

Checklist

Let's make sure this issue is valid!
  • I am using the latest released version of the library.
  • I am using a user token.
  • I have shown the entire traceback and exception information.
  • I've removed my token from any code.

`guild.members` does not work properly

Summary

When I tried guild.members on a server of around 78k members and having 15k users online on average, only 100 members are returned.

Code

import discord
from os import path
from time import perf_counter

variables = {
    'guild': 1234567890,
    'token': "abcdefghijklmnop"
}

class MyClient(discord.Client):
    async def on_ready(self):
        print("Logged in as", self.user)
        guild = self.get_guild(variables["guild"])
        start = perf_counter()
        with open(path.join(path.dirname(__file__), 'tempfile.txt'), 'w', encoding="utf-8") as file:
            file.write(f"{len(guild.members)}\n")
            print(f"{len(guild.members)}")
            for member in guild.members:
                file.write(f"{member.name}#{member.discriminator}, {member.id}\n")
            file.write(f"{guild.members}\n")
            print(f"{perf_counter()- start}")

        

client = MyClient()
client.run(variables['token'])

Expected Results

Maybe the list of 15k users who are online.

Actual Results

Prints
Logged in as User#1234
99
0.00043590000000026663

Checklist

  • I am using the latest released version of the library.
  • I am using a user token.
  • I've removed my token from any code.

Doesn't work for the real bots

Would be good if module would also work for the normal, not self-bots, as it collides with the original Discord module and you can't run script as it's now

[BUG] KeyError: 'guild_id' | Sometimes the bot can't run due this error

Summary

Sometimes the bot can't start

Reproduction Steps

Trying to start the bot

Code

Relevant code that shows the bug.
import discord
from discord.ext import commands

bot = commands.Bot(command_prefix='.')

bot.run('my_token')

Expected Results

Normal start

Actual Results

Sometimes the bot can't start due to this error, and takes a lot to load the event on_ready

System Info

C:\Users\Bengali\Desktop\Genessir X\selfbot>python -m discord --version
- Python v3.8.5-final
- discord.py-self v1.9.0-final
- aiohttp v3.6.2
- system info: Windows 10 10.0.19041

Checklist

Let's make sure this issue is valid!
  • I am using the latest released version of the library.
  • I am using a user token.
  • I have shown the entire traceback and exception information.
  • I've removed my token from any code.

Additional Information

  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 631, in run
    return future.result()
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 610, in runner
    await self.start(*args, **kwargs)
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 574, in start
    await self.connect(reconnect=reconnect)
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 477, in connect
    await self.ws.poll_event()
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\gateway.py", line 547, in poll_event
    await self.received_message(msg.data)
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\gateway.py", line 497, in received_message
    func(data)
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\state.py", line 497, in parse_message_create
    guild_id = int(data['guild_id'])
KeyError: 'guild_id'

[BUG] Bot can't start if a guild has no channels

Summary

The bot cant start if a guild has 0 channels

Reproduction Steps

How did you make it happen?
  1. Trying to start the bot with an account who has a guild with 0 channels
  2. Bug found: IndexError

Code

Relevant code that shows the bug.
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix='!')
@bot.event
async def on_ready():
        print('hello')
bot.run('user token')

Expected Results

Normally run

Actual Results

What is currently happening?

The bot cant run

System Info

- Python v3.8.5-final
- discord.py v1.8.1-final
- aiohttp v3.6.2
- system info: Windows 10 10.0.19041

Checklist

Let's make sure this issue is valid!
  • I am using the latest released version of the library.
  • I am using a user token.
  • I have shown the entire traceback and exception information.
  • I've removed my token from any code.

Exception

websocket connection is closing.
Traceback (most recent call last):
  File "genessir.py", line 190, in <module>
    runSelfbot()
  File "bot.py", line 188, in runSelfbot
    bot.run("mytoken")
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 755, in run
    return future.result()
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 734, in runner
    await self.start(*args, **kwargs)
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 698, in start
    await self.connect(reconnect=reconnect)
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 599, in connect
    await self.ws.poll_event()
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\gateway.py", line 555, in poll_event
    await self.received_message(msg.data)
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\gateway.py", line 505, in received_message
    func(data)
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\state.py", line 481, in parse_ready
    self._add_guild_from_data(guild_data)
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\state.py", line 377, in _add_guild_from_data
    guild = Guild(data=guild, state=self)
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\guild.py", line 190, in __init__
    self._from_data(data)
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\guild.py", line 326, in _from_data
    self._fetch_members(guild)
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\guild.py", line 353, in _fetch_members
    channel = self.channels[0]
IndexError: list index out of range
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x03EBCA00>
Traceback (most recent call last):
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\asyncio\base_events.py", line 719, in call_soon
    self._check_closed()
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\asyncio\base_events.py", line 508, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

image

[BUG] Cannot edit ClientUser

Reproduction Steps

How did you make it happen?
  • Edit a ClientUser's properties using ClientUser.edit

Code

Relevant code that shows the bug.
await client.user.edit(password=password, username="a new user name", avatar=b"Some dang bytes~")

Obviously, the avatar is valid. This is just for example.

Expected Results

What is supposed to happen?

Account's properties become their assigned values, provided the password is correct.

Actual Results

What is currently happening?
Traceback (most recent call last):
  File "some_arbitrary_module.py", line some_arbitrary_line, in some_coroutine
    await client.user.edit(
  File "C:\Users\some_arbitrary_username\PycharmProjects\some_arbitrary_project_name\venv\lib\site-packages\discord\user.py", line 479, in edit
    http._token(data['token'], bot=False)
TypeError: _token() got an unexpected keyword argument 'bot'

...and the user gets phone-locked, but I doubt this is because of this issue.

System Info

Run python -m discord --version and paste the information below.
- Python v3.9.2-final
- discord.py v1.8.1-final
- aiohttp v3.7.4.post0
- system info: Windows 10 10.0.21390

Checklist

Let's make sure this issue is valid!
  • I am using the latest released version of the library.
  • I am using a user token.
  • I have shown the entire traceback and exception information.
  • I've removed my token from any code.

Additional Information

Put any extra context, weird configurations, or other important info here.

I'll likely make a PR to fix this if it's not touched.

[BUG] 'TextChannel' object has no attribute 'fetch_message'

Summary

I'm trying to get message object from a message-id by fetch_message method, But I got AttributeError: 'TextChannel' object has no attribute 'fetch_message'

Code

from discord.ext import commands

client = commands.Bot(command_prefix=".")

@client.command()
async def get_msg(ctx, msg_id):
    msg = await ctx.channel.fetch_message(msg_id)

client.run(TOKEN)

Expected Results

Returning a message object

Actual Results

Getting an AttributeError
Full traceback:

Traceback (most recent call last):
  File "C:\Users\notmo\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "B:\desktop\projects\auto-react-rewrite\tests\add_all_reacts.py", line 26, in add
    msg = await ctx.channel.fetch_message(msg_id)
AttributeError: 'TextChannel' object has no attribute 'fetch_message'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\notmo\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\notmo\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\notmo\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'TextChannel' object has no attribute 'fetch_message'

System Info

- Python v3.9.1-final
- discord.py v1.8.1-final
- aiohttp v3.6.3
- system info: Windows 10 10.0.19041

Checklist

  • I am using the latest released version of the library.
  • I am using a user token.
  • I have shown the entire traceback and exception information.
  • I've removed my token from any code.

[BUG] Can't start the script sometimes

Summary

A simple summary of the bug.

when i launch the script it crashes sometimes

Reproduction Steps

How did you make it happen?
  1. start the script

Code

Relevant code that shows the bug.
future: <Task finished name='Task-8' coro=<ConnectionState._delay_ready() done, defined at /home/kouranio/.local/lib/python3.9/site-packages/discord/state.py:418> exception=IndexError('list index out of range')>
Traceback (most recent call last):
  File "/home/kouranio/.local/lib/python3.9/site-packages/discord/state.py", line 465, in _delay_ready
    self.call_handlers('ready')
  File "/home/kouranio/.local/lib/python3.9/site-packages/discord/state.py", line 234, in call_handlers
    func(*args, **kwargs)
  File "/home/kouranio/.local/lib/python3.9/site-packages/discord/client.py", line 284, in _handle_ready
    str(guild.channels[0].id): [
IndexError: list index out of range

Expected Results

What is supposed to happen?

the script starts normally

Actual Results

What is currently happening?

it crashes but when i start the script again and again it works sometimes

System Info

Run python -m discord --version and paste the information below.
- Python v3.9.5-final
- discord.py v1.8.1-final
- aiohttp v3.7.4.post0
- system info: Linux 5.12.12-arch1-1 #1 SMP PREEMPT Fri, 18 Jun 2021 21:59:22 +0000

Checklist

Let's make sure this issue is valid!
  • I am using the latest released version of the library.
  • I am using a user token.
  • I have shown the entire traceback and exception information.
  • I've removed my token from any code.

Additional Information

Put any extra context, weird configurations, or other important info here.

[BUG] `guild.members` is blank

Summary

A simple summary of the bug.

Most of the time, members are not present in the guild data, so guild.members (along with other things) are blank. This creates quite a few issues. Sometimes, it comes through (after a while) for some reason, with a few members. Again, this seems to be related to lazy loading.

Reproduction Steps

How did you make it happen?

Code

Relevant code that shows the bug.
...
async def on_message(self, message):
  print(message.guild.members)
...

Expected Results

What is supposed to happen?

It prints a list of discord.Member objects.

Actual Results

What is currently happening?

It is empty. This also affects guild.me which has a lot of bad effects.

Checklist

Let's make sure this issue is valid!
  • I am using the latest released version of the library.
  • I am using a user token.
  • I have shown the entire traceback and exception information.
  • I've removed my token from any code.

Additional Information

Put any extra context, weird configurations, or other important info here.

Sometimes, after a while, some users load. Most of the time they do not. This bug leads to a lot of bugs, especially with discord.ext.commands. I have no idea on how to implement a fix for this, but I'm researching the lazy user loading patches that are used to fix similar bugs.

Help needed.

Example traceback:

Ignoring exception in on_message
Traceback (most recent call last):
  File "/home/dolfies/Temp/discord.py-self/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "/home/dolfies/Temp/discord.py-self/client.py", line 44, in on_message
    await self.process_commands(message)
  File "/home/dolfies/Temp/discord.py-self/discord/ext/commands/bot.py", line 976, in process_commands
    await self.invoke(ctx)
  File "/home/dolfies/Temp/discord.py-self/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/home/dolfies/Temp/discord.py-self/discord/ext/commands/core.py", line 855, in invoke
    await self.prepare(ctx)
  File "/home/dolfies/Temp/discord.py-self/discord/ext/commands/core.py", line 777, in prepare
    if not await self.can_run(ctx):
  File "/home/dolfies/Temp/discord.py-self/discord/ext/commands/core.py", line 1071, in can_run
    if not await ctx.bot.can_run(ctx):
  File "/home/dolfies/Temp/discord.py-self/discord/ext/commands/bot.py", line 290, in can_run
    return await discord.utils.async_all(f(ctx) for f in data)
  File "/home/dolfies/Temp/discord.py-self/discord/utils.py", line 350, in async_all
    elem = await elem
  File "/home/dolfies/Temp/discord.py-self/discord/ext/commands/core.py", line 1537, in wrapper
    return predicate(ctx)
  File "/home/dolfies/Temp/discord.py-self/discord/ext/commands/core.py", line 1809, in predicate
    permissions = ctx.channel.permissions_for(me)
  File "/home/dolfies/Temp/discord.py-self/discord/channel.py", line 147, in permissions_for
    base = super().permissions_for(member)
  File "/home/dolfies/Temp/discord.py-self/discord/abc.py", line 490, in permissions_for
    if self.guild.owner_id == member.id:
AttributeError: 'NoneType' object has no attribute 'id'

[BUG] Getting user info in a DM doesn't work

Summary

A simple summary of the bug.

Whenever I try to get the avatar_url of a user in a DM it returns the default discord profile picture, and if I try to get the name of the user it returns 'None'

Reproduction Steps

How did you make it happen?
  1. Go into a DM
  2. Run:
  3. Try to get a user's name/avatar

Code

Relevant code that shows the bug.
@Client.command()
async def test(Context, User: discord.User):
	print(User.avatar_url)
	print(User.name)

Expected Results

What is supposed to happen?

Returns the user's correct tag and avatar

Actual Results

What is currently happening?

Returns 'None' as the user's name and the default discord profile picture as their avatar

System Info

Run python -m discord --version and paste the information below.
- Python v3.9.5-final
- discord.py v1.8.1-final
- aiohttp v3.7.4.post0
- system info: Windows 10 10.0.19041

Checklist

Let's make sure this issue is valid!
  • [ x ] I am using the latest released version of the library.
  • [ x ] I am using a user token.
  • [ x ] I have shown the entire traceback and exception information.
  • [ x ] I've removed my token from any code.

Additional Information

Put any extra context, weird configurations, or other important info here.

[BUG] discord.Intents

What's with the discord.Intents?
Looks like there is no such a thing in your fork, and I really need it for discord.Guild.fetch_members() to work
Also, is there even fetch_members function? Cuz I havent found it in the source code

Documentation

Issue

We have plans to remove a lot of regular bot-only features, and add a lot of undocumented Discord APIs to this library. This will make the official Discord.py documentation incomplete.

What do we do about documentation?

Solutions

I have a few different ideas for solutions.

  • Edit and rehost the official Discord.py documentation
    This is probably the best solution, but also the hardest. We'd have to keep it updated, as well as change all the links inside the documentation.

  • Create an extension
    This seems like the best compromise. Point people to the official documentation, but have an addendum outlining all the new and removed things.

  • Do nothing
    This is probably the least beginner-friendly solution. We could just let people look at pull requests/issues/commits/the code to figure out what the hell we changed.

What do we do?

Please voice your thoughts below! What do you think is best? Do you have a different idea?
Any new solutions will be added to Solutions

[BUG] Rename everything in the package from discord to discord_self

Summary

We can't use both versions of Discord because of the package name

Reproduction Steps

Try importing discord when you have both installed.

Code

Relevant code that shows the bug.
import discord

Expected Results

It should import only one but doesn't do it because I have both versions

This could be fixed if you added bot: bool back to the source code but atleast default it to False.
Because that's the whole reason I want 2 of the versions, because you don't support bot.

Actual Results

Imports bot discord

System Info

Run python -m discord --version and paste the information below.
- discord.py v1.7.3-final
- aiohttp v3.7.4.post0
- system info: Linux 4.9.186-perf-g10af704 #1 SMP PREEMPT Sun Dec 27 14:28:21 WIB 2020

Checklist

Let's make sure this issue is valid!
  • I am using the latest released version of the library.
  • I am using a user token.
  • I have shown the entire traceback and exception information.
  • I've removed my token from any code.

Additional Information

Put any extra context, weird configurations, or other important info here.

wait_for not returning message

Summary

wait_for function is not returning contents of message

Reproduction Steps

Run the code the do ;p then wait for an embed.

Code

config import token, channelid, userid
from selfcord.ext import commands

bot = commands.Bot(command_prefix=';', self_bot=True)

meowid = 664508672713424926

def check(msg):
      lambda m: m.author.id == meowid and m.channel == msg.channel

def footer(ctx):
     embeds = ctx.embeds
     for embed in embeds:
         print(embed)
         footer=str(embed.footer)
         print(footer)
         return footer

@bot.command()
async def p(ctx):
      if ctx.channel.id == channelid and ctx.author.id == userid:
         try:
            try:        
                  msg = await bot.wait_for("message", check=check(ctx), timeout=10)

            except:
                  print("Test 1 Failed")
            
            else:
                  print(str(msg.embeds))
                  if f"Common" in footer(msg):
                        await ctx.send("gb")
         except:
               pass

bot.run(token)

Expected Results

print(str(msg.embeds)) should return contents of the embed.

Actual Results

It is returning an empty list but the message does have an embed.

System Information

  • Python v3.9.7-final
  • discord.py v1.7.3-final
  • aiohttp v3.7.4.post0
  • system info: Windows 10 10.0.19042

Checklist

  • I have searched the open issues for duplicates.
  • I have shared the entire traceback.
  • I am using a user token (and it isn't visible in the code).

Additional Information

No response

[BUG] Improper token has been passed.

Summary

When having discord.py and discord.py-self installed on the same system, I can not run/host a discord bot(s) while having both installed at the same time. I have pip3 installed discord.py 1.7.3 and discord.py-self 1.9.1 onto the same system. I wanted to run a discord bot instead of a selfbot or run discord bot code along side discord bot code and I get an Improper token has been passed error for the discord bot code. not the selfbot code

Reproduction Steps

How did you make it happen?
  1. python3 -m pip install -U discord.py
  2. python3 -m pip install -U discord.py-self
  3. Make a discord bot how you'd normally make a discord bot.
  4. Set up discord bot code then get the discord bot's token and pass it in somehow or put client.run("TOKEN_HERE") at the bottom of the code file.
  5. Run the file

Code

Relevant code that shows the bug.
# Nothing to show here as the code for the bot itself works just fine.

Traceback Error

Trackback error block for debugging.

(When running discord bot code. not selfbot code)

Traceback (most recent call last):
  File "/home/ori/.local/lib/python3.9/site-packages/discord/http.py", line 349, in static_login
    data = await self.request(Route('GET', '/users/@me'))
  File "/home/ori/.local/lib/python3.9/site-packages/discord/http.py", line 302, in request
    raise HTTPException(r, data)
discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ori/Desktop/Projects/ChatterEye/eye_BOT.py", line 73, in <module>
    client.run('BOT_TOKEN_HERE')
  File "/home/ori/.local/lib/python3.9/site-packages/discord/client.py", line 631, in run
    return future.result()
  File "/home/ori/.local/lib/python3.9/site-packages/discord/client.py", line 610, in runner
    await self.start(*args, **kwargs)
  File "/home/ori/.local/lib/python3.9/site-packages/discord/client.py", line 573, in start
    await self.login(*args)
  File "/home/ori/.local/lib/python3.9/site-packages/discord/client.py", line 424, in login
    await self.http.static_login(token.strip())
  File "/home/ori/.local/lib/python3.9/site-packages/discord/http.py", line 353, in static_login
    raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.

Expected Results

What is supposed to happen?

The discord bot will come online and run its code.

Actual Results

What is currently happening?

Errors and says improper token has been passed.

System Info

Run python -m discord --version and paste the information below.
- Python v3.9.6-final
- discord.py v1.7.3-final
- aiohttp v3.6.2
- system info: Linux 5.10.59-1-MANJARO #1 SMP PREEMPT Sun Aug 15 13:11:32 UTC 2021

Checklist

Let's make sure this issue is valid!
  • I am using the latest released version of the library.
  • [] I am using a user token. (For this bug, no. This bug involves normal discord bot tokens and not being compatible with discord.py installed at the same time you have discord.py-self installed.)
  • I have shown the entire traceback and exception information.
  • I've removed my token from any code.

Additional Information

Put any extra context, weird configurations, or other important info here.

Having discord.py and discord.py-self installed on the same computer at the same time will conflict with each other and means you can not and will not be able to run normal discord bots from your computer/laptop. It is the same thing that happens when trying to run the selfbot code without discord.py-self. It will say improper token. IF I uninstall discord.py-self, I will be able to run discord bot code again and not get this error. But then my selfbot code will give me this error and for obvious reasons, won't be able to run the selfbot code.

[BUG] Cannot run selfbot

import discord 
from discord.ext import commands

bot = commands.Bot(command_prefix='.', self_bot=True)

@bot.command()
async def ping(ctx):
    await ctx.send('pong')

try:
    bot.run("mytoken")
except Exception as e:
    print(e)

Returns error:

websocket connection is closing.
websocket connection is closing.
websocket connection is closing.
websocket connection is closing.
websocket connection is closing.
websocket connection is closing.
websocket connection is closing.
websocket connection is closing.
websocket connection is closing.
websocket connection is closing.
websocket connection is closing.
websocket connection is closing.
websocket connection is closing.
websocket connection is closing.
websocket connection is closing.
websocket connection is closing.
websocket connection is closing.
websocket connection is closing.
websocket connection is closing.
websocket connection is closing.
websocket connection is closing.
list index out of range
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x034099B8>
Traceback (most recent call last):
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\asyncio\base_events.py", line 719, in call_soon
    self._check_closed()
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\asyncio\base_events.py", line 508, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

Better commit messages for your commits for changes on what changes fixed the .content and .embeds, and more?

So I am currently patching discord.py with the message history workaround in my project, and I would like to kind of use the proper solution with its advantages from this instead. So I would kind of like to nicely format the commit from this that fixes this and that's it.

However it seems like the things that fix it seem to be just a multiple of a bunch of useless messages with titles like "Update file.py". I know I could figure it out by comparing this and discord.py and making a good commit manually, however I think that shouldn't be needed. So maybe please clean history up to be nice and make sense and have more proper messages (also, don't combine with formatting changes in non relevant parts)

image

'HTTPClient' object has no attribute 'user_agent'

Summary

When running "fetch_user", I get an AttributeError exception

Reproduction Steps

  • Instantiate client as a selfcord.ext.commands.Bot()
  • Instantiate selfcordClient as selfcord.Client()
  • Execute selfcordClient.fetch_user(id)
  • AttributeError exception thrown

Code

import selfcord as discord
from selfcord.ext import commands

client = commands.Bot(command_prefix=",",
                      case_insensitive=True,
                      user_bot=True,
                      guild_subscription_options=discord.GuildSubscriptionOptions.default())
selfcordClient = discord.Client()

client.run(TOKEN)
member.id = "(MEMBER_ID_HERE)"
userobj = await selfcordClient.fetch_user(member.id) # exception

Expected Results

fetch_user returns a discord.User object

Actual Results

Ignoring exception in on_ready
Traceback (most recent call last):
  File "/Users/ventus/GitRepos/darvester/env/lib/python3.9/site-packages/selfcord/client.py", line 301, in _run_event
    await coro(*args, **kwargs)
  File "/Users/ventus/GitRepos/darvester/run.py", line 79, in on_ready
    userobj = await selfcordClient.fetch_user(member.id)
  File "/Users/ventus/GitRepos/darvester/env/lib/python3.9/site-packages/selfcord/client.py", line 1362, in fetch_user
    data = await self.http.get_user(user_id)
  File "/Users/ventus/GitRepos/darvester/env/lib/python3.9/site-packages/selfcord/http.py", line 194, in request
    'User-Agent': self.user_agent,
AttributeError: 'HTTPClient' object has no attribute 'user_agent'

System Information

โฏ python -m discord -v

- Python v3.9.8-final
- discord.py v1.7.3-final
- aiohttp v3.7.4.post0
- system info: Darwin 19.6.0 Darwin Kernel Version 19.6.0: Thu Nov 11 20:02:32 PST 2021; root:xnu-6153.141.49~1/RELEASE_X86_64

Checklist

  • I have searched the open issues for duplicates.
  • I have shared the entire traceback.
  • I am using a user token (and it isn't visible in the code).

Additional Information

No response

Answers to some common questions

I already put this in the latest pull request, but thought I should put it here too.


Some people have been asking about what will happen when 2.0 releases. I will rebase this project to that version, however, it won't be quick. v2.0 adds type-hints to the entire project, completely removes everything user-related, and changes a lot of things internally.

A lot of people have asked me to rename the project, because it conflicts with the original discord.py. I will not be doing this. I have chosen to keep the same package name in the name of backwards-compatibility. There is a scary amount of closed-source selfbots that cannot be easily edited to change import discord to import packagename as discord. Python has a great feature called virtual environments that can help people wanting to use both libs.

Update:
Since closed-source selfbots aren't as much as a problem as I thought, I have reconsidered.
Since some people want me to rename it, and some people do not, I'm kind of stuck.

What I'm planning to do is create a new branch on this repo that has a different import name. That way, you'll be able to install it using pip and use it as normal.
However, I won't be uploading that version to PyPi. You'll have to install and update manually.


I also want to address another thing

I see a lot of Python beginners using this project to create something that would work perfectly fine as a regular bot. I want to make it clear that you shouldn't break the Discord ToS for no reason (no matter how bad it is), and that working with a library such as this or the original discord.py for your first coding adventure is not a good idea. Get familiar with Python first, and then come back to the mess that is the Discord API. If you do come back, consider using a regular bot.
I don't want script-kiddies getting banned for being curious. Been there, done that.

The reason I created this fork was to fix/improve upon discord.py's support of selfbots, and keep it maintained when discord.py removes it. Even though selfbots are against Discord ToS, I believe people should have a choice; writing code isn't against ToS, but using this library, unfortunately, is.
For that reason, I cannot ever recommend anybody ever uses this, and I carry no responsibility for any crap you do.

In my opinion, Discord banning selfbots was an incredibly stupid idea. It hasn't stopped bad actors from using them, it has only affected regular people trying to enhance their chat experience on what is (or at least used to be) a wonderful platform, with a wonderful community, and caring staff.

They had good intentions, but the selfbot detection is easy to work around (and always will be). Raids, dm spam, and all the other cons of selfbots still occur. Raiders, spammers, and advertisers don't care if their alts get disabled, or even if their mains get banned; they'll just generate a few hundred more tokens and continue. Disabled accounts only affect the people that aren't raiding, spamming, or advertising; just having fun. The selfbot ban only stops people that actually use Discord for keeping in touch with friends and being a part of communities they love, and wanted to tinker, carry around some extra chatting features, and add functionality to their servers.

Selfbotting is very low-risk to people that will abuse it, and high-risk to people that want to mess around and create cool things on their account.

The solution is not banning selfbotting as a whole. It is acting against people who abuse the Discord API.
If you support this, please go vote here and tell Discord how you feel.

For all of you saying "just use a bot":

  • You can't invite your bot to all the servers you're in
  • Certain actions are user-only
  • You can't impersonate yourself with a bot
    ...amongst other things

~Dolfies

on_member_join

Discussed in #42

Originally posted by caiocinel June 18, 2021
Is there any prediction or way to make on_member_join work without intents?

Cannot import `discord.ext` in v1.x

Summary

I tried importing discord.ext.commands, but it fails

Reproduction Steps

Execute code in shell

Code

from discord.ext import commands


### Expected Results

It is supposed to import `commands`

### Actual Results

ModuleNotFoundError: No module named 'discord.ext'


### System Information

- Python v3.9.7-final
- discord.py-self v1.10.0-alpha
    - discord.py-self pkg_resources: v1.7.3
- aiohttp v3.6.3


### Checklist

- [X] I have searched the open issues for duplicates.
- [X] I have shared the entire traceback.
- [X] I am using a user token (and it isn't visible in the code).

### Additional Information

Also, flask isn't in the requirements.txt but is required.

DeprecationWarning is thrown when calling message.ack()

I had to use a hack like this to suppress DeprecationWarnings:

import warnings
from unittest import mock

with warnings.catch_warnings():
    warnings.filterwarnings("ignore", category=DeprecationWarning) 
    with mock.patch('warnings._add_filter'):
        await message.ack()

The reason is this line

warnings.simplefilter('always', DeprecationWarning) # turn off filter

It overrides any filters I set manually, so in the interim I'm patching an internal function of the warnings module to make the filterwarnings call in there a no-op.

improper token passed

everything is correct I have rechecked the bot token 20 @times

File "/app/.heroku/python/lib/python3.9/site-packages/discord/http.py", line 303, in static_login
2021-06-06T14:43:10.968122+00:00 app[worker.1]: raise LoginFailure('Improper token has been passed.') from exc
2021-06-06T14:43:10.968122+00:00 app[worker.1]: discord.errors.LoginFailure: Improper token has been passed.

invalid tkn error cause it use discord.py instead discord.py-self

Summary

running the script cause the issue

Reproduction Steps

i just installed the newest version from discord.py-self and noticed this issue. i think it would be good to replace the importname so you use import selfcord and from selfcord.ext import ... instead of discord so you can have both packages installed at the same time

Code

there is no need for a code as this issue is raised within the lib

Expected Results

i expected it to work fine

Actual Results

not working fine

Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0000020DAFA76AF0>
Traceback (most recent call last):
  File "D:\Downloads\Python\python 3.9.6\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "D:\Downloads\Python\python 3.9.6\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "D:\Downloads\Python\python 3.9.6\lib\asyncio\base_events.py", line 746, in call_soon
    self._check_closed()
  File "D:\Downloads\Python\python 3.9.6\lib\asyncio\base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

System Information

  • Python v3.9.6-final
  • discord.py v1.7.3-final
  • aiohttp v3.7.3
  • system info: Windows 10 10.0.22000

Checklist

  • I have searched the open issues for duplicates.
  • I have shared the entire traceback.
  • I am using a user token (and it isn't visible in the code).

Additional Information

No response

[BUG] readme python version

idk if it's a bug but I was looking thru commits and I saw you made it 3.8 or higher but the readme still shows 3.5 3.6 3.7 3.8

wait_for message_edit not working

Summary

wait_for message_edit isn't doing anything

Reproduction Steps

Run the code send the command followed by a message "hi" then edit that message. wait_for message works but wait_for message_edit doesn't.

Code

from selfcord.ext import commands
import asyncio

bot = commands.Bot(command_prefix=';', self_bot=True)

def check(m):
      return m.author.id == userid and m.channel.id == channelid

@bot.command()
async def hi(ctx):
      if ctx.channel.id == channelid and ctx.author.id == userid:
            try:
                  try:        
                        msg = await bot.wait_for("message", check=check, timeout=10)

                  except:
                        pass
            
                  else:
                        print("worked 1")
                        if "hi" in msg.content:
                         try:
                              edited_msg = await bot.wait_for('message_edit', check=check, timeout=20)

                         except asyncio.TimeoutError:
                              print("Timeout")

                         else:
                              print("Worked 2")

            except:
                  pass

bot.run(token)

Expected Results

It should print worked 1 then worked 2.

Actual Results

It prints worked 1 but not worked 2 or timeout which means wait_for message_edit isn't doing anything.

System Information

  • Python v3.9.7-final
  • discord.py v1.7.3-final
  • aiohttp v3.7.4.post0
  • system info: Windows 10 10.0.19042

Checklist

  • I have searched the open issues for duplicates.
  • I have shared the entire traceback.
  • I am using a user token (and it isn't visible in the code).

Additional Information

No response

issue while using bot.commands

None of the other stuff is important its just that bot.commands isnt working aka the discord.ext like my on_message functions r working but thats it pretty much nothing prefixed is that intended?

'LazyUser' object has no attribute 'send'

Summary

A simple summary of the bug.

I found that the message.author is a type of LazyUser, when I call message.author.send("abc"), it just failed "'LazyUser' object has no attribute 'send'". How can I send DM to the corresponding user after recieving a group message?

Reproduction Steps

How did you make it happen?
  1. Call message.author.send("abc") after recieving a message

Code

Relevant code that shows the bug.
# message.author.send("abc")

Expected Results

What is supposed to happen?

Send DM to the corresponding user

Actual Results

What is currently happening?

Throw a exception "'LazyUser' object has no attribute 'send'"

System Info

Run python -m discord --version and paste the information below.
- Python v3.8.8-final
- discord.py v1.8.0-final
- aiohttp v3.7.4.post0
- system info: Windows 10 10.0.16299

Checklist

Let's make sure this issue is valid!
  • [ x] I am using the latest released version of the library.
  • [ x] I am using a user token.
  • I have shown the entire traceback and exception information.
  • I've removed my token from any code.

Additional Information

Put any extra context, weird configurations, or other important info here.

[BUG] Library crashes trying to import .Account

Summary

When I run my bot on heroku I get an error.

Reproduction Steps

I installed discord.py-self and then when I run my bot it gives an error.

Code

Relevant code that shows the bug.
# 
import discord
import asyncio
import time
from time import sleep

print("Start date & time " + time.strftime("%c"))
username=("")
channelid=
ball="ub"
myGlobal=0

class MyClient(discord.Client):
    async def on_message(self, message):        
    
     if message.author == self.user:
            return

     if (message.channel.id == channelid):
      embeds = message.embeds
      for embed in embeds:
        footer=str(embed.footer)
        rarity=(footer.find)
        description=str(embed.description)
        name=(description.find)

        if (name("**"+ username + "** found a wild") == -1):
            return

        else:
        
         if (rarity('Common') != -1):
          await message.channel.send("pb")
         
         if (rarity('Uncommon') != -1):
          await message.channel.send("pb")
         
         if (rarity('Rare (27') != -1):
          await message.channel.send("gb")
         
         if (rarity('Super Rare') != -1):
          await message.channel.send("ub")
         
         if (rarity('Legendary') != -1):
            if (name('Articuno') != -1):
                await message.channel.send(ball)
            elif (name('Moltres') != -1):
                await message.channel.send(ball)
            elif (name('Zapdos') != -1):
                await message.channel.send(ball)
            elif (name('Raikou') != -1):
                await message.channel.send(ball)
            elif (name('Entie') != -1):
                await message.channel.send(ball)
            elif (name('Suicune') != -1):
                await message.channel.send(ball)
            elif (name('Lugia') != -1):
                await message.channel.send(ball)
            elif (name('Ho-oh') != -1):
                await message.channel.send(ball)
            elif (name('Regirock') != -1):
                await message.channel.send(ball)
            elif (name('Regice') != -1):
                await message.channel.send(ball)
            elif (name('Registeel') != -1):
                await message.channel.send(ball)
            elif (name('Kyogre') != -1):
                await message.channel.send(ball)
            elif (name('Groudon') != -1):
                await message.channel.send(ball)
            elif (name('Latias') != -1):
                await message.channel.send(ball)
            elif (name('Latios') != -1):
                await message.channel.send(ball)
            elif (name('Deoxys') != -1):
                await message.channel.send(ball)
            elif (name('Uxie') != -1):
                await message.channel.send(ball)
            elif (name('Mesprit') != -1):
                await message.channel.send(ball)
            elif (name('Azelf') != -1):
                await message.channel.send(ball)
            elif (name('Palkia') != -1):
                await message.channel.send(ball)
            elif (name('Heatran') != -1):
                await message.channel.send(ball)
            elif (name('Regigigas') != -1):
                await message.channel.send(ball)
            elif (name('Cresselia') != -1):
                await message.channel.send(ball)
            elif (name('Cobalion') != -1):
                await message.channel.send(ball)
            elif (name('Terrakion') != -1):
                await message.channel.send(ball)
            elif (name('Virizion') != -1):
                await message.channel.send(ball)
            elif (name('Tornadus') != -1):
                await message.channel.send(ball)
            elif (name('Thundurus') != -1):
                await message.channel.send(ball)
            elif (name('Reshiram') != -1):
                await message.channel.send(ball)
            elif (name('Landorus') != -1):
                await message.channel.send(ball)
            elif (name('Xerneas') != -1):
                await message.channel.send(ball)
            elif (name('Yveltal') != -1):
                await message.channel.send(ball)
            elif (name('Celebi') != -1):
                await message.channel.send(ball)
            elif (name('Zygarde') != -1):
                await message.channel.send(ball)
            else:
                await message.channel.send("mb")

        if (rarity('Shiny (Full-odds') != -1):
         await message.channel.send("mb")
            
        if (rarity('Shiny') != -1):
         await message.channel.send("mb")

        global myGlobal
        myGlobal += 1
        print (("Current date & time |" + time.strftime("%c")) + "| Encounters : " + (str(myGlobal)))

        sleep(8.25)
        await message.channel.send(";p")
        
client = MyClient()
client.run('')```

## Expected Results
##### My bot should run properly

## Actual Results
##### it is giving an error

## System Info
##### Run `python -m discord --version` and paste the information below.

Paste here

Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.9/runpy.py", line 188, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/app/.heroku/python/lib/python3.9/runpy.py", line 147, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/app/.heroku/python/lib/python3.9/runpy.py", line 111, in _get_module_details
    __import__(pkg_name)
  File "/app/.heroku/python/lib/python3.9/site-packages/discord/__init__.py", line 61, in <module>
    from .accounts import Account
ModuleNotFoundError: No module named 'discord.accounts'

## Checklist
##### Let's make sure this issue is valid!
<!--- To check something, put an x in the box, like this: [x] -->
- [x ] I am using the latest released version of the library.
- [ x] I am using a user token.
- [x ] I have shown the entire traceback and exception information.
- [ x] I've removed my token from any code.

## Additional Information
##### Put any extra context, weird configurations, or other important info here.

[BUG] Changes to Online Status

Summary

It appears that starting a selfbot changes my status to Online

Reproduction Steps

How did you make it happen?
  1. Start a Selfbot
  2. Status set to Online

Code

Relevant code that shows the bug.
import discord
from discord.ext import commands

bot = commands.Bot(command_prefix=">", self_bot=True)


@bot.command()
async def ping(ctx):
    await ctx.send("pong")


bot.run("MY_TOKEN")

Tested on two tokens just in case.

Expected Results

My current status is not changed from 'Do not Disturb', 'Idle', etc. to 'Online'

Actual Results

The following error is sent (commands work):

My status is changed to Online

System Info

Run python -m discord --version and paste the information below.
- Python v3.8.8-final
- discord.py-self v1.9.0-final
- aiohttp v3.7.4.post0
- system info: Windows 10 10.0.19041

Checklist

Let's make sure this issue is valid!
  • I am using the latest released version of the library.
  • I am using a user token.
  • I have shown the entire traceback and exception information.
  • I've removed my token from any code.

Additional Information

> MY_TOKEN refers to an actual token.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.