Ask coding questions

← Back to all posts
How to get a channel inside on_message without bot |
DwellerIgor (1)

Hello! It is me again. File from line 87 to 99. I have a function that adds credits to someone when they send a message and I have a spam-channel, so I don't want people to farm credits in spam-channel.

I did: channel = discord.utils.get(message.guild.channels, id = 819705815090200646) if != 819705815090200646: await self.add_credits( print("yes2")

But the bot doesn't any add any credits this way in ANY channel. And if I type else: then bot adds credits in every channel, so the bot thinks that every channel has the same id. I need one specific channel where you don't get the credits, but you do in others.

Thank you! Sorry for bothering you!
P.S. Coder100 thank you already!

Coder100 (18882)

but you can also do print( to debug what is!

Coder100 (18882)

I believe you should compare it with the string version, like this:

if != '819705815090200646': await self.add_credits( print("yes2")

i do believe that is a string and of course a number will never equal a string

DwellerIgor (1)

hello! sorry for answering too late, but no. This is not the case. When I print it gives me the same id channel has, but I need that credits function doesn't work in this channel, but it somehow works. I also tried string, but I get the same result. The bot checks channel, but he ignores !=. Is there any other way of doing this? Thanks @Coder100

Coder100 (18882)

did you read my other answer
it will provide valuable insight. @DwellerIgor

DwellerIgor (1)

are you talking about print( answer? i read both @Coder100

DwellerIgor (1)

nice i fixed that: if != await self.add_credits( @Coder100

DwellerIgor (1)

is there any course to learn python very good, because im kinda ok, but i want to be better @Coder100

Coder100 (18882)

you can search one up on google -- they'll all work I suppose @DwellerIgor