# Ban Reason show null or n/a in my Bot

**URL:** <https://staging-discuss.dev.twitch.com/t/ban-reason-show-null-or-n-a-in-my-bot/19517>\
**Category:** Chat and IRC\
**Created:** [January 15, 2019, 7:50pm UTC](https://staging-discuss.dev.twitch.com/t/ban-reason-show-null-or-n-a-in-my-bot/19517 "2019-01-15T19:50:16Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![AbstellkammerTv](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/abstellkammertv/32/5651_2.png) [@AbstellkammerTv](https://staging-discuss.dev.twitch.com/u/AbstellkammerTv)\
**Post date:** [January 15, 2019, 7:50pm UTC](https://staging-discuss.dev.twitch.com/t/ban-reason-show-null-or-n-a-in-my-bot/19517/1 "2019-01-15T19:50:16Z")

</div>

Hello everyone,

my english is very bad and for that i want to apologize first.  
I hope you still understand me.

I want to intercept the ban reason about my bot.  
But it always gets to me “null” in my DB or “n/a”.

I tried it with “/ban \<username\> \<reason\>” like this “/ban me\_123\_test this is a test”  
My Bot is Mod and can Ban too. But don’t show my reason.

What is wrong ?

with friendly greetings from Germany

---

<div class="post-metadata">

**Author:** ![WLTN1](https://avatars.discourse-cdn.com/v4/letter/w/7feea3/32.png) [@WLTN1](https://staging-discuss.dev.twitch.com/u/WLTN1)\
**Post date:** [January 15, 2019, 9:36pm UTC](https://staging-discuss.dev.twitch.com/t/ban-reason-show-null-or-n-a-in-my-bot/19517/2 "2019-01-15T21:36:48Z")

</div>

When its a bot, from irc, command must start with “.”, not with “/”. Like “.ban me\_123\_test this is test”

---

<div class="post-metadata">

**Author:** ![AbstellkammerTv](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/abstellkammertv/32/5651_2.png) [@AbstellkammerTv](https://staging-discuss.dev.twitch.com/u/AbstellkammerTv)\
**Post date:** [January 15, 2019, 9:43pm UTC](https://staging-discuss.dev.twitch.com/t/ban-reason-show-null-or-n-a-in-my-bot/19517/3 "2019-01-15T21:43:49Z")

</div>

Thank you for your reply … this dosnt work too … Same problem 😕

EDIT: My Code -  
var tmi = require(‘tmi.js’);  
var options = {  
options: {  
debug: true  
},  
connection: {  
cluster: “aws”,  
reconnect: true  
},  
identity: {  
username: “BOT\_NAME”,  
password: “oauth:MY\_PW”  
},  
channels: [“test\_user”]  
};  
var client = new tmi.client(options);  
client.connect();  
client.on(“ban”, function (channel, username, reason) {   
console.log("User " + username + " banned in " + channel + ". (Reason: " + reason + “)”);  
});

Output: User test\_123 banned in test\_user. (Reason: null)

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [January 16, 2019, 12:26am UTC](https://staging-discuss.dev.twitch.com/t/ban-reason-show-null-or-n-a-in-my-bot/19517/4 "2019-01-16T00:26:47Z")

</div>

Check out

> [@In-line broadcaster chat mod logs](https://staging-discuss.dev.twitch.com/t/in-line-broadcaster-chat-mod-logs/7281):
>
> Hi, We’ve developed a small update for chat that you might be able to do things™ with if you so choose. A user will attempt to send listen (with an oauth token) on a [pubsub](https://github.com/justintv/Twitch-API/tree/master/PubSub) topic chat\_moderator\_actions.{user\_id}.{room\_id} room\_id is the user\_id of the user that owns the room (in most cases the broadcaster’s user ID). If that user is the broadcaster or a mod of the room they will receive messages containing a type of chat\_login\_moderation or chat\_channel\_moderation as well as some associated …

I went digging, it got moved from TMI to PubSub.

Which be why it’s not in the docs either.

There is a discussion thread on the matter from 2016, which basically says “use pubsub”

---

<div class="post-metadata">

**Author:** ![AbstellkammerTv](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/abstellkammertv/32/5651_2.png) [@AbstellkammerTv](https://staging-discuss.dev.twitch.com/u/AbstellkammerTv)\
**Post date:** [January 16, 2019, 11:36am UTC](https://staging-discuss.dev.twitch.com/t/ban-reason-show-null-or-n-a-in-my-bot/19517/5 "2019-01-16T11:36:41Z")

</div>

Hello BarryCarlyon,

thank you for your Reply… pubsub isn’t reachable at the link (404 - This is not the web page you are looking for.)  
I try google with the query “pubsub” but was not successful. 🙄

I’m probably too stupid 🤔

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [January 16, 2019, 11:37am UTC](https://staging-discuss.dev.twitch.com/t/ban-reason-show-null-or-n-a-in-my-bot/19517/6 "2019-01-16T11:37:59Z")

</div>

PubSub is documented here:

> **[PubSub](https://dev.twitch.tv/docs/pubsub/)**
>
> PubSub Guide

The pubsub topic for moderation actions in the linked thread

---

<div class="post-metadata">

**Author:** ![AbstellkammerTv](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/abstellkammertv/32/5651_2.png) [@AbstellkammerTv](https://staging-discuss.dev.twitch.com/u/AbstellkammerTv)\
**Post date:** [January 16, 2019, 11:39am UTC](https://staging-discuss.dev.twitch.com/t/ban-reason-show-null-or-n-a-in-my-bot/19517/7 "2019-01-16T11:39:29Z")

</div>

Holy moly … very fast reaction … thank you … I will read it to myself and contact again if I can not get any further

---

<div class="post-metadata">

**Author:** ![3ventic](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/3ventic/32/298_2.png) [@3ventic](https://staging-discuss.dev.twitch.com/u/3ventic)\
**Post date:** [January 16, 2019, 3:02pm UTC](https://staging-discuss.dev.twitch.com/t/ban-reason-show-null-or-n-a-in-my-bot/19517/8 "2019-01-16T15:02:42Z")

</div>

The `ban-reason` tag was a month or two ago removed from IRC and the reason is right now only available via the above-mentioned pubsub topic.

---

<div class="post-metadata">

**Author:** ![AbstellkammerTv](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/abstellkammertv/32/5651_2.png) [@AbstellkammerTv](https://staging-discuss.dev.twitch.com/u/AbstellkammerTv)\
**Post date:** [January 16, 2019, 4:03pm UTC](https://staging-discuss.dev.twitch.com/t/ban-reason-show-null-or-n-a-in-my-bot/19517/9 "2019-01-16T16:03:53Z")

</div>

Hello, i have try to understand this “pubsub” but it’s for me a horror.  
I want to understand it, but it does not work.

Can some one help me with a litle code for Ban Events?

---

<div class="post-metadata">

**Author:** ![AbstellkammerTv](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/abstellkammertv/32/5651_2.png) [@AbstellkammerTv](https://staging-discuss.dev.twitch.com/u/AbstellkammerTv)\
**Post date:** [January 19, 2019, 5:21pm UTC](https://staging-discuss.dev.twitch.com/t/ban-reason-show-null-or-n-a-in-my-bot/19517/10 "2019-01-19T17:21:07Z")

</div>

Hmm… ok no one can help ?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [January 19, 2019, 5:22pm UTC](https://staging-discuss.dev.twitch.com/t/ban-reason-show-null-or-n-a-in-my-bot/19517/11 "2019-01-19T17:22:48Z")

</div>

Documentation is here:

> **[PubSub](https://dev.twitch.tv/docs/pubsub/)**
>
> PubSub Guide

PubSub is a industry stnadard communication method, so whichever programming language you prefer likely already has in implementation of PubSub as a library you can include.

I can’t just give you some code, without knowing a language preference or what you intended to then do with the collected information.

---

<div class="post-metadata">

**Author:** ![AbstellkammerTv](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/abstellkammertv/32/5651_2.png) [@AbstellkammerTv](https://staging-discuss.dev.twitch.com/u/AbstellkammerTv)\
**Post date:** [January 19, 2019, 6:44pm UTC](https://staging-discuss.dev.twitch.com/t/ban-reason-show-null-or-n-a-in-my-bot/19517/12 "2019-01-19T18:44:49Z")

</div>

Yea, i have try to understand this but its for me a horror. I want to understand it, but it does not work. I try to code in NodeJS a Bot for my Channel how can listen " .on(“ban”, …) " and insert this banned user in a DB with original ban reason.

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [January 19, 2019, 6:59pm UTC](https://staging-discuss.dev.twitch.com/t/ban-reason-show-null-or-n-a-in-my-bot/19517/13 "2019-01-19T18:59:07Z")

</div>

Well it sounds like your bot is already connected to TwitchChat over IRC.

So you will need to make a second connection to PubSub and then you will need to parse the response information pushed to you.

---

<div class="post-metadata">

**Author:** ![system](https://d2spem0quai2ol.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://staging-discuss.dev.twitch.com/u/system)\
**Post date:** [February 18, 2019, 6:59pm UTC](https://staging-discuss.dev.twitch.com/t/ban-reason-show-null-or-n-a-in-my-bot/19517/14 "2019-02-18T18:59:12Z")

</div>

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