# Twitch bot not connecting to channel

**URL:** <https://discuss.dev.twitch.com/t/twitch-bot-not-connecting-to-channel/42919>\
**Category:** Chat and IRC\
**Created:** [January 20, 2023, 10:12pm UTC](https://discuss.dev.twitch.com/t/twitch-bot-not-connecting-to-channel/42919 "2023-01-20T22:12:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![novaevermoon](https://avatars.discourse-cdn.com/v4/letter/n/b77776/32.png) [@novaevermoon](https://discuss.dev.twitch.com/u/novaevermoon)\
**Post date:** [January 20, 2023, 10:12pm UTC](https://discuss.dev.twitch.com/t/twitch-bot-not-connecting-to-channel/42919/1 "2023-01-20T22:12:10Z")

</div>

Hey everyone,

I used to have a fully functional chatbot that I coded from scratch in c# .(don’t ask me why I’m reinventing the wheel and not using an existing library, I like to make things difficult for myself haha)

I stopped streaming for a while and only came back recently and noticed that the APIchanged a bunch and nothing was working anymore. I was able to fix everything, updated my old API calls and now almost everything works as it did before. The only thing I haven’t been able to fix is my bot’s connection to my channel.  
What I mean by that is that, my entire code works as expected, the bot reacts to commands etc but when it sends messages in chat, it does so using my own account and not the one I created to write in chat.

I am connecting to IRC with the bot’s account “thecelestialwarden” but irc responds to my account and every time the bot writes in chat, it is through my own account. I have tried everything, even re-coded just the IRC connection and nothing else to make sure I didn’t change something by accident but I can’t figure out why the account can’t connect. Is there something I’m missing? I’ve searched for a really long time but I have no idea what I’m doing wrong…It’s probably something really easy and dumb but I’m really at a loss there

Here is a bit of code and the console results I get.

I am using the ip: [irc.twitch.tv](http://irc.twitch.tv) and the port: 6667

 ![image](https://d2opxh93rbxzdn.cloudfront.net/original/3X/1/7/17bac554bc53d5f7ab41a83f7256094369f485c2.png)

---

<div class="post-metadata">

**Author:** ![novaevermoon](https://avatars.discourse-cdn.com/v4/letter/n/b77776/32.png) [@novaevermoon](https://discuss.dev.twitch.com/u/novaevermoon)\
**Post date:** [January 20, 2023, 10:13pm UTC](https://discuss.dev.twitch.com/t/twitch-bot-not-connecting-to-channel/42919/2 "2023-01-20T22:13:49Z")

</div>

here is the console result (I wasn’t able to embed it in the original post)

 ![image](https://d2opxh93rbxzdn.cloudfront.net/original/3X/4/6/46380318d9308889564d6b9378daf89c4ca1da19.png)

---

<div class="post-metadata">

**Author:** ![Dist](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/dist/32/7192_2.png) [@Dist](https://discuss.dev.twitch.com/u/Dist)\
**Post date:** [January 20, 2023, 10:19pm UTC](https://discuss.dev.twitch.com/t/twitch-bot-not-connecting-to-channel/42919/3 "2023-01-20T22:19:37Z")

</div>

> [@novaevermoon](#):
>
> I am connecting to IRC with the bot’s account “thecelestialwarden” but irc responds to my account and every time the bot writes in chat, it is through my own account.

That would indicate you are using your own accounts OAuth token, as regardless of what `NICK` you use when connecting, if you’re using the OAuth token from `novaevermoon` going through the OAuth flow, then it’ll be connected as `novaevermoon`. You can confirm this by using your OAuth token with the Validate Tokens endpoint [https://dev.twitch.tv/docs/authentication/validate-tokens/](https://dev.twitch.tv/docs/authentication/validate-tokens/) and it’ll return which use account is associated with that token.

If you want to send messages as `thecelestialwarden`, you need to log in to go through the OAuth flow while logged in to that account, so that account can grant the permissions needed to connect to chat and send messages as it.

---

<div class="post-metadata">

**Author:** ![novaevermoon](https://avatars.discourse-cdn.com/v4/letter/n/b77776/32.png) [@novaevermoon](https://discuss.dev.twitch.com/u/novaevermoon)\
**Post date:** [January 20, 2023, 10:26pm UTC](https://discuss.dev.twitch.com/t/twitch-bot-not-connecting-to-channel/42919/4 "2023-01-20T22:26:50Z")

</div>

Oh.My.God, I feel SO dumb!  
Here is what happens when you leave your code for 2 years and come back to it 🙃

Thank you so much for pointing that out, it’s working now !

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [February 19, 2023, 10:27pm UTC](https://discuss.dev.twitch.com/t/twitch-bot-not-connecting-to-channel/42919/5 "2023-02-19T22:27:48Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
