#development
1 messages · Page 634 of 1
yes
Thanks
@pallid zinc setInterval
message.channel.send("(~‾▿‾)~ ")
.then(msg => {
msg.edit("~(‾▿‾~) ")
}, 15000) // time in ms 15000 = 15s
}
Or this
thanks it is done
This "Code" creates/sets Override for all channels, right?
message.guild.channels.forEach(async (channel, id) => {
await channel.overwritePermissions(Muterole, {
SEND MESSAGES: false,
ADD_REACTIONS: false,
SEND TTS MESSAGES: false,
ATTACH_FILES: false,
SPEAK: false```
try {
yourCode();
} catch (error) {
if (error) comeBackAndTellTheError();
else TellWhatHappened();
}
OwO
iframe
html styling
Well if you already have one then iframe is the way to go 
yes just do probably what kef said
I think that's only available to cert devs though? Not quite sure
javascript is cert dev only
Yeah iframe is a part of html since the beginning of time I think lol
What page are you trying to embed?
a specific page i want to say, but i cant
DM it to me
Sure
actually i found the solution just now
it's on cloudflare's side
they block Iframe requests
There you go
you seen similiar issues?
No not really. Didn't even think about cloudflare blocking iframes before
alright nvm its on discordbot's side
due to ssl key not being the same origin between the servers
basically
user -> discordbots -> cloudflare -> server
doesnt work
however user -> cloudflare -> server do work
That's odd
indeed
i wonder would me stripping off my entire html/css (except for hyperlinks) work
or would it cause issues
i mean other way is to disable SAMEORIGIN parameter in my SSL
You can add the entire html/css to your description, but I'm pretty sure there's a way around it
What exactly does it show you when you add it? 
Can't you add discordbots.org as an exception or something?
no its not an optional setting that u can change around
it's either on or off for all sites
Hmm
here's the differences
and cause it cant verify the cert on the discordbots side (due to 2 request in one go)
and discordbots (client) is the one who gets access, but not the user
it doesn't work
that's agony, my htaccess file, wherever i put it now again
What is the code for guildBannerURL in stable?
I just know there's a bannerURL in master
What lib and lang?
discord.js
should i use 11.5-dev
It’s not supported in stable
Oh
Either go master or do fetches yourself to resolve banner URL’s
I will use 11.5-dev
@pale marsh it should work by default
my server doesnt use htaccess
its some outdated bs from apache2
i use nginx
I wouldn't really know tbh. Not an expert when it comes to this 
i see, well thanks anyways doe ^^
Anytime
Wrong channel
^
so which channel>?
we aren't the support server for a specific bot
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
.
Please don't post dots, especially outside of #memes-and-media
Anyone have a clue on how to use axios?
Im unsure and Ive been trying to figure it out
One message removed from a suspended account.
One message removed from a suspended account.
Boi calm down
Oh alright I was just asking
I know it's a whitename but be nice qwq
^ 
One message removed from a suspended account.
What do you need to do on axios?
I just wanna get the data on the JSON file for the bot to output it
Im probably doing something wrong here -> https://gyazo.com/0bfd00bd9241b291212a8062b5b95851
Quick question, Does anyone know a useful database for storing a json array? I used mysql but for a music command and persistent queue it's not very good.
.then and await both work with promises
Yeah I know. But they're required with Keyv?
if you dont await a promise or use .then the other code will just continue running which could cause errors
Depends on whether you want to have persistence of the queue or not after reboots/crashes/etc
If thats your issue then keep it in memory and update the entire array after every new song/command
Just write over it
if(command === "roleinfo"){
let inline = true
let role = args.join(` `)
if(!role) return message.reply("Specify a role!");
let gRole = message.guild.roles.find(`name`, role);
if(!gRole) return message.reply("Couldn't find that role.");
const status = {
false: "No",
true: "Yes"
}
let roleemebed = new Discord.RichEmbed()
.setColor("#00ff00")
.addField("ID", gRole.id, inline )
.addField("Name", gRole.name, inline)
.addField("Mention", `\`<@${gRole.id}>\``, inline)
.addField("Hex", gRole.hexColor, inline)
.addField("Members", gRole.members.size, inline)
.addField("Position", gRole.position, inline)
.addField("Hoisted", status[gRole.hoist], inline)
.addField("Mentionable", status[gRole.mentionable], inline)
.addField("Managed", status[gRole.managed], inline)
message.channel.send(roleemebed);
}
why the bot don't detect me the role?
who helps?
well first of all, .find takes a function
and let gRole = message.guild.roles.find(gRole => gRole.name == role.name);
Because the way you do it is deprecated.
no worries
How do create a webhook for a bot, to use, me and @bitter night are creating a moniter bot that will send status of the bot to a certain channel.
We've made a script m>ons that will make us say the status.
So you want to receive webhooks in your bot itself?
What language is it written in?
Create a simple http server in the same instance that's running the bot
Sure. Don't leak tokens or anything sensitive though
Ive got a question
I managed to get the data to log on console but how do I output the data in chat
Ahhh alright Ill try that thanks
you could use a GET/POST statement if that's what you are doing
probably because its too long
oh yea the bottom one wont send without await
It is VERY long
well do you want to send that? seems unlikely
I just want it to output "data:"
its probably an object
you can navigate it like other objects
Id like it to output this, do you know how to output specifically this?
well it depends whats around it lol
stick it under the console log?
stick it under?
as in
console.log(data)
the line under console.log(response)
do
message.channel.send(JSON.stringify(response.data))
nice
Thanks a bunch as I've been racking my brains about this for about 30 minutes
axios is asynchronous, the way you had it before there was no reference to response.data
it has to go inside of the .then clause
Ahhh
it was probably crashing saying response wasnt defined
Yeah most likely
well you tell me, ur the onethat ran it lol
Yup it works perfectly, its giving the string of data I was looking for
But what if I wanted to specifically get a string
{"level":24,"gender":"Male","player_id":2261231,"name":"Scottish","status":["Okay",""]}
Like if I wanted to get 24
I did it and it works
I understand how the code works thanks for teaching me
Tutorials online are waaaay harder to understand
not sure what tutorial you're looking at
now for a slight challenge, get "okay" from your response
yeah use ^ if you wanna work with embeds
but they expect you know something about js already so maybe check out codecademy first
or get data from discord
Works like a charm
🤔 with code or with an echo command
what'd u do?
I changed level to status
should be .status[0] because its in an array
<@&265158261945270273> Can you help me with something with my bot? because it keeps saying invalid server format and i dont know what that means.
ye should be [0]
<@&264889767072628742> Can you help me with something with my bot? because it keeps saying invalid server format and i dont know what that means.
Please
lol
Yikers
@modern sable Thanks For The Help!
:v
oh boy
I got one last question, how do I make the bot output a string of data every 6 hours?
I heard its called a scheduler or something
Set an interval
function doThing() {
//do some cool things
}
doThing()
setInterval(doThing, 6 * 60 * 60 * 1000)```
or alternatively, cron jobs
Alright thanks
I think Im doing something wrong here
SyntaxError: Lexical declaration cannot appear in a single-statement context
at Module._compile (internal/modules/cjs/loader.js:721:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
declare args in a new linejs if (message.content.startsWith("!user")) { let args; }
enclosed in curly braces
Ah
Although I wouldn't re-define args every single time
Just do it at the top and use it for every command.
Ill do that later thanks
I think i got it to work but the command isnt working
let args; message.content.split(" ").slice(1);
}
axios.get("https://api.torn.com/user/" + (args[0]) + "?selections=basic&key=1vpH5bIwSDLfkwX7")
.then(function (response) {
console.log(response)
let x = response.data.level
message.channel.send(x)
})
.catch(function (error) {
console.log(error)
})
.finally(function () {
});```
What's the error?
axios.get("https://api.torn.com/user/" + (args[0]) + "?selections=basic&key=1vpH5bIwSDLfkwX7")
Hmm... you need to put it inside the if statement lol
This part I might be having issues
Or else the GET request won't run when !user is triggered
Im trying to do this
!user 2261231 is run
Axios will go to this page and get the data
Yes, put it inside the curly braces...
if (message.content.startsWith("!user")) {
let args;
axios.get(); // etc
}```
Alright it works but it spits out the same data over and over
let args; message.content.split(" ").slice(1);
axios.get("https://api.torn.com/user/" + (args) + "?selections=basic&key=1vpH5bIwSDLfkwX7")
.then(function (response) {
console.log(response)
let x = response.data.level
message.channel.send(x)
})
.catch(function (error) {
console.log(error)
})
.finally(function () {
});
}```
Why'd u change it from args[0] to args?
I must have removed it
Put it back and try again.
With args it shows up data but the same one with args[0] it shows nothing
Is there an error in the console?
Wait you copied let args word-for-word lmao
So get rid of the ; and replace it with a =
oh
yeah..
Sorry for being a bother pretty new to discord bots and javascript
if it was a big bother we wouldnt respond
dw
use setinterval for a schedule
and settimeout if you just want it to happen once
It works perfectly 😄
Kind of a loaded question here, so I have a leaderboard bot for PUBG which is going to be on a per-server basis. So as users invite the BOT, it will keep a leaderboard keyed in based on their server ID so they only get their own members data.
I have two main questions from this:
-
What is the best way to share a BOT? Right now I gave away the custom discordapi link to a few people to test it out, but I am not sure if that is the best route or if there is a better way to share that?
-
I ideally want to include 8 custom emojis for rank purposes. Obviously that is not ideal as it cannot be assumed the user will see nor import those 8 custom emojis. But if they do (which it works fine without), is there a guideline on the best way to express/share that they should grab those 8 images and turn them into emojis on their server?
Any other first time making a public BOT todos/NotTodos are welcome too so that it plays nicely with everything out there is welcome too!
Thanks! 😃
- go to our website https://discordbots.org and add your bot there to the list. When it's approved it will be publicly available for everyone to add
- bots have one of the nitro features, which is that they're able to use any custom emoji anywhere, provided it's in a server they're in
@stark beacon
- ideally you just give them the invite link to the bot, or make it redirect to the link from your domain such as mycoolbot.com/invite -> invite link
- bots can use emojis by doing
<:emojiname:emojiid>for example:mmLol:
So as long as you have those 8 emotes in your support server, you can grab the emote's name and ID and add it in the format <:emote_name:ID>
So it sounds like I can use a custom emojis in other servers?! that is dope!
You cant
Yup. Only bots and nitro can do this
But your bot can
ahh my b, that is what I meant
If you wanna know the ID of an emote add \ before its name
Or

Just use ``
Two
Nope doesn't work lol
Two on each side
right, so I am trying to figure out that piece, what I currently do is use DiscordJS and
const emojiList = MESSAGE.guild.emojis.map(e => e.toString());
_.each(emojiList, function(e) {
if (e.includes(rank)) {
emoji = e;
}
});
return emoji;
```,
then I just do a string find based on name (as I named them uniquely) what would I need to change?
``:mmLol:``
i mean, you could just use message.guild.roles.find
so will the above work, or do I need to do something a bit different?
Well if you already know the emote name and id and you don't plan on changing them frequently you don't need the loop
Just store them somewhere
The easiest way to deal with that
Okay, so that emoji the <...> it returns works on a global level?
Yea
As long as the bot shares a server with the emote, yes
^
Hmm, I thought it wasn't working in a server until I added those emojis to it. I guess I could go test by removing those emojis from one and seeing what occurs
I store my emotes in two testing servers of mine
random Q while I test this. Will a PI hold old for quite a few servers? It is essentially doing MySQL calls based on user commands and a constant update process to the PUBG's API server for users updates that get pushed into the DB that the user's query. Never done much with BOTs or Pi's until a week ago haha
If you have a good enough internet I don't see why not, as long as you don't do a lot of calculations
okay coolio!
Unless it joins a really big server
Someone a couple of days ago complained that their cpu usage was at 100% almost constantly when the bot joined and got back to normal when it left, which lead to a huge delay for the bot to respond to commands
I was actually talking about here but nvm lmao
Yeah but imagine all those status updates
That one only has bots and like a user
Presence updates*
Yeah
So @stark beacon my advice is, for a new bot a pi is fine. If it's growing you might wanna consider having a vps
luckily for processing, I make users have to add users into the BOT's leaderboard. I just link their PUBG ID to their discord ID
then they do all stats stuff off their discord ID/mention
Alright sounds good then. Doesn't seem like a lot would be happening behind the scenes
For some reason discord is telling me it cant post an empty message
let args = message.content.split(" ").slice(1);
axios.get("https://api.torn.com/user/" + (args[0]) + "?selections=basic&key=1vpH5bIwSDLfkwX7")
.then(function (response) {
console.log(response)
let q = response.data.name
let w = response.data.gender
let e = response.data.level
let r = response.data.status
let x = {
title: "Information: " + (q),
url: "https://www.torn.com/profiles.php?XID=" + (args[0]),
color: 1000,
description: (q) + " is a " + (w) + " and his level is " + (e) + " and he is currently " + (r) + ".",
};
message.channel.send(x)
.catch(function (error) {
console.log(error)
})
.finally(function () {
})
})
}
})```
You can't just send an object
you cant post a message with an empty string
Also if that is supposed to be an embed object then you have to do send({embed: x})
also thats an object you need to make it a string
Okay I am back, so yea, if I remove the custom icons from one server they do not show up in that server as of right now (even though it sounds like they should as the BOT share's a server that does have them), they currently print out as something like <elite:588031542660562984>
okay weird, there is a colon before elite but then it removes the numbers
<: elite : 588031542660562984> without spaces
So should this be working? or am I missing a step?
I added half the icons back and those half work, so I guess I am not sure what is off for the other custom icons to not be working? 🤔 Any ideas, @pale marsh?
@stark beacon there is a colon around the elite like
:elite:
And the ID goes after that in the brackets
yup
that is what my log prints
and I am putting within text in an {embed}
if the icon is on the server it prints correctly like this
but when I removed half the icons (from one of the servers), only the remaining half show up... so I am not sure what is going on..
so short-hand of the code looks like this
fields.push({
'name': r.PUBGName,
'value': getRankEmoji(r.PUBGSquadRankPointsTitle) + "...other stuff"
});
function getRankEmoji(rankstr) {
const emojiList = MESSAGE.guild.emojis.map(e => e.toString());
let emoji = "";
rank = RANKS[rank].name.toLowerCase()
_.each(emojiList, function(e) {
if (e.includes(rank)) {
emoji = e;
}
});
//:elite: (for example)
return emoji;
}
@west spoke
@stark beacon I'm confused. Wdym by when you remove half the emotes only half shows up?
Also editing messages to add a mention doesn't ping lol
oh really?? I never knew that haha my b
It's alright lol
I mean't I have two servers with the icons. On one I removed half the custom icons. The ones I removed no longer appear even though the other server has them
Because they're different id's even though they have the same name
That's why you need the emote name and the ID
Only keep the emotes on one server and remember that if you remove an emote and reupload it the ID changes
okay, so I just removed all emotes on one of the servers. I then had it print out all the emotes. so I can just key/value to what I need and it should work? like this?
const CUSTOM_ICONS = {
"platinum": ":platinum:",
"silver": ":silver:",
"bronze": ":bronze:",
"diamond": ":diamond:",
"energydrink": ":energydrink:",
"bandage": ":bandage:",
"grenade": ":grenade:",
"medic": ":medic:",
"teamkiller": ":teamkiller:",
"sharpshooter": ":sharpshooter:",
"headshot": ":headshot:",
"ironman": ":ironman:",
"gold": ":gold:",
"elite": ":elite:",
"master": ":master:",
"grandmaster": ":grandmaster:",
}
wow it cut out the numbers
bc discord
Upload to hastebin.com
Alright looks good then
so I can put those <...> inline of description, title, fields[], and it should work?
Yup. Give it a try
will do, brb
@stark beacon it's because you removed them
Anytime
The intro docs just tell you what calls to use to get the api.
For example to get last message:
/api/channels/"id"["last-message"]
I would reccomend not using Google apps scripts tho. Use a free hoster first then move over to paid.
Since what it seems it doesnt support what you need.
Also most of what you asked could be found by going through google.
It's a example
One sec
This is a way to access the api directly to check if the channel is NSFW
The refrence documentation is mainly for making your own libary or making calls
Integrate your service with Discord — whether it's a bot or a game or your whatever you wildest imagination can come up with.
^
all the API calls are documented. you make these calls, build your objects, and then use them within your application
^
Not quite
@upper tundra Google works miracles btw
Integrate your service with Discord — whether it's a bot or a game or your whatever you wildest imagination can come up with.
Making that single api call I sent as a image took around a week to do
It's not that easy tbh
you just need to know how to make http requests
^
But I didnt know how to do that
So I learned on my own since everyone hates me for using async
reference= authentication and all other information you need to know for the api. then, you select an object you want on the side and look at the relevant api call which gives you what you want
not you, the other guy
make it in binary

#memes-and-media for memes
Does anyone know if the discord.js@11.5-dev has an event to listen for forced disconnect?
gl
^
why glitch... glitch sucks
dbl ask2ask @earnest phoenix
Dont ask to ask
Just ask your question
it wastes time if you say "i need help" or "can someone help me?" instead of just saying what the problem is. Save your time and other people's time by just asking the question.
hm, this would be a question for https://discord.gg/discord-api
are you aiming to create a discord library?
Apparently
@upper tundra Use Discord.js Web Builds
I have heard that the server is a tad unfriendly to newcomers
but I don't have any direct experience
I feel like the friendliness depends on the channel
lmao
Ive got a question
I've got an answer
There is one channel for each lib
Thats great!
The non-JavaScript ones tend to be friendlier
I'd like this command to run every 6 hours
function Repeater() {
setInterval(function () {
axios.get("https://api.torn.com/faction/22295?selections=basic&key=1vpH5bIwSDLfkwX7")
.then(function (response) {
console.log(response)
let y = response.data.respect
let x = {
title: "ID Current Respect",
url: "https://www.torn.com/factions.php?step=profile&ID=22295#/",
color: 50000,
description: "Infinite Dimension Current Respect: " + (y)
};
(message.channel.send({ embed: x }))
.catch(function (error) {
console.log(error)
})
.finally(function () {
});
}
}
}, 3000);
}
I think I am doing something wrong somewhere
That runs every 3 seconds
It's becuz of the 3000 at the bottom
6 * 60 * 60 * 1000 is the number you're looking for, if u wanna run it for 6 hours
ok
3000 is 3 seconds
I was going to ask as well, my bot only let's certain users admin it for their server. What is the best way to handle that for public use? Currently people with the role "leaderboard manager" can do the admin actions
But Im not sure about the code if it even is correct
you would have to tie that to a list of user ids @stark beacon
Im still trying to figure out whats wrong
and check if the command runner has their user id in the list
if they do, then run the command, if not, then either fail silently or tell them they dont have perms
your decision really
or you can make the bot check if the user has meet the required server perms
oh yea you could check if they are in that server, then check if they have that role, but it doesnt seem that efficient
Er I mean, how do I tell John Doe that he needs to add a role to let themself or others do admin commands
ohh
In my case it's adding and removing users to the bots leaderboard
check if they have the role on command run, if they do then do it, if not then say smth like "you need the role leaderboard manager to run this command!"
and maybe create it through the bot if it has perms
and notify that it has done so
Okay yea that is what I do, just wasn't sure if that was common to do
and the bot need to use .find('name', 'rolename') instead of .get('id')
Yup it does I believe
Just gotta update my queries to be by server and then I can go apply it here I think. 😬 😀
@uneven rover that is deprecated
instead of using .find('name', 'rolename') use a function
like this
i know, but you can use the older version if you need to use .find
.find(role => role.name === 'rolename')
Yeah
but in the future it will just kill the process
Some text in my discord should be repeatedly spitting out data every second but it is not working for me
function Repeater() {
setInterval(function () {
axios.get("https://api.torn.com/faction/22295?selections=basic&key=1vpH5bIwSDLfkwX7")
.then(function (response) {
console.log(response)
let y = response.data.respect
let x = {
title: "ID Current Respect",
url: "https://www.torn.com/factions.php?step=profile&ID=22295#/",
color: 50000,
description: "Infinite Dimension Current Respect: " + (y)
};
(message.channel.send({ embed: x }))
.catch(function (error) {
console.log(error)
})
.finally(function () {
});
})
}, 1000);
}
});
Is there any issue?
is there any error?
hmmm
Message have a value still?
It works when I do a command like !respect
But when I try to make it a set interval so it shows up every 1 second
Where do you pass the reference to what message is though into the interval?
Can you console log it
Alright
It console logs the response
response should be 802k
But it isnt working
I can look in a few, busy right now
function Repeater() {
setInterval(function () {
axios.get("https://api.torn.com/faction/22295?selections=basic&key=1vpH5bIwSDLfkwX7")
.then(function (response) {
console.log(response)
let y = response.data.respect
let x = {
title: "ID Current Respect",
url: "https://www.torn.com/factions.php?step=profile&ID=22295#/",
color: 50000,
description: "Infinite Dimension Current Respect: " + (y)
}
message.channel.send({ embed: x })
.catch(function (error) {
console.log(error)
})
.finally(function () {
})
})
}, 1000)}
``` try with this
Unfortunately it doesnt work Snails
How is repeater called btw
Im trying to think about a solution for 2 hours already but I cant seem to think of whats wrong or is there any substitutes
When I'm back at my PC I can help, should be soonish.
lol
Welp after an hour I still haven't figured it out lmao
setInterval(function () {
axios.get("https://api.torn.com/faction/22295?selections=basic&key=1vpH5bIwSDLfkwX7")
.then(function (response) {
console.log(response)
let y = response.data.respect
let x = {
title: "ID Current Respect",
url: "https://www.torn.com/factions.php?step=profile&ID=22295#/",
color: 50000,
description: "Infinite Dimension Current Respect: " + (y)
}
message.channel.send({ embed: x })
.catch(function (error) {
console.log(error)
})
.finally(function () {
})
})
}, 5000)
I tried this instead but unfortunately it still doesnt work
idk what that's for, all I see is a key to some api
which you should now regen
and you have an empty finally
which does nothing so there's really no reason it should be there
That's so much easier with modern JS
All I just need is the line of code to run every 6 hours
Im testing it at 5 seconds
axios.get("https://api.torn.com/faction/22295?selections=basic&key=1vpH5bIwSDLfkwX7")
.then(function (response) {
console.log(response)
let y = response.data.respect
let x = {
title: "ID Current Respect",
url: "https://www.torn.com/factions.php?step=profile&ID=22295#/",
color: 50000,
description: "Infinite Dimension Current Respect: " + (y)
}
message.channel.send({ embed: x })
.catch(function (error) {
console.log(error)
})
.finally(function () {
})
This is the command I need to run every 5 seconds
but what's the error
There isnt
does it log anything
doesnt even log response
Yeah odd it doesnt
Probably there isnt a response thats why
I dont know how to setInterval running properly
I feel like its some very easy command but I cant figure it out
axios.get("https://api.torn.com/faction/22295?selections=basic&key=1vpH5bIwSDLfkwX7")
.then(function (response) {
console.log(response)
let y = response.data.respect
let x = {
title: "ID Current Respect",
url: "https://www.torn.com/factions.php?step=profile&ID=22295#/",
color: 50000,
description: "Infinite Dimension Current Respect: " + (y)
}
message.channel.send({ embed: x })
.catch(function (error) {
console.log(error)
})
.finally(function () {
})
})
}, 5000) ```
yeah
Whats meant to happen is when I run node index.js in cmd it should run a few strings of code every 5 seconds
you do require axios right?
Yeah I do need Axios to run this command
in your .then
instead of logging response, log a string
just like "hi"
or something
Well I require it to log the response for the response.data.respect
I think its an issue with the setInterval
Try logging something else to see if it works
I print to console when creating a new idea to see what works and what doesn't
so are the testing areas places to test bots at? Does your bot have to be already approved in this group/site or can it be any bot?
ah okay, so you can get it approved and still be working on it?
or is that just for "new feature" stuff
Just not sure when I should do the approval process
I believe it is up and working correctly..
yea, bots dont have to be 100% production ready to be on our site
it just has to work
oh coolio
ima go do this then I think
So what if I have no public GitHub for it and no Website Url?
I also am not sure what I am supposed to in Servers this bot is in, the rest is filled out though
ahh yea, I Just saw that haha
coolio, added it. will probably need to add more detail description text haha
Still its not online , wew.
did you make index.js?
did you code the bot?
do you have a server?
thats some questions you need to answer yourself
Seems a lot of people use js for bots?
yep
In my opinion, Javascript is easy to deploy thats why a lot of people use it
Very true
I'm using JDA myself
I've never really liked web dev much so I never got into js
I know Java as well, but I am using Javascript on my production bot
main reason was because js is not strict with types
Yeah js is nice and loose! I always call it loosey goosey
Java is what my college focused on so I tend to it use it for almost everything... but I need to branch out
you can try Node.js yourself and see how easy to deploy it on some scenarios
some packages can be problematic but other than that
its a breeze
I dont think my setInterval code is working
message.send.channel("Hey")
}, 5000)
Is there any issue with it
Cause Im trying to get setInterval to work specifically for this
axios.get("https://api.torn.com/faction/22295?selections=basic&key=1vpH5bIwSDLfkwX7")
.then(function (response) {
console.log(response)
let y = response.data.respect
let x = {
title: "ID Current Respect",
url: "https://www.torn.com/factions.php?step=profile&ID=22295#/",
color: 50000,
description: "Infinite Dimension Current Respect: " + (y)
}
message.channel.send({ embed: x })
.catch(function (error) {
console.log(error)
})
.finally(function () {
})
})
}, 5000)```
error?
No errors
Thats what Im thinking, most likely it hasnt cause it has it would log something
I got it to console.log(response)
then ok if it doesnt execute. how do you do the whole code probably
probably input how you exactly do it from how it starts to end
Yes but I need to see how do you do the code itself
giving only the setInterval function wont give me ideas since you have no errors
so if it has no errors, do it even "arm" the setInterval?
I dont think it does
I know the code runs well but when I change if (message.content,startsWith("!command)) to setInterval(function ()) {` it stops working
Instead of it running with an input I want it to run every 6 hours by testing every 5 seconds
setInterval(function () {
axios.get("https://api.torn.com/faction/22295?selections=basic&key=1vpH5bIwSDLfkwX7")
.then(function (response) {
console.log(response)
let y = response.data.respect
let x = {
title: "ID Current Respect",
url: "https://www.torn.com/factions.php?step=profile&ID=22295#/",
color: 50000,
description: "Infinite Dimension Current Respect: " + (y)
}
message.channel.send({ embed: x })
.catch(function (error) {
console.log(error)
})
.finally(function () {
})
})
}, 10000)
The whole command
thats not the whole thing
where do you even put that thing
thats what Im asking since earlier
I cant pinpoint your issue with little context right now
Right below client.on("message", async (message_ => {
But I have more stuff other than this
ok since
you are making an interval
why do you want it to become an interval?
so I can probably recommend something
Its testing
Alright
so my suggestion in your design is
do an array or map
then set your guild id then channel id on that map
then make an interval outside any events that runs every 6 hours
use the ID you stored in the map to make it output the data. on the guild + channel you want.
then when you use !command, just do map.set(msg.guild.id, msg.channel.id)
const data = [];
setinterval(() => {
for (const channelID of data) client.channels.get(channelID).send();
}, 6 hours in ms)
client.on('message', (msg) => {
// If command is !command
data.push(msg.channel.id)
})
(node:10956) UnhandledPromiseRejectionWarning: ReferenceError: message is not defined
at D:\Discord_Bots\Bot_1\Bot\index.js:126:13
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:10956) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
Alright thanks
I'm making a thing http://i.al1l.com/9ohK1.png Thoughts?
Not at all finished, just a prototype.
export it in files instead of keeping it in one file
@sinful lotus Im sorry Im unsure on how to use your command
what is your current code
I tried modifying my previous code
It spammed it so fast I got IP Blocked lmao
client.on("ready", async (message) => {
setInterval(() => {
axios.get("https://api.torn.com/faction/22295?selections=basic&key=1vpH5bIwSDLfkwX7")
.then(function (response) {
console.log(response)
let y = response.data.respect
let x = {
title: "ID Current Respect",
url: "https://www.torn.com/factions.php?step=profile&ID=22295#/",
color: 50000,
description: "Infinite Dimension Current Respect: " + (y)
}
message.channel.send({ embed: x })
.catch(function (error) {
console.log(error)
})
.finally(function () {
})
})
}); 100000;
});
thats not what I said you to do
const data = [];
setinterval(() => {
for (const channelID of data) client.channels.get(channelID).send();
}, 6 hours in ms)
client.on('message', (msg) => {
// If command is !command
data.push(msg.channel.id)
})
did I put the interval inside the message?
did I put the ms outside the setInterval second parameter?
please understand what I actually sent
you did not even change anything on your code
Alright sorry
I cant spoon feed too much because that would hinder your learning
but I already gave you the idea on how to execute what you want to do
its up to you to digest it and apply it
Does anyone know how to have the bot automatically restart its VPS if the bot goes offline? I've heard it's possible but not sure how to do it.
The bot has been running perfectly fine on the VPS except for one issue where it occasionally switches the bot off even though the VPS is still running. When VPS is restarted, the bot works fine again.
you can achieve that on pm2
We have that, but it didn't work.
this is what I do on every server I have and it didnt failed me
Well we have the part which provides us with logs, I don't think we have the startup script though. Thank you.
just do process.exit()
no, I have the command
or if you meant by anime suiciding thats not allowed
aa oka
we cant promote something like suiciding
I don't watch anime
Do you know some gore Animes? @sinful lotus
If you prefere send the names in Dm
not here use #memes-and-media and no, I dont watch gore
okay thanks ❤
and I dont think we also promote gore here so keep that in mind thank you 
at item.request.gen.end (/rbd/pnpm-volume/2343a5d2-a3ec-43c3-aa15-d2ebbd304141/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15)
at then (/rbd/pnpm-volume/2343a5d2-a3ec-43c3-aa15-d2ebbd304141/node_modules/.registry.npmjs.org/snekfetch/3.6.4/node_modules/snekfetch/src/index.js:215:21)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)
name: 'DiscordAPIError',
message: 'Missing Permissions',
path: '/api/v7/guilds/264445053596991498/invites',
code: 50013,
method: 'GET' }
Uncaught Promise Error: { DiscordAPIError: Missing Permissions
at item.request.gen.end (/rbd/pnpm-volume/2343a5d2-a3ec-43c3-aa15-d2ebbd304141/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15)
at then (/rbd/pnpm-volume/2343a5d2-a3ec-43c3-aa15-d2ebbd304141/node_modules/.registry.npmjs.org/snekfetch/3.6.4/node_modules/snekfetch/src/index.js:215:21)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)
name: 'DiscordAPIError',
message: 'Missing Permissions',
path: '/api/v7/guilds/264445053596991498/invites',
code: 50013,
method: 'GET' }```
What is this
@earnest phoenix the bot doesn't have permission to get invites to the server it's in
You dont have permissions
On this server don't have permissions
Then you need to make sure that it gets permissions before trying to use invites
Otherwise you'll get this error
Just do something like
if the bot has no perms to send message in this channel, return silently
what?
do a check on start of your code
or command handler
to see if the bot can send messages
Commands do not work
just do a check on top of your file like how you ignore bots
commands dont matter here
what matters is you stop your bot from doing anything if it has no permissions
= no more error
@sinful lotus Thanks for your help! I managed to used the knowledge you have given me and that allowed me to make the bot function as planned!
no problems 
Someone in #development made sense and made use of information 
i messed up with modules system :D
Please keep the channel to the topic. #general would be more appropriate for these comments. @lament meteor @earnest phoenix
why
im about development
It has a line through it which clearly indicates that it is not a serious question or request for assistance regarding development.

tryharding to get that mod role, its expected
I just asked to keep this channel on topic so don't send an off-topic message right after it, and everyone has their own way of moderating.
uwu
Err on client.login(config.token)
Err unexpected token
Are u sure that error is from that line?
Yup
token in a JS error rarely refers to your bot's token.
if you are getting unexpected token on your last line, there is another error in there
- Use a linter.
- Check your syntax (grammar).
Nope
Well your error says otherwise.
rewind?
i'm guessing ctrl z
@earnest phoenix what's the problem
i have 1 error at the end of my code
What is it
Lol
ROFL
Learn 2 code™
Stfu
Learn JavaScript, get a linter.
You seem to be trolling
just read @earnest phoenix
It's not being rude, that's an error you can prevent when you know how to code.
^
@modern sable
wrong marco
Let's refrain from disrespecting each other.
Will ya'll calm down
He has asked for help, so either help or don't reply.
he just need to read
i cant learn to someone how to read
there are helpful answers in that mess
Unexpected Token errors are a subset of SyntaxErrors and, thus, will only appear when attempting to execute code that has an extra (or missing) character in the syntax, different from what JavaScript expects.
You can simply point out what he should read instead of being rude about it. 
You have extra one ) or one missing
I think he forgot to install ESLint and get a proper code editor.
And if the error is on the end of the code its bc you miss a ) or a } somewhere
Muted @pallid zinc
??
That's js, not python
Why to mute me??
#memes-and-media please
yes
A rich embed?
yes
if(message.content === prefix + "informations services") {
if(message.guild.member(message.author).hasPermission("ADMINISTRATOR")) {
let infosServEmbed = new Discord.RichEmbed()
.setDescription("• Hey ! Dans ce salon proposez vos services ou dites nous ce dont vous avez besoin ! \n\n• Si vous cherchez des personnes qualifiées : <@&588055678522753054> !")
.setColor("#249bff")
.setThumbnail("a valid picture without importance")
.addField("Partenaires", "**[Staff List](the link of the server)**!")
.setImage("The link of the image")
.setFooter("Time")
.setTimestamp()
infosServ.send(infosServEmbed)
}
}```
i want the link of the "setImage" in the addField("Partenaires")
What
?
You can't put an image before fields
@limpid raptor .setAuthor(message.guild.name, image url)
I think is what do you want
Try
okay 🤔
He want this
Ok yeah that's author image
Yes
Yep to any image
The link need to be after the ,
yes, i understand that
I have a two commands that will probably require massive storage.
Is it okay to force users to have voted in the last 24 Hours to use that commands?
yeah
You could keep a hash map with users and a timestamp with a timer that removes them if it's been > 24
@onyx summit
thanks
Np
I never wanted to implement a feature like that but it seems like every bot does
and yeah, I already have a solution with ttl to limit api requests, but somehow I always get false, even tho I voted 5 mins ago
I guess it's next to impossible to keep up with votes without it?
I rarely see a bot implement it
Rewarding for voting?
unlocking commands for votes
Ahh
Is there a delay with votes?
I just voted but every api request says no
yes
u sure?
yes
ok
My bot has issues where it takes a few minutes for some users to register as have voted
Same, just wait a couple mins
They will vote, do the command and it will be false for them
Then magically a few minutes after its true and the command works
I've come to accept the delay
Not really sure what causes that
Maybe it's faster with webhooks
Api
And the last 1000 votes doesnt work im pretty sure its discontinued
Gives random crap back
My bot doesnt have an external api so a webhook wouldnt work
External POST endpoint*
I just added this not If you already voted, but this doesn't work, wait up to 5 Minutes.
(the 5 minutes is the ttl for the entry that they didnt vote but psssht)
Hey, does discord offer their own database, or do you have to separately download one
Your own
make your own
Is there a way to make a Python program restart itself in case of death of program
use a process manager such as pm2 or docker
Note this is on Windows for now, but I will be moving to Linux in the future
imagine using docker 
I don't have a working server rn, so I kinda have to run it off my desktop
pm2 can run on all operating systems with all programs
(Not sure why your py bot would crash unless your code is bad)
shitty_code()
except:
restart()```
just nullify all errors, problem fixed
@slender thistle I have no clue either, unless my computer rebooted itself for updates or smthn
Lol
For unexpected reboots just have it launch on boot
What’s the recommended database for bots? I downloaded MySQL but it doesn’t open because it needs a password and I have no idea what it is
Depends on your needs
go to the mysql docs and find out what the default password is
K
you should have been able to set it up yourself during your install
What are you coding in?
node.js
K
Another thing can be using JSON
no
lol
dont use json as a database
If you don't need relational aggregations why not?
A good redneck data base is to just write a bunch of text files for everything 😆
Depending how simple the needs are it could be easier if the person doesn't know SQL
JSON can be easily corrupted
its way too easy to fuck up
Fair enough, it's true there's no real integrity checks
Now that I think of it, I could just use text files
of course, but just as easy to fuck up with fs as a json file
How so
I use something consider blasphemy by many; serialization
dude I use that too
?
I would've used MySQL but my server died
Lol
@earnest phoenix improper management of data in json file can go to shit fairly quick
I run my bot on my laptop
I use JSON as input data
my JSON management is very shoddy, I think I'm doing it wrong
Mostly because I can edit a spreadsheet and export to JSON and vice-versa for loading data
MySQL is better
but saving and keeping object data is done via serialization
I’ll try to redownload it
Each user has their own JSON file named after their ID, and it just pulls from the user's file when it's needed
I’m not an expert, but I’ll try my best
That could scale poorly for your filesystem
At the very least I'd use a single file with a JSON Array of users
I much prefer MySQL to JSON, but I never got the connector library working, and my server dying fucked everything over.
but the positive side to your way is if one user is corrupt it doesn't crap the whole bed
Like I said, I’ll just try mySQL and I’ll work my way up from there. My bot is currently only on 3 servers
Mine is on 5 👏👏
same
My bot is in 2 servers being actively tested by ~7 people
4 of which are utterly hooked on the game which is a good sign
I'm curious to see how it scales
I want people to use my bot, but not to get famous. My laptop will commit suicide if it does
I’m middle school age...no money to buy legit servers
I have a good rig, but if I have it running my bot and doing other stuff at the same time it slows down quite a bit
fyi for in your near future:
$50 DigitalOcean credit can get you 10 months of a basic a VPS
I’ll just have it for my friends or so
This channel has gone way off the topic of #development, please take it to #general.
vps stuff is still development
Ok, back to code, what the heck is a webhook
webhook is basically a server that accepts post req
Topic says "bot development" which is usually coding, but okay.
something like that
I see, I guess we strayed a bit talking about the actual bots and goals. Apologies. It was in regards to scaling, which is development, but I see you point.
🙏
In what instances would you use a webhook
something like if you handle large amount of data per sec
imitates other users with a webhook
webhooks is basically a service that receives data from a webpage or something
it waits for post data
then process the post data
you can also make it handle get requests
and when you also make it handle /get thats basically where I think its called an api
I’m sorry, I’m so confused...how do you use one
a sec
https://github.com/Deivu/Haruna this is an example of an api
Simple webhook vote handler for Discord Bot List https://discordbots.org/ - Deivu/Haruna
Ok
I created that soley for my use but I decided to open source it anyways
that receives /POST and /GET requests, basically a middle man between my bot and dbl
Ahhhh.....I get it now, thanks
here is a more indepth
stuff about api and webhook
hi there, is there any mod free to reinvite my bot to the server? id: 510980011008983060
@mint grove ping a mod and next time ask in #general or #memes-and-media
@modern sable ^
oh my bad
reinvited it
Hello
ye
Yes
How do i make pm2 startup start as the root user? Because pm2 doesnt wanna resurrect my processes on boot
you should be able to just run pm2 startup or something like that
with sudo?
i get this output, maybe its suggesting a command like this for you as well?
i'll try running the command again
Platform systemd
Template
[Unit]
Description=PM2 process manager
Documentation=https://pm2.keymetrics.io/
After=network.target
[Service]
Type=forking
User=root
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
Environment=PM2_HOME=/root/.pm2
PIDFile=/root/.pm2/pm2.pid
Restart=on-failure
ExecStart=/usr/local/pnpm-global/2/node_modules/.registry.npmjs.org/pm2/3.5.1/node_modules/pm2/bin/pm2 resurrect
ExecReload=/usr/local/pnpm-global/2/node_modules/.registry.npmjs.org/pm2/3.5.1/node_modules/pm2/bin/pm2 reload all
ExecStop=/usr/local/pnpm-global/2/node_modules/.registry.npmjs.org/pm2/3.5.1/node_modules/pm2/bin/pm2 kill
[Install]
WantedBy=multi-user.target
Target path
/etc/systemd/system/pm2-root.service
Command list
[ 'systemctl enable pm2-root' ]
[PM2] Writing init configuration in /etc/systemd/system/pm2-root.service
[PM2] Making script booting at startup...
[PM2] [-] Executing: systemctl enable pm2-root...
Synchronizing state of pm2-root.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable pm2-root
[PM2] [v] Command successfully executed.
+---------------------------------------+
[PM2] Freeze a process list on reboot via:
$ pm2 save
[PM2] Remove init script via:
$ pm2 unstartup systemd
root@raog:~#```
thats all i get
ran a test script
[PM2] Spawning PM2 daemon with pm2_home=/root/.pm2
[PM2] PM2 Successfully daemonized
[PM2] Starting /root/pmtest.js in fork_mode (1 instance)
[PM2] Done.
┌────────┬────┬──────┬────────┬───┬─────┬──────────┐
│ Name │ id │ mode │ status │ ↺ │ cpu │ memory │
├────────┼────┼──────┼────────┼───┼─────┼──────────┤
│ pmtest │ 0 │ fork │ online │ 0 │ 0% │ 8.3 MB │
└────────┴────┴──────┴────────┴───┴─────┴──────────┘
Use `pm2 show <id|name>` to get more details about an app
root@raog:~#```
and ran pm2 save


