Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Channel always none #2409

Closed
HerrHase opened this issue Nov 3, 2019 · 3 comments
Closed

Get Channel always none #2409

HerrHase opened this issue Nov 3, 2019 · 3 comments
Labels
invalid This is not right.

Comments

@HerrHase
Copy link

HerrHase commented Nov 3, 2019

I don't get it, all works, i can see events in "on_message", but when i try to get a specifiy channel, anywhere in the code, the channel is always "none". Public Channels and Private Channels they seems to not exists.

client = discord.Client()
channel = client.get_channel(12345678)
@apple502j
Copy link
Contributor

get_x and utils.get both return None if they can't find anything matching.
Common causes include:
• Wrong key
◦ Remember, IDs are ints, not strings
◦ If you're trying to copy an emoji ID, right-clicking the emoji in a message will copy message ID
• Bot not logged in, and trying to grab objects from cache
◦ Subvairant, using two client objects. See:?tag botclient
• Bot cannot "see" the object.
◦ It has to be on the server, share a server with the member, etc
◦ If you're sharded on separate processes, each process will only have objects for that shard.
• Objects retuned by fetch_x will not have a populated cache.

Also there is a great place for you to ask questions, at https://discord.gg/dpy - let's join and you can question there. Not here, sorry.

@Harmon758
Copy link
Contributor

There is a reason the issue template for bug reports asks for a full traceback and reproduction steps.
Without the actual code you're running or a reproducible example (MCVE/SSCCE) of what you're trying, it's impossible to determine what your exact issue is. Your provided example will always set channel to None, as 12345678 is not a valid ID.
As explained, you're likely providing an invalid ID or an ID for a channel the client/bot cannot see.

@HerrHase
Copy link
Author

HerrHase commented Nov 4, 2019

Damn! A little misunderstanding, my script is in a Class and i try this,

#
#
#
#
class MrDoorbell(discord.Client):

    #
    #
    #
    async def on_ready(self):
        client = discord.Client()
        channel = client.get_channel(12345678)

Of course it don't work. Sorry! Now it works fine with self.get_channel() ;-)

@HerrHase HerrHase closed this as completed Nov 4, 2019
@dpy-manager-bot dpy-manager-bot added the invalid This is not right. label Nov 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This is not right.
Projects
None yet
Development

No branches or pull requests

4 participants