# Get username of someone who sent a command (javascript)

**URL:** <https://discuss.dev.twitch.com/t/get-username-of-someone-who-sent-a-command-javascript/28916>\
**Category:** Chat and IRC\
**Created:** [November 5, 2020, 3:05am UTC](https://discuss.dev.twitch.com/t/get-username-of-someone-who-sent-a-command-javascript/28916 "2020-11-05T03:05:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![clockwork\_turtle](https://avatars.discourse-cdn.com/v4/letter/c/ecccb3/32.png) [@clockwork\_turtle](https://discuss.dev.twitch.com/u/clockwork_turtle)\
**Post date:** [November 5, 2020, 3:05am UTC](https://discuss.dev.twitch.com/t/get-username-of-someone-who-sent-a-command-javascript/28916/1 "2020-11-05T03:05:00Z")

</div>

Hello,  
I am currently coding a bot for my twitch channel. I am pretty new to coding and I am using this to practice/get better at coding. I am trying to make a command that on use takes the username of the person who typed the command and along with a random number generator gives an output. The problem I am having is that I don’t know how to get the username of the person who typed the command. The rest of the command is working perfectly. All help is greatly appreciated.

---

<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:** [November 5, 2020, 12:18pm UTC](https://discuss.dev.twitch.com/t/get-username-of-someone-who-sent-a-command-javascript/28916/2 "2020-11-05T12:18:13Z")

</div>

For me in my code I just hit `payload.user` or grab the `display-name` from `payload.tags`

> <https://github.com/BarryCarlyon/twitch_misc/blob/master/chat/chat.js#L180>

So to get the username or display name will depend on your code or if you are using a library refer to the library documentation

---

<div class="post-metadata">

**Author:** ![clockwork\_turtle](https://avatars.discourse-cdn.com/v4/letter/c/ecccb3/32.png) [@clockwork\_turtle](https://discuss.dev.twitch.com/u/clockwork_turtle)\
**Post date:** [November 5, 2020, 6:42pm UTC](https://discuss.dev.twitch.com/t/get-username-of-someone-who-sent-a-command-javascript/28916/3 "2020-11-05T18:42:09Z")

</div>

Thanks this works for me. I really appreciate the help.

---

<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:** [December 5, 2020, 6:42pm UTC](https://discuss.dev.twitch.com/t/get-username-of-someone-who-sent-a-command-javascript/28916/4 "2020-12-05T18:42:13Z")

</div>

Closed on December 5, 2020, 6:42pm UTC

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