# Get and use the username of someone who subscribes

**URL:** <https://discuss.dev.twitch.com/t/get-and-use-the-username-of-someone-who-subscribes/29685>\
**Category:** API\
**Created:** [December 29, 2020, 4:13pm UTC](https://discuss.dev.twitch.com/t/get-and-use-the-username-of-someone-who-subscribes/29685 "2020-12-29T16:13:34Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![nust](https://avatars.discourse-cdn.com/v4/letter/n/c6cbf5/32.png) [@nust](https://discuss.dev.twitch.com/u/nust)\
**Post date:** [December 29, 2020, 4:13pm UTC](https://discuss.dev.twitch.com/t/get-and-use-the-username-of-someone-who-subscribes/29685/1 "2020-12-29T16:13:34Z")

</div>

Hello,

Today i’m trying to make something for my Twitch channel and I need to get the username of the viewers who sub and then display it in a message.

I tried to find out on the documentation how to do it, but after many hours, I can’t.

Any insight you can provide I would greatly appreciate.  
N.

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [December 29, 2020, 5:27pm UTC](https://discuss.dev.twitch.com/t/get-and-use-the-username-of-someone-who-subscribes/29685/2 "2020-12-29T17:27:54Z")

</div>

You can get a “new or returning subscriber” in real time via

- chat (USERNOTICE) - [https://dev.twitch.tv/docs/irc/tags#usernotice-twitch-tags](https://dev.twitch.tv/docs/irc/tags#usernotice-twitch-tags)
- pubsub - [https://dev.twitch.tv/docs/pubsub](https://dev.twitch.tv/docs/pubsub)
- webhooks - [https://dev.twitch.tv/docs/api/webhooks-guide](https://dev.twitch.tv/docs/api/webhooks-guide)

---

<div class="post-metadata">

**Author:** ![nust](https://avatars.discourse-cdn.com/v4/letter/n/c6cbf5/32.png) [@nust](https://discuss.dev.twitch.com/u/nust)\
**Post date:** [December 29, 2020, 10:44pm UTC](https://discuss.dev.twitch.com/t/get-and-use-the-username-of-someone-who-subscribes/29685/3 "2020-12-29T22:44:23Z")

</div>

I’m really sorry, but I have been trying for hours now, and i still can do it.  
Is that possible that you write me the code so I can better understand ?

Sorry, but thanking you in advance,

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [December 29, 2020, 10:45pm UTC](https://discuss.dev.twitch.com/t/get-and-use-the-username-of-someone-who-subscribes/29685/4 "2020-12-29T22:45:51Z")

</div>

> [@nust](#):
>
> Is that possible that you write me the code so I can better understand ?

What do you currently have that isn’t working.

Are you trying to use chat, pubsub or webhooks?

---

<div class="post-metadata">

**Author:** ![nust](https://avatars.discourse-cdn.com/v4/letter/n/c6cbf5/32.png) [@nust](https://discuss.dev.twitch.com/u/nust)\
**Post date:** [December 29, 2020, 10:50pm UTC](https://discuss.dev.twitch.com/t/get-and-use-the-username-of-someone-who-subscribes/29685/5 "2020-12-29T22:50:03Z")

</div>

I’m trying to check when someone subs

> client.on(“subscription”, (channel, username, method, message, userstate) =\> {  
> if (self) { return; }  
> whisperSomeone(username);

and I want to get something like this that i can use in an other part of the code :

> ${username}

By the way, i am really sorry if it’s confusing, i’m new in development and i try things ☹

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [December 29, 2020, 10:51pm UTC](https://discuss.dev.twitch.com/t/get-and-use-the-username-of-someone-who-subscribes/29685/6 "2020-12-29T22:51:40Z")

</div>

Ah that looks like you are trying to use tmi.js

And then trying to whisper them

TLDR, don’t bother. Bots cannot whisper (generally speaking).  
You’ll get stuck in the spam black box of doom and not be able to send whispers. Whispers are not intended to be used by bots. It’s been ruined by spammers

---

<div class="post-metadata">

**Author:** ![nust](https://avatars.discourse-cdn.com/v4/letter/n/c6cbf5/32.png) [@nust](https://discuss.dev.twitch.com/u/nust)\
**Post date:** [December 29, 2020, 10:53pm UTC](https://discuss.dev.twitch.com/t/get-and-use-the-username-of-someone-who-subscribes/29685/7 "2020-12-29T22:53:56Z")

</div>

Oh no that was not what i was trying. I thought whisper meant using the name as a general thing that can be re-used. What i intended to do, is to quote them in the chat. I mean, caught their nickname and display into chat.

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [December 29, 2020, 10:56pm UTC](https://discuss.dev.twitch.com/t/get-and-use-the-username-of-someone-who-subscribes/29685/8 "2020-12-29T22:56:25Z")

</div>

According to the docs your code appears correct.

But I don’t use tmi.js

> <https://github.com/tmijs/docs/blob/gh-pages/_posts/v1.4.2/2019-03-03-Events.md#subscription>

---

<div class="post-metadata">

**Author:** ![nust](https://avatars.discourse-cdn.com/v4/letter/n/c6cbf5/32.png) [@nust](https://discuss.dev.twitch.com/u/nust)\
**Post date:** [December 29, 2020, 10:59pm UTC](https://discuss.dev.twitch.com/t/get-and-use-the-username-of-someone-who-subscribes/29685/9 "2020-12-29T22:59:47Z")

</div>

Would you recommand me to try with chat to do it easier?  
And is there a simple way to do it?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [December 29, 2020, 11:00pm UTC](https://discuss.dev.twitch.com/t/get-and-use-the-username-of-someone-who-subscribes/29685/10 "2020-12-29T23:00:51Z")

</div>

if you intent is to @ the user who is sunscribeing then chat is the way to go. I just never use a library to talk to chat.

---

<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:** [January 28, 2021, 11:00pm UTC](https://discuss.dev.twitch.com/t/get-and-use-the-username-of-someone-who-subscribes/29685/11 "2021-01-28T23:00:55Z")

</div>

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