#development
1 messages · Page 533 of 1
nop
Lol
ok then just let it
like it's blocked but I can make selections etc
Discord had an connection issue
Again
well I will let him make his things
What did I miss?
I don't knwo bro
Discord's demise yet again
What library are you using?
he's using discord.io
OwO use discord.js
I used this
Follow source code
you mean when I put the command to make with .js and not with .io?
Look up source code on YouTube and follow his tutorial
no, that's just the name of the library
what is a source codeee?
Youtuber
oh ok
and he made a tutorial for a discord bot?
cuz I need one for my discord server
Yes
and it's working?
Yes, I followed his tutorial, he tells what does what, and how to do this
sure, thank you 😃
Np
@rustic obsidian mmh.. okay
no it's fine, go ahead and run it
ok ty
No prolem
nah im done
i let this off
I don't get the same folders like him
I don't get any folder
Really?
Discord.js?
npm install discord.js
It should have made a new folder called node-modules, and discord.js should be in there
Oh @graceful warren look up bufferutil and do a npm install, then install discord.js
I'll do it tomorrow but ty
Discord shutdown all bots. Luca will go off soon
@earnest phoenix its connection issues
oof
not discord doing it on purpose
hi
guys, I restarted the npm tutorial thing and now it's loading, I'll let this for 1 hour loading and maybe something will pass I don't know
By loading what do you mean @graceful warren
discord is having issues right now
Do we know how bad it is?
I cant seem to remember what is the last blank can get some help
required?
Maybe you need to update
wrong token
are you using the DBL token or the bot token
i believe he said updating stats works but votes doesnt, same token
?
hi, silly question
Optional packages
bufferutil to greatly speed up the WebSocket when not using uws (npm install bufferutil)
erlpack for significantly faster WebSocket data (de)serialisation (npm install hammerandchisel/erlpack)
uws for a much faster WebSocket connection (npm install uws)
how do i configure erlpack with discordjs
or is it automatic when it detects it in my dependencies
is it in peerDependencies?
code: https://pastebin.com/yiDuJGTq
error: the prefix doesnt work ;/
like I tried to use the same prefix but it doesnt seem to work - discord.js
@gleaming glen botumdaki hatayı duzeltdim Fenon'S botunu eklermisin
Uh can someone help with something
Like, i want the bot to react to it's own helplist, and if you click on one of the emoji's, it goes to the other helppage.
Like this: < >
you can make a reaction collector
and then check if someone reacts with any of those
if they do you can edit the message
@earnest phoenix haha same
Its their shit and you can do like nothing
Only call the api endpoint for correct vote count 
I mean Discord.js did not install
@knotty steeple Thanks!
@amber junco try 1.) latest npm (npm install -g npm) - 2.) add exception to your antivir, to ignore node_modules folder in your project - 3.) rm -rf node_modules package-lock.json - 4.) npm install ... that should work
you're using vscode? and is it running right now? if so close it and try to temrinate a instances of node and try to install then
@rustic obsidian discord.js?
if you use it then you can follow my guide for reaction help
I'd love to
Because i'm kinda stuck right now, i know how to let my bot react to messages, but not to embeds.
And yeah discord.js
Thanks
Hi
Who can help me ?
I want make a welcome message with canvas but is not work
Post code and error

