Categories > Coding > Javascript >
[TUT] How to make a Discord Bot image generator
Posted
So I will be teaching you guys how to make a discord bot that generates a image of that topic
First create a new project in your perferred IDE
Then make a bot on https://discord.com/developers
And create and application Then create the bot part
And paste this code in
https://pastebin.com/raw/P7y9yzbW
You need to install two packages reddit.images and discord.js
On default if you run the bot then say !yuri in the server that it is in it will generate a yuri anime image (You are welcome weebs)
You can change it (I am not gonna explain that because it is simple)
And yeah! Have fun
Credits: Explanation for teaching me this
Edit: Reposted pastebin link because other had a error
Enjoy!
no
Error: The signature must be between 3-200 characters
Replied
Not the best tutorial. Pasting code is not the way. You should explain what is happening in the code.
Cancel
Post
Replied
very bad tut, copy and pasting isnt the way to go, i tryed my best to explain with whats going on but i suck as at js and mostly do c# or lua but yh no
identifier:
const Discord = require("discord.js") //discord,js the language your building the bot
const client = new Discord.Client(); //client
const redditimage = require("reddit.images"); //able to get the images from reddit
const prefix = "!" //prefix for commands
loaded:
client.on("ready", () => { // when the client is ready/loaded
console.log(`Logged in as ${client.user.tag}`) // prints
});
command:
client.on('message', async message => { // when a message is sent
let command = message.content
const args = message.content.split(' ');
if (message.author.bot) return;
if (command == `${prefix}yuri`) { // if the command is the prefix and the word "yuri"
try {
let reddit = [
"yuri", //try to search through reddit with tag "yuri"
"yuri",
"yuri"
]
let subreddit = reddit[Math.floor(Math.random() * reddit.length)];
await redditimage.fetch({
type: "custom",
total: 1,
subreddit: [`${subreddit}`],
}).then((result) => {
message.channel.send(`Subreddit: /r/${result[0].subreddit} \nTitle name: ${result[0].title} \n ${result[0].image} \n Upvotes: ${result[0].upvotes} \n
Downvotes: ${result[0].downvotes} \n Author: https://www.reddit.com/user/${result[0].author}/`) // posts in that channel with the title of the post, the image, the amount of upvots and downvotes and the person that posted that image
});
} catch (err) {
console.log(err) // any errors found it prints it
}
}
});
token:
client.login("bot token here"); //turns on the client/bot with its token
tryed my best with explantion of each parts, someone like ducky could do better then me or someone with better js knowledge
Cancel
Post
https://media.discordapp.net/attachments/1010636204225601659/1012865624797610044/sKQybOLT.gif
no
Error: The signature must be between 3-200 characters
Replied
hello welcome to the best tutorial ever about how to make a discord bot!
open ur IDE, you totally know what an IDE is
go to this URL and make a bot, you totally know how'
paste this code somewhere, you totally know where
instal two packages, reddit.images, discord.js, once again you definitely know how to do that if you're following the tutorial
THEN USE THE BOT
and if you wanna change it well do it yourself, im not gonna explain how and by reading this you will DEFINITELY know how to do it yourself
and we're not gonna mention the deps you gotta install thats up to you to figure out good luck :))))
Cancel
Post
My new discord is Wabz#1337 with ID 777154062789509130
Replied
@Wabz Thanks for this awesome tutorial! This really had some good explanation in it!!!!
Cancel
Post
Learning C++, C#, JavaScript Developer
I develop random stuff
Discord: Unidentified#1091
no
Error: The signature must be between 3-200 characters
Learning C++, C#, JavaScript Developer
I develop random stuff
Discord: Unidentified#1091
no
Error: The signature must be between 3-200 characters
Replied
Horrible tutorial.
First of all, this isn't your code. It's copied.
Second of all, this code wont even work by pasting it because you didn't tell people to install the module/package it requires.
Third, this isn't even a generator. It's a random Reddit image fetcher.
Cancel
Post
no
Error: The signature must be between 3-200 characters
Users viewing this thread:
( Members: 0, Guests: 1, Total: 1 )
Cancel
Post