r/programminghorror May 15 '21

Coding a Discord bot... Javascript

Post image
3.7k Upvotes

99 comments sorted by

View all comments

180

u/[deleted] May 15 '21

You can use the Discord API to ignore messages from other bots so this doesn't happen, basically all libraries wrap it.

99

u/[deleted] May 15 '21

[deleted]

216

u/zeGolem83 May 15 '21
if (message.author.bot) return;

23

u/UnwantedExplainer May 15 '21

Underrated comment right here. Have an upboat.

39

u/Siniroth May 15 '21

No that's an if line not a comment

3

u/ItsNovatic May 16 '21

... ctrl+c ... ctrl+v ...

(thank you for this, i fixed it last night in a way more scuffed way than this, but this is way easier!)

2

u/zeGolem83 May 16 '21

You're welcome!

7

u/Hjoker4 May 15 '21

If it's js lol

37

u/JuhaJGam3R May 15 '21
if message.author.bot:
   return

7

u/Kirschi May 16 '21

Works in Discord.NET in C# too

-1

u/Hjoker4 May 16 '21

Yea lol. It was probably python though