😢
Undo?
You can just send code ?
I can't just send you the exact code b
You have to work on it yourself
This channel is for help, not freelancing
Plzzzz i delete my code ...
Or you have a tutorial for canvas welcome message ?
@night imp
I don't have one, there are others online
Of ?
Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.
better than google
@night imp my code :
const canvas = Canvas.createCanvas(700, 250);
const ctx = canvas.getContext('2d');
const background = await Canvas.loadImage('./wallpaper.png');
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
ctx.strokeStyle = '#74037b';
ctx.strokeRect(0, 0, canvas.width, canvas.height);
// Slightly smaller text placed above the member's display name
ctx.font = '28px sans-serif';
ctx.fillStyle = '#ffffff';
ctx.fillText('Welcome to the server,', canvas.width / 2.5, canvas.height / 3.5);
// Add an exclamation point here and below
ctx.font = applyText(canvas, `${sender.displayName}!`);
ctx.fillStyle = '#ffffff';
ctx.fillText(`${sender.displayName}!`, canvas.width / 2.5, canvas.height / 1.8);
ctx.beginPath();
ctx.arc(125, 125, 100, 0, Math.PI * 2, true);
ctx.closePath();
ctx.clip();
const { body: buffer } = await snekfetch.get(sender.user.displayAvatarURL);
const avatar = await Canvas.loadImage(buffer);
ctx.drawImage(avatar, 25, 25, 200, 200);
const attachment = new Discord.Attachment(canvas.toBuffer(), 'welcome-image.png');
message.channel.send(`Welcome to the server, ${sender}!`, attachment);
break;```
Error :
(node:8246) UnhandledPromiseRejectionWarning: ReferenceError: applyText is not defined
at Client.bot.on (/home/Akimitsu_Dev/commandes.js:76:17)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)
(node:8246) 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: 3)```
So ? @night imp
your missing a function
called applyText
if your going to use a tutorial don't just skip to the end
Mmmmhh ok i go test
Is jimp or canvas better for image manipulation?
anybody know a good documentation generator thingo
Docsify is pretty nice.
https://docsify.js.org/#/
A magical documentation generator.
is it possible to push something to an array in a json file using node?
this is what i have right now but im not sure if it even works tbh
settingsFor[message.guild.id].prefixes.push(args[0].toLowerCase())```
are you using json as a database?
yeah
@austere fossil load the array from the json you want to write to it, make changes, then write back to file
exactly
what is the difference between let and var
let is only available in the scope while var is available in the entire file
nope
only do var to define it
for example
var cool = 0
cool = 1
console.log(cool) //1
o ok
how do we do a round trip ping
message.channel.send("Ping! " + message.createdTimestamp - new Date().getTime() + " ms");
message.channel.send(`💓${bot.ping} ms`)
um so how do u do a roundtrip ping
what
https://perfectly-balanced.as-all-things-should.be/i/043r.png client.api isnt even a thing.. did you even read the docs..
like
i make a command and i want to get the first mention
no problem
i run the command and i mention 1 person it gets everything
if i mention 2 people it gets the second one
which is weird
I figured it out
Ok so
I was trying to make a button
That was in a link
And I think i got it
Is it
<a href="link"><button> text </button> </a>
@loud salmon Would this be right?
not sure, i dont really work with html
yes
yes that would work fine
an easier way to achieve that would just to do this
<style>
.link-button {
/* the styles for your button here */
}
</style>
<nav-or-something-else>
<a class="link-button" href="https://url.to/site">Some Text</a>
</>
I have a function that returns a value (via return result;), how can I pull that result after calling the function (blox.getByID("347890719");)?
NodeJS.
the value of the expression
so let/const/var coolResultValue = callFunctionHere(with, arguments);
Hmm.. Let me see.
This is only if the function is synchronous though.
if it isnt add await
If it's async, attach a callback or use async await
let result = blox.getByID(result, "347890719");
console.log(result);```
Such as that?
uhhhh
weird naming scheme but ok
¯_(ツ)_/¯
i dont think you want that first arg
so just blox.getByID("thing here")
It returns undefined,
Yet if I console.log the variable in the function, it returns the correct thing.
whats your code where you call the function
var request = require('request');
request({url: `https://myapi.com/${id}`, json: true}, function(err, res, json) {
if (err) {
throw err;
}
let result = json.Username;
return result;
});
};
where you call it
not the function definition
let result = blox.getByID("347890719");
console.log(result);```
ahhh
youll need to make a promise
and resolve that promise with result
new Promise((resolve, reject) => {
/*
Use resolve(something) to "return"
Use reject(something) to "throw"
*/
});
hi
i need help
exports.conf or export conf
depends on the lang
discord.js
it also depends on what you're trying to do
and whether you're using es6 modules
no reboot command
wait
@earnest phoenix Where do I put the function in that?
const Discord = require(discord.js); const moment = require(moment`);
exports.run = (client, message, args) => {
message.channcel.sendMessage(Pls Say yes``)
.then(() => {
message.channel.awaitMessages(response => response.content ==="yes", {)
max:1,
time:10000
errors: [time],
})
.then((collected) => {
message.channel.sendMessage(**rebooting.**).then(message => {
console.log([${moment().format('YYYY-MM-DD HH:mm:ss')}] Bot yeniden başlatılıyor...)
process.exit(1);
}).catch(console.error)
})
.catch(() => {
message.channel.sendMessage('cancelled.');
});
});
};
exports.conf = {
enabled: true,
guildonly: false,
aliases: [],
permlevel: 4
};
`
@earnest phoenix you put the code for the function inside the promise's constructor's argument
@earnest phoenix that's correct iirc
Well wasn't I right
no
It was asynchronous
try module.exports
});```
So you need to attach a callback to the getID
no nc
the fuckk
put it inside the function
ah
exports.help = { name: 'reboot', description: 'admin', usage: 'reboot' };
or
exports help = { name: '!marco reboot', description: 'admin', usage: '!marco reboot' };
Sounds like this is now a basic JavaScript issue
I see.
🤦 yes it is
I found np
i'm incapable of explaining well, search on MDN for promises or something
blox.getByID("347890719");
console.log(resolve)
});```
(this is what you should do first before asking)
Sorry, I'm trying to learn a new language.
which is why you shouldn't dive headfirst into something you don't know
Well, I've made it pretty far.
I just need help with this one thing.
@earnest phoenix copy the code from blox.getByID
Mk.
except return something -> resolve(something)
and throw something -> reject(something)
The point is I'm trying to make it a package.
ok
so wait
that doesn't really change anything
exports.getByID = function(id) {
var request = require('request');
request({url: `https://api.roblox.com/Users/${id}`, json: true}, function(err, res, json) {
if (err) {
throw err;
}
let result = json.Username;
resolve(result);
reject(result);
});
};
Yeah. Its just super confusing.
Python is much simpler.
i beg to differ
but ok
ok but
how do i do it
!
what you do is
take this stuff
uh huh
copy it in between the {} in ```js
new Promise((resolve, reject) => {
}):
oh shit
and use resolve when you want to return something
from there, where you call the function, use async/await or .then to obtain the result
Just stop
Stop blindly guessing
Just stop
And actually make an attempt to learn.
exactly
new Promise((resolve, reject) => {
exports.getByID = function(id) {
var request = require('request');
request({url: `https://api.roblox.com/Users/${id}`, json: true}, function(err, res, json) {
if (err) {
throw err;
}
let result = json.Username;
resolve(result);
});
};
});```
Hi
So, that would be in my module. Correct?
Who can help me ?
I want send a message to all user of my discord
NC, please
I try : message.guild.members.send('Test')
We are trying our best
What? I am asking for help.
But is not work
you're asking for us to completely teach you something you dont know
I did as he said, and pasted it in.
We are not here to teach you JavaScript.
Plz ?
That's why the internet exists
It is a simple question, I'm not asking you to teach me it.
oh wait
it isnt
IAM that is not correct
i just noticed that
im dumb
its better
Who can respond me plz ?
It would be so easy for you to just walk me through it, I've already spent an hour and a half on looking for a solution.
How can I fix that code?
i've tried explaining it to you
several times
By learning JavaScript.
exactly
Stop you squabble in this channel ....!
Plz
I've watched like 20 videos on it already.
Instead of driving us crazy, make an attempt to learn
That's why I asked?
I want to learn.
Shut up @earnest phoenix
you could have asked somewhere where an automated program (like a webserver) could have responded
instead of having to drive real humans insane
When I say make an attempt, I don't mean asking and expecting to be spoon-fed.
@earnest phoenix you can help me ?
I'm not asking to be spoon-fed, I'm asking how to fix it.
Sure...
@earnest phoenix message.guild.members.send('Test') Are you trying to DM all users?
you're asking that, and then refusing to learn
Yes$
Something so basic
nc that's wrong
@earnest phoenix no, dont send messages to all of your users, your bot will be kicked from here if it does
still bad idea
still not a good idea
just tag everyone
No ...
because its fucking annoying
b) super annoying
just tag everyone
"just 180"
thats a lot of people
@earnest phoenix alright. Mind explaining one last time why the code is incorrect?
just tag everyone or here if you're so obsessed with annoying people in your server
Pl give me code for this
@earnest phoenix if you werent expecting to be spoon-fed, then you should have understood what IAM said.
I want
Send a mesage to all peaple of my discord
@earnest phoenix you want to export a function that returns a promise that contains the original body of the getByID function with the addition of the use of resolve
So ?
@earnest phoenix I did.
https://gyazo.com/6eadd7fa6ebc3f8fa3f412b2fd8434d4
https://gyazo.com/d3bb8b2e63ce3e2bb132bb60b8e16433
which was not what i meant
@earnest phoenix Yes. I do, yet how do I do that?
NC I'm done. I've told you out exactly what you need to do
@earnest phoenix ?
IAM has explained it correctly
@earnest phoenix What did you mean?
What code did you want me to copy...
parts of that code
more precisely the body of the function
What part?
Ah.
Alright.
?.......
Plz i'm here
I'm not a ghost
@earnest phoenix you shouldnt dm every user in your server. period.
@earnest phoenix Nobody will help you abuse Discord's API.
By body, do you mean:
var request = require('request');
request({url: `https://api.roblox.com/Users/${id}`, json: true}, function(err, res, json) {
if (err) {
throw err;
}
let result = json.Username;
});
};```
Or do I keep the resolves?
@earnest phoenix stop randomly tagging people, we wont help you abuse the api and annoy your members
what
@mossy vine What was he asking?
@west raptor wants to send dm to all members of his serevr
a server of 180+ people i might add
Thats API abuse
whats happening here
nothing
kid wants to be spoonfed api abuse
and insulting comment
utter anarchy
sdcroll up
@earnest phoenix that's against Discord Terms of Service and nobody here will help you with it
Can someone help me with setting up customprefix system per guild,
this is the code I have, but it doesn't respond to setprefix in the db
https://hastebin.com/upesacoyeh.js
- make a db
- fetch from db
any benefits to using classes for commands?
I have done @earnest phoenix >_>
@brittle nova Maybe if you like OOP
Some people prefer functional programming, so they use functions
how can i prevent someone from using bot commands?
like a blacklist?
yes
check if they are blacklisted before processing commands on their behalf
if that's your setup, then check your so called blacklist.json if they are in it or not
i didnt try it just thinking about it
dbl.on('vote', vote => {
console.log(`User with ID ${vote.user.id} just voted!`);
});
Does this work
I tried it and it didn't work and didn't send any errors
@grave mist well you'll need to set up the webhook in your bot's edit page
Else it won't work?
yes
yes
It can be random number?
no
dblapi.js will set up a webserver on the port you specify
client is for server count posting it has nothing to do with webhooks
So I have to define them again?
I thought I could edit
So this will work?
const dbl2 = new DBL('mydbltoken', { webhookPort: 5000, webhookAuth: 'xd' });
dbl2.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});```
you dont need to define it again
you can use one dbl instance for both webhooks and server count posting
But I have to use client for server count right
And webhookport auth for webhook
How to do like you said
Is it possible to clear the members/messages or other things that is caching and eating from memory a lot with a code that can be evaled?
@grave mist ```js
const dbl = new DBL('mydbltoken', { webhookPort: 5000, webhookAuth: 'xd'}, client)
Ok thanks
is there a bot that anyone knows of that if I type a specific word/phrase into the chat a role is given?
?role @earnest phoenix <role you wanna give>
Oof it pinged an user sorry for the ping dude
I am talking a non-admin and mod command
i.e someone joines a server and says a word/phrase and has a role named "secret club" a role that only a few people should know how to get. its not for this scenario but that is the overall porpose
will this be bot automated or is this a command I still have to type to giveb them the role?
Is there something like emit event
So that I can check that vote thing without voting actually
@robust jackal automated, only they need to type the custom command
@grave mist test button in ur bot edit page
@topaz fjord how to sweep
https://discord.js.org/#/docs/main/master/class/Client?scrollTo=sweepMessages
https://discord.js.org/#/docs/main/master/class/GuildMemberStore?scrollTo=sweep
https://discord.js.org/#/docs/main/master/search?q=sweep
Discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
Discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
@steel heath
thanks you
@bright spear I clicked test button but it didn't log that user voted
did you set up the webhook in your bots code and in the dbl edit page?
well your bot needs to be connected to an ip or domain
To test it?
where are you hosting your bot
Glitch
setInterval(() => {
http.get(`http://${process.env.PROJECT_DOMAIN}.glitch.me/`);
}, 80000);```this?
no, the code with express
app.get("/", (request, response) => {
response.sendStatus(200);
});
```this?
Idk I just followed a guide once to set up my bot
your app.listen code
There's no such thing in my main file
is your app.get code in your main file
yeah then you'll need to use webhooks
Rip
its not that complicated if you know js
Idk anything about webhook
you could use dblapi.js and connect it to your express webserver, or just add a route in express
How to...
which one
Which is easy
If you guide me what to do, I can do it correctly
ok lets just use dblapi.js
can you find the app.listen in your code
it probably is there somewhere
whats the name of your glitch project
i wanna check if it is getting requests
It is private project, I can invite you
just tell me the name for now
i dont need to see the code

