Get and use the username of someone who subscribes

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.

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

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,

What do you currently have that isn’t working.

Are you trying to use chat, pubsub or webhooks?

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 :frowning:

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

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.

According to the docs your code appears correct.

But I don’t use tmi.js

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

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.

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