yeah
Quick.db uses it you can find what you want still?
wut
quick.db has webviewer
And that comes in the glitch.me link
So you can still find what you want?
Anyway it is https://amazing-bot.glitch.me/
oh uh
idk if you'll be able to set up a webhook on that project if you already have that running a webserver
you'll probably need to make a new project
yeah ik
Done
Then?
its in the same file as your dbl code right?
can you make sure the const server is below your app.get code but above your dbl code
k now that should be good
now you can put stuff in your bot's edit page
the webhook url should be https://amazing-bot.glitch.me/dblwebhook
Then?
the webhook authorization thing should be whatever you set as webhookAuth in your code
yw
It isn't a big process tho you could've said both of them are easy
lol k
is there a way to remove that little watermark on the background of the bot page
wdym
nvm got it
dblapi.js
How do you be gay
K thanks
I am making a pay command
I specifited the amount
but
it still replies with an error
let mUser = message.mentions.users.first(),
amount = parseInt(args.join(" ").replace(mUser, ''));
if (!mUser) return message.reply('you have to include a person to pay!')
if (isNaN(amount)) return message.reply('you have to include how much money you will pay!')
let mBal = await db.fetch(`userBalance_${mUser.id}`),
sBal = await db.fetch(`userBalance_${message.author.id}`);
if (mBal === null) mBal = 0;
if (sBal === null) sBal = 0;
if (amount > sBal) return message.reply('you do not have enough money to pay this person!')
if (amount < 1) return message.reply("hey you can't pay $0!")
db.add(`userBalance${mUser.id}`, amount);
db.subtract(`userBalance${message.author.id}`, amount);
message.channel.send(`Paid ${amount} to ${mBal.username}!`)
let payLogEmbed = new Discord.RichEmbed()
.addField("Pay Log", `${message.author.user.tag} paid ${amount} to ${mUser}!`)
.addField('Time', `${message.createdTimestamp}`)
bot.channels.get(521112640815366144).send({embed: payLogEmbed})
got it
so
sooooo
soOOOO
it works
but doesnt
it sends the success message but doesnt actually pay
let mUser = message.mentions.users.first(),
amount = parseInt(args[1]);
if (!mUser) return message.reply('you have to include a person to pay!')
if (isNaN(amount)) return message.reply('you have to include how much money you will pay!')
let mBal = await db.fetch(`userBalance_${mUser.id}`),
sBal = await db.fetch(`userBalance_${message.author.id}`);
if (mBal === null) mBal = 0;
if (sBal === null) sBal = 0;
if (amount > sBal) return message.reply('you do not have enough money to pay this person!')
if (amount < 1) return message.reply("hey you can't pay $0!")
db.add(`userBalance${mUser.id}`, amount);
db.subtract(`userBalance${message.author.id}`, amount);
message.channel.send(`Paid ${amount} to ${mUser.username}!`)
let payLogEmbed = new Discord.RichEmbed()
.addField("Pay Log", `${message.author.user.tag} paid ${amount} to ${mUser}!`)
.addField('Time', `${message.createdTimestamp}`)
bot.channels.get(521112640815366144).send({embed: payLogEmbed})
yw
hey!
I'm wondering on using Individual User Id Voting Check for the past 24 hours.
My bot is in python
I've checked the dbl python lib source code but I havent found any function for this request
Can someone help me with it plz?
@hard sorrel looks like its not supported by dblpy so you'll need to make a direct request to the api
anyone got a few seconds to help code a simple bot? looking for something that monitors a folder and if a new .txt document arrives, prints its contents to a specific channel. im shit at coding.
any idea where I could find folks willing to work a small project?
not sure where to start even.\
not unless you're gonna pay
Ad whats the link torequest plz
wut
sec
https://discordbots.org/api/bots/BOTID/check?userId=USERID
change BOTID and USERID
Also doc tells That authentification is required but what is dbl auth 🤔
Thanks for the help 😜
Ty
add an Authorization header with your bot's DBL API key as the value
yw
Can you put videos in discord embeds?
Shit
if i have a python script that requires servercomm as a command line argument what could that be? i.e. #The program should be called in cmd like so: TestBot.py 'directory' 'channel' 'OAuth2 Token'
comline = sys.argv #sys.argv is a list of the arguments/parameters given in the command line
directory = comline[1] #the first parameter
channelcomm = comline[2]
bottoken = comline[3]
servercomm = comline[4]
cant figure out what its asking for got the rest going.
In discord js, im getting an error while using ytdl-core. The error say that the "url" must be a string, i think i know what it means but idk how to do that nor understand if that's al;l there is to it.
Code im using form tutorial:
const voiceChannel = message.member.voiceChannel;
if (!voiceChannel) return message.channel.send("You must be in a voice channel to play music.");
const permissions = voiceChannel.permissionsFor(message.client.user);
if (!permissions.has('CONNECT')) return message.channel.send("I don't have the proper perms to connect to the voice channel.");
if (!permissions.has('SPEAK')) return message.channel.send("I don't have the proper perms to play music in your current channel.");
try {
var connection = await voiceChannel.join();
} catch (error) {
console.error(error);
return message.channel.send(`I was not able to join the voice channel ${error}.`);
}
var ytURL = args.join(' ');
const dispatcher = connection.playStream(ytdl(args))
.on('end', () => {
message.channel.send("Music playback has finnished");
voiceChannel.leave();
})
.on('error', error => {
console.error(error);
});
dispatcher.setVolumeLogarithmic(5 / 5);```
Error:
at Url.parse (url.js:152:11)
at Object.urlParse [as parse] (url.js:146:13)
at Object.exports.getURLVideoID (D:\STUFF\node_modules\ytdl-core\lib\util.js:270:22)
at Object.exports.getVideoID (D:\STUFF\node_modules\ytdl-core\lib\util.js:301:20)
at Function.exports.(anonymous function) [as getInfo] (D:\STUFF\node_modules\ytdl-core\lib\info.js:363:21)
at ytdl (D:\STUFF\node_modules\ytdl-core\lib\index.js:17:8)
at Object.exports.run (D:\STUFF\commands\play.js:19:46)
at process.internalTickCallback (internal/process/next_tick.js:77:7)```
Please properly format your code blocks
mongoose or quick.db
no
change the start of the block to this
```js
and then a new line
will make it look like js
@pastel mulch well one is local db and the other is 3rd party so which ever you feel like using tbh
```js
oof
happy klep?
lol
this is args
var cont = message.content.slice(prefix.find(p => message.content.startsWith(p)).length).split(" "); //slices off the prefix, then puts it in a array
var args = cont.slice(1);```
My plan for persistent timers is to have an interval on ready every whatever seconds (maybe 5 - 10) to check the database for events that need to be fired and handle them accordingly. This won't be very exact though. If a timer is set for 45 seconds, it may be 50 or 55 seconds before it is handled. Is there a way to have exact and persistent timers without having the interval be less than 1 second?
using nodejs and mongodb
well
when the bot starts up
you can have it setTimeout to whenever the DB says the event is due
@brittle nova what's this for
@languid dragon temporary moderation actions for now
if your using it on one server its safe ish to cache and check every 3~ seconds
my bot for reminders queries the db every 10 seconds, caches and the timer queries the cache every 2 seconds
So I guess you can't actually get it exact?
Well some DBs have subscription thingies where it sends u an update or smth
You could do what iAmThe32Bit suggested to get it ~exact
But note that if there's no event saved when you startup it won't do anything
You could just set the timeout when you set the event to fix that
You can even make it able to do multiple events
By setting the timeout to whichever one comes first
And at the end you can make it set another timeout for the next one
guys my audioclient does not play the first time connects any fix?
Just check a time stamp every time an event is emitted
That way u don't need to fill it with timers
@brittle nova
yes
You can just store them in a database on ban event
I don't actually store them anywhere, I just have them sent into the logs channel.
submit it @dusty oasis
in the logs channel 
so how does your bot know what guild to ban
yeah
Oh I use an API
As it's easier and well I have other admins taking care of them as well 

so how does the bot know tho
I was thinking a task that checks the ban database once a while
and compare it to the local cache of guilds
if match, leave the guild
So I use the API's endpoint with the users ID on member join and if it returns true it bans the user
It doesn't loop through all the servers as I am too lazy and it takes too long

User ban I believe
i believe 
😩
@keen drift I am doing a rewrite of the bot so it doesn't really matter at this stage
I have an entire repo dedicated to the planning of it all
i'm currently working on a wireframe
gonna post it on my subreddit and get some feedback

sort of a like sneak peak and feedback
python, whats the difference between split and rsplit?
ohh rsplit starts from the right
can i have 2 arrays in 1 .json?
lets say i 2 arrays which are 1 = random numbers and 2 = random strings
Your json has to be an object or an array afaik
You could make it an object with 2 arrays
Or an array with 2 arrays
{
"firstArray": [1, 2, 3],
"secondArray": ["one", "two", "three"]
}```
yes you can do that
oh yeas its missing the colon
after ]?
not colon
yes
the whatitscalled
comma
Do we refer to jsons as const config = require('./config.json')
config.array
i dont expect spoonfeeding, but how could i append an string to .json's array?
allowing users to append strings
The file extension isn't needed if that's the only file you have with that name @empty owl
Oh ok
If your json is an array than config will be an array in your case
ok
if (cmd === "writetest") {
let text = args.join(" ")
fs.appendFile('test.json', text, function(err, text){
if (err) console.log(err);
console.log("Successfully Written to File.")
});
}
What are you using that for ^
I would recommend using a database.
what do you mean
Store them in a database rather than just a json file
i dont know what do you mean by "database" ;c
You can read/write data to a database
app.post('/users', function (req, res) {
// retrieve user posted data from the body
const user = req.body
users.push({
name: user.name,
age: user.age
})
res.send('successfully registered')
})
👀
its example from the internet
For what? xd
I just don't think you should save stuff like that in a json file
As I'm pretty sure appendFile would just add it to the bottom
And ruin the file
There's probably some tricky stuff you can do
file for each user?
i didnt mean that
if i had blacklist folder
than just store each user in separate file
Would work
google isnt helping me very much
I mean
nvm, ill find a way
Never a bad time to start learning about databases
mlab offers 500mb of storage in their free plans
You can use the mongoose package to integrate it in your project
It's pretty easy to setup
I need a bit of help extracting posts from reddit
Anyone know about this? I'm using Python (discord.py)
TypeError: Cannot read property 'has' of undefined
do you know this error
pretty self explainatory
^
you have been asking this for hours
Lol
It means whatever u put before .has is undefined 👀
Or the var, const etc
reddit has an option to display subreddits as json without an api token 
@high anchor what are u using it for
how can bot read if json contains user ID?
im trying to figure this out but it doesnt work >(
if member.id === ids.json {
function
}
?
well first of all if that's javascript you need to wrap the if statement with parentheses like if () {}, second, if you're just looking for a user id it typically doesn't have to be inside a json, you can just put it in an array like ['userid1', 'userid2', ...]
let a = []
if it's an array inside a json, like
{
users: []
}
then you can just iterate over users using a for loop
or use .includes()
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes if you wanna know more
👌
can i use fs.appendfile
Anyone here certified
now the problem is in appending userid
i can append in normal files
e.g. text files
@valid frigate help him im a noob
eh
turns out its same as in other files
i dont understand
fs.appendFile("blacklist.json", json , function (err) {
jesus fucking christ
it overwrites it
appendFile is not meant to be used with json
it will break it
you have to write the entire file at once
@empty owl to give my bot reddit post watching
If i just grab the json then i cant do any reddit user auth, meaning i cant implement approve/remove posts from Discord
Suppose that’s the only drawback
Snoowrapper needs an API token tho
(if you're using python use praw for the reddit thing)
how can i get the bot to know if an emoji exists. cuz i have it working if the bot is in the server with it but with the nitro emojis it cant find it
discord.js
client.emojis.get('id')
client.emojis.map(id => id.id).contains(arg[i].replace(/>/, "").split(":")[2])
i just do that
but im encountering emojis from servers the bot is not in
due to nitro users.
so sometimes this creates problems
@slim heart if the bot isnt in the server then it wont know the emoji exists
^
so you can just check if its undefined/null
If you are using emojis, I recommend putting the bot in your own server then using your server's emojis across servers.
no for the emojis that are in server the bot doesnt have
cuz its not in client.emojis
I already have emojis covered for emojis that the bot is already in
i literally showed my code above
what im asking is if theres any way at all of telling its an emoji if the bot isnt in the server its from
const d = require('discord.js')
const fs = require('fs')
const c = new d.Client()
const ms = require('ms')
const token = process.env.TOKEN
const prefix = '?'
c.on('message', async(message) => {
if(message.content.startsWith(prefix)){
}
});
c.user.setPresence({
game: {name: 'with carrots'},
status: 'idle'
}).then(console.log)
.catch(console.error)
c.login(token)```
Just the start of a js bot has an error
Cannot read property setPresence of null
you have to use the ready event
c.on('ready' => ({
yes
With async
you dont need async if you're not using async stuff
const d = require('discord.js')
const fs = require('fs')
const c = new d.Client()
const ms = require('ms')
const token = process.env.TOKEN
const prefix = '?'
c.on('message', async(message) => {
if(message.content.startsWith(prefix)){
}
});
c.user.setPresence({
game: {name: 'with carrots'},
status: 'idle'
}).then(console.log)
.catch(console.error)
c.on('ready', async(ready) => {
c.login(token)
})``` this?
@inner jewel
Oh
Fixed it, thanks
I don't think bots can have rich presence @wide ruin
I got it from docs
Still, I'm pretty sure bots can't have rich presence
oh
wait
thats not rich presence
my bad
Its ok
Also
Using this method, how can I do watching, listening, playing and streaming?
4,3,2,1,0
can you get the full url of where a users at
in express
like if someone clicks something from /profile/id can i get https://website.com/profile/id
req.protocol + req.hostname + req.originalUrl
@wide ruin with type iirc
Wdym @west raptor
@empty owl yup
Oh. Well, my bot is used on reddit discords... a post watch is a requested feature. Sorry for misunderstanding your question
That would be a nice misc command though
@slim heart exactly, its not in client.emojis, so client.emojis.get('id') will return undefined
const d = require('discord.js')
module.exports.run = async(c, message, command, args, ms) => {
let ping = Date.now() - message.createdAt()
let p = new d.RichEmbed()
.setTitle('Pong!')
.setDescription(`${ping} ms!`)
.setColor('00FF00')
message.channel.send(p)
}``` why doesn't this work?
I'm trying to see if there's anyway to tell if it's an emoji even tho its not in there
oh i see
you could try https://cdn.discordapp.com/emojis/ID.png
it'll be a 404 if its not found
@wide ruin that'll just calculate clock differences tho
clock difference + time for the ws payload to be received
hey
if (code !== "bob") return message.author.send(`${code} is not a code.`).then(message.delete(message))```
how do I make it so i can check if its a different code
like that?
let codes = [
"bob",
"greekyogurt",
"ligma",
"despacito",
]
await message.delete
if (code !== codes) return message.author.send(`${code} is not a code.`).then(message.delete(message))
.then(message.delete(message)) is wrong
and i'm pretty sure await message.delete is invalid syntax
i have an async
also you want Array#includes
o
yes but that's not a function call
so
ok
but
nvm
let codes = [
"bob",
"greekyogurt",
"ligma",
"despacito",
]
message.delete(message)
if (code !== codes) return message.author.send(`${code} is not a code.`)
Ok need the help now
i already gave you the answer
Array#includes
same




