#development
1 messages · Page 875 of 1
@amber fractal is there a save function?
In sqlite, how can I get all users who have a certain value?
I want to access each user individually
wouldnt that return every single user at the same time
hey how can i close all the shards if i want?
just
shut down your bot
and then restart it
why not? lets all worship how great database technology is
lol
my brain uses json db
If you were to set your bot as an API so you can request data on guilds and db information (for a web interface), would you host 2 instances or just one doing the api and main functions?
does anyone know how i can fix this error when trying to connect to mongoose?
not the unhandled promise thing
getaddrinfo EAI_AGAIN discordapp.com discordapp.com:443 at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
Whats this?
d.js v 11.5
also in the code what do i see https://github.com/abalabahaha/eris
i mean error*
Can someone give me script to get all server invites that bot in? I can't find it and actually no idea how to create it
there are a flaw there
1st Its not allowed
discord.js
You cannot get invite with the server's permission
Forgot to say it
iterate through https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=guilds and grab any channel from that guild and then call https://discord.js.org/#/docs/main/stable/class/GuildChannel?scrollTo=createInvite
Can someone please Tell me how to make my bot leave any server that doesn't have a user that has manage server that has either one of the 2 roles in my server that are supposed to be able to Invite the Bot?
Using js
Is it only me or this wasnt understandable
Like premium bote
Bots
That have roles that can invite the bot
And if the said user doesn't have the role
The bot leaves
then get your server and then check the owner or whatever for a role
;-; wow
anyone here who got SQL brains?
Like unbelivaboat premium
it's rare to see those creatures these days
most people rely on JSUNreliable and SQSinglethread
Can anyone help me with bot commands
smash the kb and carry the vinegar
ELECTR0ZED#0001 knows sql I believe @Gofven#00021
@earnest phoenix its just im not good at commands and I would like to learn how to be good at making them
OOF failed ping
@earnest phoenix can ye summon him


That counts as a cold ping ;w;
Can someone please Tell me how to make my bot leave any server that doesn't have a user that has manage server that has either one of the 2 roles in my server that are supposed to be able to Invite the Bot?
Using js
What will we use to show the total number of banned users?
exam : Server Owner ', msg.guild.owner
in which library
what could you do to improve ram management
sql.prepare("SELECT COUNT(*) FROM raid WHERE raid1 > 0");
Would this return the number of occurences where raid1 are greater than 0?
It returns not a number
nevermind about my question
it's because of the way our backend works
I'm trying to make a command that my bot users will use to report bugs they find on my bot. So the command will work like m!report-bug {title} {description} {attachment} how do i make the arguments be sentences not only 1 word for the title and description? (Python)
using quotes?
How?
m!report "here is a sentence" "here is another sentence"
Ain't there like a way to split text by commas or?
yeah, but that wouldnt work if you were going to add a comma on your description or title
sql.prepare("SELECT COUNT(*) FROM raid WHERE raid1 > 0");
Would this return the number of occurences where raid1 are greater than 0?
It returns not a number
even after having
Number( )
hmmmmm maybe
its because I have no ;
nope
sql.prepare returns NaN?
const usersin1 = sql.prepare("SELECT COUNT(*) FROM raid WHERE raid1 > 0");
Number(usersin1)
= NaN
but userin1 const returns what?
if Number(userin1) returns NaN that means you are probably not selecting the correct variable right?
Im using the same variable
However
without Number()
it seems to be null
let me gather a few more tests
anyone out there proficient in TypeScript looking for some side-work? My current dev is having to take a break, and I've got a bot in over 2600 servers I'd like to continue having worked on haha
what do you usually do with database data when you are retrieving the whole row
btw, what language
try that
since you are still returning a table, not just a number
it would just be in array[0][0]
basically
what library are you using for database, since i cant find the function
??
i am trying to learn postgresql but I can't just do the harder part
what are the harder part?
if (!member.guild.me.hasPermission("MANAGE_CHANNELS")) return;```
Cannot read property ‘hasPermission’ of undefined
why?!
@turbid bough can i yeet u into my dmz, Vinx theres discord servers dedicated to discordjs
and eris
guildmember does not have haspermission, but member has
I cant seem to get a valid output
i wanna do something similar to this thaun
DO $$
DECLARE
ratelimit INTEGER := 42;
reset_timeout timestamptz := NOW() - '1 hour'::interval;
BEGIN
IF reset_timeout >= NOW() THEN
ratelimit := 45;
reset_timeout := NOW() + '1 hour'::interval;
RAISE NOTICE 'reset';
ELSE
IF ratelimit > 0 THEN
ratelimit := SUM(ratelimit - 1);
RAISE NOTICE 'decrement';
ELSE
RAISE NOTICE 'error';
END IF;
END IF;
END $$;
but ratelimit and reset_timeout is instead values from an user_id in a database
uh ive only dealt with sql for like not alot
i see 
whats the minimum age to be a Verified Developer on discord?
13
@topaz sphinx are you just wanting the variables ratelimit and reset_timeout come from just the database, and thats it?
yes
the function is complete
almost but
if i get the variables linked to memory addresses
or something similiar
then im done
its PostgreSQL 11
looking it up you can get set a variable from a table using this as an example
SET @ModelID = (SELECT m.modelid
FROM MODELS m
WHERE m.areaid = 'South Coast')
will changing that varaiable affect the table too
no, but that you can do with an another command
raise notice are useless comments that i use
what could i use in place of those
just regular updates
or
is there a better alternative
regular update should work fine
omg
what if it wasn't working because
i didn't add .run()
nvm Im dumb itsn ot
maybe .get()
db.transaction
const usersin1 = sql.prepare("SELECT COUNT(*) FROM raid WHERE raid1 > 0").get().count;
now im getting undefined
https://hastebin.com/ogawiheqec.js (commands/play.js)
https://hastebin.com/icudobunom.js (include/play.js)
Is it possible to make a Soundcloud music command using these play commands I made? This is discord.js V12 BTW
OMG FINALLY
Finally what?
he did it
Id like to say that this thing is very stupid and the fact that I had to ask stackoverflow gives shame and doubt in my ability to use sqlite
check soundcloud docs
Soundcloud docs? Link?
Thx
let stmt = sql.prepare("SELECT COUNT(*) count FROM raid WHERE raid1 > 0");
let row = stmt.get();
let usersin1 = row.count;
Why does this work but
const usersin2 = sql.prepare("SELECT COUNT(*) FROM raid WHERE raid2 > 0").get().count;
doesnt
does sql return promises?
wait that wouldn't do anything anyways
ignore me
idk sql
probably cause thats how the library works
i got it working
if (message.content.startsWith("$ban")) {
var member = message.mentions.members.first();
member
.ban()
.then(member => {
// Successmessage
message.channel.send(
":wave: " +
member.displayName +
" has been successfully banned https://gfycat.com/playfulfittingcaribou :point_right: "
);
})
.catch(() => {
// Failmessage
message.channel.send("Access Denied");
});
}
if (message.content.startsWith(PREFIX + "elon")) {
message.channel.send(
"https://gfycat.com/thornyspotlessarrowworm :point_right: "
)
}
});```
but its soo ugly only its own mother could love it
if(message.member.guild.me.hasPermission('ADMINISTRATOR')```
how could i add that if statement to thar command
by adding it
@turbid bough 1 to 10 how good is my solution
DO $$
DECLARE
ratelimit INTEGER := (SELECT image FROM users.ratelimits WHERE user_id = 2);
reset_timeout timestamptz := (SELECT image_refresh FROM users.ratelimits WHERE user_id = 2);
BEGIN
IF reset_timeout <= NOW() THEN
UPDATE users.ratelimits
SET image_refresh = NOW() + '1 hour'::interval,
image = 45
WHERE user_id = 2;
RAISE NOTICE 'reset';
ELSE
IF ratelimit > 0 THEN
UPDATE users.ratelimits
SET image = image - 1
WHERE user_id = 2;
RAISE NOTICE 'decrement';
ELSIF ratelimit <= 0 THEN
RAISE NOTICE 'out of credits';
ELSE
INSERT INTO users.ratelimits(user_id) VALUES (2);
RAISE NOTICE 'error';
END IF;
END IF;
END $$;
does it work?
yeah but where would i add it
add it right after the first if statement
f (message.content.startsWith("$ban")) {
if(message.member.guild.me.hasPermission('ADMINISTRATOR')
var member = message.mentions.members.first();
member
.ban()
.then(member => {
// Successmessage
message.channel.send(
":wave: " +
member.displayName +
" has been successfully banned https://gfycat.com/playfulfittingcaribou :point_right: "
);
})
.catch(() => {
// Failmessage
message.channel.send("Access Denied");
});
}
right thwre
hello
probably beacuse you forgot curly braces yeah
you're missing fundamental knowledge lol
i fixed it lol
How can I do something like this:
bot.users.get(user).send("THE CORRUPT HAS APPEARED! YOU FAILED TO DEFEATH THE CORRUPTED!")
let usera = await getScore.get(user)
usera.raid1 = 0
setScore.run(usera)
})```
I want to access each user who has a certain value
client.on("message", message => {
if (message.content.startsWith("$ban")) {
if(message.member.guild.me.hasPermission('ADMINISTRATOR') {
var member = message.mentions.members.first();
member
.ban()
.then(member => {
// Successmessage
message.channel.send(
":wave: " +
member.displayName +
" has been successfully banned https://gfycat.com/playfulfittingcaribou :point_right: "
);
})
.catch(() => {
// Failmessage
message.channel.send("Access Denied");
});
}
}
})```
if i addcurly brackets like that it doesnt work
i think your code needs organizing
formatting?
oh okay
how tf do you not know how to use an if statement
im an idiot i was missing a )
I want to get each user who has a specific value in their row and access each of them. I want something like Js sql.prepare("SELECT * FROM raid WHERE raid1 > 0 AND NOT id='685337576810610734'").run().forEach(async (user) => { bot.users.get(user).send("THE CORRUPT HAS APPEARED! YOU FAILED TO DEFEATH THE CORRUPTED!") let usera = await getScore.get(user) usera.raid1 = 0 setScore.run(usera) })
But for it to actually go through each user who has raid1 > 0. Im trying to iterate through the array as its output but I have no idea how to start this out.
Node.js
Oh shitt
Hey, I have a question... when I type a command for my bot... Why does it send the same thing multiple times in the command?
Ill get a screenshot
if (message.content.startsWith(PREFIX + "roll")) {
message.channel.send({
embed: {
color: 3447003,
title: "cinnamon roll"
},
fields: [
{
name: "Here is a cinnamon roll",
value: "https://gfycat.com/defiantgrimydodo"
}
]
});
}
});```
you have multiple command handlers, @clear wraith
why doesnt that embed work
learn how js works
that embed only sends the title
fields should be in embed probably
if (message.content.startsWith(PREFIX + "roll")) {
message.channel.send({
embed: {
color: 3447003,
title: "cinnamon roll",
fields: [
{
name: "Here is a cinnamon roll",
value: "https://gfycat.com/defiantgrimydodo"
}
]
}
});
}```
like that
Why are you deleting the message twice?
Ooo.. lemme fix that
now the command doesnt work at all
message.channel.send({
embed: {
color: 3447003,
title: "cinnamon roll",
fields: [
{
name: "Here is a cinnamon roll",
value: "https://gfycat.com/defiantgrimydodo"
}
]
}
});
}```
oh yeah
wait what?
Forget about that, just noticed that you built the embed inside the send function
is the message just not showing up?
when i type c!psinfo the command works. It just sends it multiple times in a row
The message shows up, yes. I just don't know why its sending the command multiple times
I need money, please, my mother is in surgery, the date she left us alone, you donate at least 1 euro
Bruh
@earnest phoenix begone, human
@mods
@earnest phoenix Not the place for this type of stuff
wasn't going to
I may have a fear of mod pings
yeah the message just doesnt show up
timo thats a fat ban
Probably it's a duplicated handler
const Discord = require("discord.js");
exports.run = async (bot, message, args, config) => {
let user = message.mentions.members.first() || message.author;
let money = await db.fetch(`money_${user.id}`);
if (money === null) money = 0;
var fs = require("fs");
fs.readFile("./e/cmds.json", "utf8", function(err, contents) {
var c = JSON.parse(contents);
if (c.economy === "0") {
message.channel.send();
} else {
cc();
}
});
function cc() {
const embed = new Discord.RichEmbed()
.setColor("BLUE")
.setTimestamp()
.setDescription(`${user}, has $${money}`);
message.channel.send(embed);
name: "balance";
}
};
Why does this command not work when i type c!balance?
i only see one string mention of "balance"
Because you're not checking for c!balance anywhere in that code
we're not wizards, we can't know why because you don't provide your codebase and what you're doing
use debugging tools available to you to find the root of the problem
Also either use ```js or https://hastebin.com please
Ok
or gist
is sending your ID to discord for bot verification even trustworthy?
@dull oriole @sour stream
@frozen dagger yeah?
🙃
is there a primal reason for discord to know your identification to verify your bot?
cause it seems very stupid
why not just verify via phone number or something
who knows 🤷♂️
glitch + light theme 😩
gitch in the first place
how did you incorrect yourself
shut
yes im a big hypocrite
let prefixes = JSON.parse(fs.readFileSync("./prefixes.json", "utf8"));
if(!prefixes[message.guild.id]) {
prefixes[message.guild.id] = {
prefixes: botconfig.prefix
}
}
let prefix = prefixes[message.guild.id].prefixes;``
`
How do i set this as a constant for everysingle ${prefix} in my Main js file
is sending your ID to discord for bot verification even trustworthy?
@wanton nova an ID alone is harmless
Ah, nevermind, I see what you mean
yeah...
im under 16 so i dont have a drivers lisence
*license
so cant send that...
hopefully they fix soon...
Well, the id has you photo, so it's not like someone can impersonate you
yeah but still
its sensitive information
this isn't a legal document
this is a discord bot
You don't even have private data anymore, privacy has gone to space in a long time ago
#memes-and-media btw
ah
I want to get each user who has a specific value in their row and access each of them. I want something like Js sql.prepare("SELECT * FROM raid WHERE raid1 > 0 AND NOT id='685337576810610734'").run().forEach(async (user) => { bot.users.get(user).send("THE CORRUPT HAS APPEARED! YOU FAILED TO DEFEATH THE CORRUPTED!") let usera = await getScore.get(user) usera.raid1 = 0 setScore.run(usera) })
But for it to actually go through each user who has raid1 > 0. Im trying to iterate through the array as its output but I have no idea how to start this out.
Node.js
How do I Select all users with raid1> 0 and then access it?
I dont think sqlite supports that
let prefixes = JSON.parse(fs.readFileSync("./prefixes.json", "utf8"));
if(!prefixes[message.guild.id]) {
prefixes[message.guild.id] = {
prefixes: botconfig.prefix
}
}
let prefix = prefixes[message.guild.id].prefixes;``
`
How do i set this as a constant for everysingle ${prefix} in my Main js file
How can i verify my Discord bot? Does anyone know?
for what
get the required amt of servers
official discord bot developer?
Yeah
Ok
100*
go to that bot and enter your information
Stripe accepts different verification methods
like passport, driver's license, but all vary on country
Ok, Thanks!!
@calm shore try not using a json as a db
lol
a json file will break but go ahead if u really want to, just use a db which isn't a json
but, ur choice
If you aren’t gonna help don’t say anything at all. A user’s DB is up to them and based off personal preference.
Ive been using json for a year
no problems
that isnt the problem nor is what i was asking for
I am having trouble with some commands like this... its an error with the id... but not sure what it wants
what did i do wrong
im confused
ill copy the code
how would I get the total memory free to mb from os.freemem()?
I'm on discord.js
let targetuser = await db.fetch(`money_${user.id}`); // fetch mentioned users balance @earnest phoenix. what did i do wrong?
is user defined?
would i but that at the end of the code, or infront of the code
Also, you must be coping and pasting because otherwise you'd have the required variables.
I have no one to copy from. so how am i copying??
You have the internet to copy from.
ok den
Does anyone know if it is possible to make a dashboard for my bot on bubble.io? (ping me when read.)
@earnest phoenix probably
As long as you can connect to your bot's database you're able to do it
Alright, thanks.
any reason why a client wont connect to discord?
um hey i have a music command that was perfectly working until now... and now the music isnt playing.. the dispatcher seems to be ok and everything but the music still not playing... any idea of how can i fix it?
thats the code i use: let dispatcher = connection.play(ytdl(link, {filter: 'audioonly',quality: 'highestaudio', highWaterMark: 600}),{ volume: 0.5, passes: 3 });
Did you change any code before this happened?
nop
tried to play music from a file and it worked
its the ytdl apparently
but why does this happen
No idea
if(message.content.startsWith(PREFIX + "embed")){
message.channel.send({
embed: {
color: 15158332,
titls: "Continue:",
fields: [
{
name: "!continue bob",
value:
"You choose bob !continue bob to continue the adventure or do !cancel to choose nick"
}
]
}
})
}```
does anyone know why that embed doesnt work
nothing sends
What is PREFIX? Did you run the command properly? Are you getting an error?
PREFIX is ^ and i did ^embed and it sent no message and no
Try logging PREFIX and see if it's truly only ^. It may also be where it's in your code.
@sudden geyser i tested his bot with him but no matter what... It doesn't send embeds
Well could you show the source code for whereever that code is in your file
We also tried the <discordrequiredname>.MessageEmbed()
And that also didn't work lmao
it has to be glitch because i use glitch for me=y bot sadly and i tried it on a test bot f=with visual studio and it worked
well that may depend on your version but can you send the source code
just in the scope of your message listener as I assume it's there
or the whole file if you prefer (as an attachment)
yeah sure
its a 407 line file
im an idoit
why do you have two bot instances
I mean by this
idk
@queen needle why do you have 2 instances of it????
i d k
dont question my dumbness
this is the result of copy pasting code
A question, is it allowed for my bot to say closest match to a command? eg:
user: !inform
bot: Hey user, did you mean `!info`?
um
A question, is it allowed for my bot to say closest match to a command? eg:
user: !inform bot: Hey user, did you mean `!info`?
@coral trellis do you know this :3
it's so messy I have a hard time finding what's wrong except for the fact you're using the same token for two different client instances with its own event listeners.
It's allowed but we mute those type of bots here
I don't want the bot to get muted x)
Would it still get muted if it only does it if it starts with a mention?
@pale vessel lol, I'm way to lazy to manually create all those aliases.
I would like to hear that from a mod. ^^
Still, I would like to hear that from a mod.
okay
I don't want the bot to get muted x)
Would it still get muted if it only does it if it starts with a mention?
@coral trellis, sorry for ping again.
But could you please answer this?
It will get muted because it's essentially unknown command messages.
Ait, then I won't do it.
Thanks for clearing that up. :)
@pale vessel This is the reason why I wanted to hear it from a mod. 😉 Don't go spreading info if you're not sure of it m8
well it's a mention and it won't reply to every unknown command messages, just some so that's why i said send it was fine. well i guess not
sooo im kinda new to html, and was about to submit my HTML into the designated space for my bot...
and i was wondering
what does this gray text mean?
is it commented off?
did you know that you can use markdown?
it could be. look for <!-- in the code
doesnt seem to be any <!-- anywhere...
so it's not commented out
i'll try submitting and see what happens
don't do that
@wanton nova if its surounded by <!-- and --> its comment.
Don't always go off the color.
preview it
ah yeah
forgot thats a feature
oh wait
you can't preview it if you are just submitting the bot i think
cause i dont see the button
it's okay
you can submit it and edit it
it'll take a while until a mod review your bot
alright
it works
just need to fix some formatting
thank you!
also is there a limit to the amount of images?
no
So i have a userinfo command that works completely fine but the field that shows the game or custom status are working too but when you mention a user or use their user id to look at their user info... If the user has a custom status and custom status is only an emoji and not a text...
It shows null... How can i make show the emojis too?
What lib are you using?
Discord.js 12.1.1 lol
I'm getting some really,really weird stuff. https://corynth.xyz/lumap/IW2cJwE3.png
look at the log
reloading the command does absolutely nothing
restart bot
I tried
same result
over and over again
https://corynth.xyz/lumap/SGdRRfVH.png reloading command works
@tight plinth serverQueue is undefined so two options. Either you have misdefined queue or the server doesn't have a queue
Have you defined serverQueue twice?
the problem is actually with line 51 https://corynth.xyz/lumap/0a28YcqF.png
it was the 59th line before
That's a message
It's needs await
Const m = await message.channel.send
did you put delete instead of delete()?
Why you doing if(m)
Yeah but it would send anyways
if (m)``` I tried this to "solve" my problem, but it doesnt solve it wtf
I cant
well then
Like when you make m log it
this dumbshit wont uncache the file, even after restart
what the hell is going on
¯_(ツ)_/¯
trying last restart before going crazy
I know that feeling
Ok
make it an attachment first
new attachment?
How can I retrieve store info in queue ????
that is way too wague
Like
Details : hhhh
URL : hhhhj```
asked in python d.py channel, and nothing. can anyone help me work with timezones?
https://paste.pythondiscord.com/uzufunomix.py
and debug output. Its giving a very wierd offset. @ me if you have any ideas
if re.match("^(?:(?:1[0-2])|(?:0?[1-9])):[0-5][0-9][AP]M$", time): #12h
minute = int(time.split(":")[1][0:2])
hour = int(time.split(":")[0])
am_pm = time.split(":")[1][2:] == "PM"
if hour == 12:
hour = 12 if am_pm else 0
else:
if am_pm: hour += 12
elif re.match("^(?:(?:2[0-3])|(?:[01]?[0-9])):[0-5][0-9]$", time): #24h
hour = int(time.split(":")[0])
minute = int(time.split(":")[1])
else:
e = discord.Embed()
e.colour = discord.Colour.red()
e.title = "Invalid Time"
e.description = f"{time} is an invalid time. Times must be in 12-hour " \
f"`12:00PM` or 24-hour `14:00` formats."
await ctx.send(embed=e)
return
dt = datetime.datetime.combine(datetime.datetime.now().date(), datetime.time(hour, minute, 0), stz)
await ctx.send(str(stz) + " " + str(ftz) + "\n" +
f"{hour} {minute}")
await ctx.send(dt.astimezone(ftz).strftime("%c") + "\n" +
dt.strftime("%c") + "\n" +
datetime.datetime.now().strftime("%c"))
the important part
ftz is the timezone to convert to, 1st arg, hour and minute become the time to convert, and stz is the timezone to convert from (3rd arg)
i'm converting the string to a time correctly, combining it with a data correctly, but the timezone change just doesnt work
If i sharding bot so heroku will divide my ram right ?
i use free host to host a 1500+ servers bot
So, i have an issue with node.js where request.url is undefined..
im not sure what exactly the code you want me to send, but its basically
app.use('/login', loginRouter);
router.get('/', function(req, res, next) {
const queryObject = url.parse(req.url,true).query;
res.send(queryObject);
});```
@earnest phoenix actually 1640
w h y
my bot always max ram in 100 mins
@earnest phoenix anwser my ques 🙂
i have no clue.
i will be the women in the world host 10 000 + servers bot in free host
thats a terrible idea.
i know
ok now this is even weirder, where the webserver is giving me error that the url is not defined, yet the debugger differ
@turbid bough ?
ah nvm, its probably cause req.url only returns a query
and then url.parse returns undefined
/?code=sumcome is what req.url is returning
that wont be parsable
need clue
im originally trying to get a query
ok nvm
im dumb lol
i never imported url.
i was like "why is url undefined????"
boom, it works now
now i need to know how to safely store the login code
@cerulean pebble yes it will
if you are using heroku and ur bot is in 1000+ servers
try not using shards
as the memory usage can go high and ur shards are just gonna crash
resulting ur bot to die
try it if you want
Any idea why the top.gg widget takes a second or so longer to appear on my website than the rest of the site?
Is it a problem my end or is it their end?
@true ravine ?
yeah they always load slower
Oh okay thank you
I assume it's because it's an svg that it has to download rather than an image?
Idk quite how it works lol
all i know is that it loads slower
Yeah thanks anyway tho lol
should user access token be stored in cookies?
no
crashh
this happn when you use free host
CPU 200% ?
in 10 mins
it's impossible
get a vps or upgrade lol
If you have a card you can get 1 year of AWS which is a single xeon core and 1gb of ram - ik it's not a big improvement but it might tie you over till you can get something good
^
Makes sense
do no shard
if(collected.first().content == randomnumber) return message.channel.send(yesembed).then(coins.add(`${message.guild.id}.${message.author.id}`, parseInt(betdouble)))```
Im not able to add coins because thats in the .then(collection part
can you give an example?
...code here
}```
@finite bough poor girl without money 😦
dont shard
@finite bough i am near 2500
optimise ur project
don't cache things you won't need
Profile.findOne({
channelID: message.channel.id
}, (err, res5) => {
if(err) console.log(err);
if(!res5){
const newDoc5 = new Channel({
guildID: message.guild.id,
channelID: message.channel.id
})
return newDoc5.save().catch(err => console.log(err));
} else {
if (res5.useallowed === "false") return
}
})
```Guys, how do i async this?
I'm using mongoose
Promisify the function or put the rest of your code in the callback
I see, thanks.
The easier option would be to put the rest of the code inside the callback (the function you provide after your query)
How's that?
how's what?
Putting the code in callback
You just put the code that needs res5 inside the function
Example please?
I mean you've done it already in the code you gave
someFunction({}, (result) => { // This function is the callback
// You can use result here, put all the code that uses result here
});
// You cannot use result here
Oh, okay thanks
@small prairie Use the MessageAttachment constructor
It doesnt seem to work
(node:14514) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body
someFunction({}, async (result) => { // This function is the callback
// You can use result here, put all the code that uses result here
});
// You cannot use result here
Would this work?
Yes i know its buffer as if i send its in normal message its sent
Legendary, which function are you using to set it to the embed
yes Kayui that will work
Thanks
.setImage
Try with attachFiles, setImage only accepts a string
.attachFiles([theAttachmentYouCreated]);
That's the only way to add it afaik
im guessing this is djs
the docs have an example on how to use a local image in an embed https://discord.js.org/#/docs/main/stable/class/TextChannel?scrollTo=send
just delete json.sqlite 
and how
there is no delete option i see
copy ur db file locally & edit it using a sqlite db editor
Right click -> delete file
...
I mean it works you just need to remake it
Hey, how can i do to check if the computer is connected to the internet?
@west spoke any forks available then?
spoon-feeding
fork-feeding
yikes.
🤣
const ifConnected = window.navigator.onLine
if(ifConnected = true) {
connected = true
} else {
connected = false
}
Shouldn't this work?
onLine?
I'm not sure.
yeah that seems correct
(node:31313) UnhandledPromiseRejectionWarning: ReferenceError: window is not defined
Ok.
you are not running this in a browser are you
Nope.
thats why there is no window
I'm trying to check for an internet connection while checking the token.
Ah.
Ok
@mossy vine, how could i get this function to return a true?
connected: function() {
require('dns').resolve('www.google.com', function(err) {
if (err) {
connected = false
} else {
connected = true
}
})
}
what are you doing
Trying to get a true value
or false
depending if the device is connected to the internet
return false
bot.login(_token).catch(err => {
if (utils.connected() === true) {
error('Token provided is invalid! Please run node configure.js to change it!')
} else {
error('You seem to be offline!')
}
})
Ok.
I'm trying to do this ^^
uhm
if you are offline you are not going to get a connection anyways
and login will reject with a different error if token is wrong
^
Is anyone else having issues with visual studio code right now? The program says I have zero problems with the code and I am connected to WiFi. When I type “node .” Into the terminal it doesn’t even come up with an error. It just does nothing
I’ve tried updating visual studio code and it’s not worked
when i add the bot discord sais i have 1590 servers but when i open my bot my shards sais 2135? some1 knows how can i fix it?
Even restarting my laptop too
hm whats wrong with it
It responds to any prefix
?
fix it then
what lib do you use
?
or.. just paste fragment of your code where you check prefix
show code
Do you use discord.js/Eris or what? @sacred mountain
Discord.js
so it is node.js
lets say message is your message content so you need to check if message.startsWith(prefix), where prefix is your prefix string
So first near the start I hav:
it's message.content
What
Uhh
What did i do
on start of this on message event code
just check if(message.content.startsWith(PREFIX))
is he trying to make a prefix?
and if not return
let args = msg.content.substring(PREFIX.length).split(" ")
switch(args[0]){
Why doesn’t that work
args[0] is your command name
Yh
not actually arg
its part of the prefix
do command = shift
!commandname
Look
Ok
after that, do command = args.shift() and switch(command) {}
so now args[0] is the actual args
How can i replace info on json.sqlite?
i use quick.db for database and i want to make a reset all coins command
@sacred mountain also have this in your code too:
if (message.author.bot) return;
For it to not respond to bots or itself
is it just saying error 520?
yep
5xx means its discord shitting itself
and a lot of error
lmao
How long your bot been running in the background? @lean swan
9 days
@pale vessel the bot doesn’t work at all now
Show code?
erh
const / let or var
Wait why didn’t I do const for command
¯\_(ツ)_/¯
Lol
Hmm
Lemme try now
You are using substring AND shift
Yh
he split it afterwards chill
It doesn’t work
It responds to its prefix now
But any other prefix with 2 characters then !
Anyone know how to fix it?
show code
the best method 👏
Does anyone know how to fix it
Salty
you didn't add if (!msg.content.startsWith(prefix)) return;
Where
Yh but where
Uhh
Where
Under the message event
Oh
up to the msg.reply line
Wait what
Oh
oh
What just under it?
?
True, you're right
above.
Under
bot.on('message', message => {
think
Thinking skills has been increased to 100
There?
Yes
So now that will work?
Try it and SEE
I think you need to learn some JS basics
Dude
Did I say something wrong?
You want to return when the message does NOT start with the prefix
And that's the correct way
Lmao
What
Oh
oh
Then that will work?
=>
if (!msg.content.startsWith(PREFIX)) return;
Why return if it does
How can i replace info on json.sqlite?
i use quick.db for database and i want to make a reset all coins command
Should it be if it doesn’t
! makes it so if it doesnt
Oh
@sacred mountain if the message's content doesn't start with it's prefix it returns nothing
^
msg.content.startsWith(PREFIX) returns boolean
Ayy
true or false
Hmm
adding ! makes it return if that bool is false
! makes true from false and false from true
so when message content starts with prefix it returns true and ! makes false so it does not return and go further
I asked this before but nobody responsded:
So i have a userinfo command that works completely fine but the field that shows the game or custom status are working too but when you mention a user or use their user id to look at their user info... If the user has a custom status and custom status is only an emoji and not a text...
It shows null... How can i make show the emojis too?
(Still wondering how to do it...)
maybe nobody knows
Lol
yo so does anyone know how to make the bot send nsfw in an only nsfw chat? (javascript)
Just check if the channel is nsfw toggled
yea but how would i do that
Read the lib docs for channel
client.shard.broadcastEval('this.channels.cache.get("696570986811621406")')
.then(channelw => channelw.send(`Bot ${client.user.tag} Online! There are ${totalMembers} users and/or bots online. ${client.user.tag} is connected to these guilds: \n ${client.guilds.cache
.map(g => g.name)
.join(", ")}`).catch(err => console.log(err)))
client.shard.user.setStatus("online");
client.shard.user.setActivity(`${clientactivityset}`);
```I'm trying to shard my bot, what did i miss?
It won't work, no error codes
@lucid pasture https://discord.js.org/#/docs/main/stable/class/TextChannel
thx
@lucid pasture
return message.channel.send("This is not an nsfw channel");
}```
ight ight thanks guys
Kk...
.
@earnest phoenix thx chief works like a charm
Np
What's the optimal way of getting a random element from an array, where every value has a certain chance to be returned?
Currently I first get a random value from the array and then check if it will be returned or not:
while (res.length !== amount) {
if (!arr.length) break;
const eventIndex = Math.floor(Math.random() * arr.length);
const eventValue = arr[eventIndex];
if (Math.random() < eventValue.odds) {
...
}
}
But is that truly depending on the chance of the variable? eventIndex can be the same value twice, so the chance kinda doubles if you get what I mean, also any other way of doing this without a while loop 
const _ = require('lodash')
const randomElement = array => array[_.random(0, array.length)]
const exampleArray = [23, 351, 213, 521, 4123]
console.log(randomElement(exampleArray))
Sorry if I couldn't understand
I think he asked What's the optimal way of getting a random element from an array, where every value has a certain chance to be returned?
Adding a module doesn't make it optimal
Yeah every value has a different chance of being returned, so your solution won't work as there's an equal chance for every value
They want weighted chance
I read half my bad. @cinder patio can you explain more?
For example: [{odds: 0.5}, {odds: 0.7}, {odds: 0.2}]. The first value has a 50% chance of being returned, the second has 30% and so on...
yeah weighted chance exactly
https://www.npmjs.com/package/weighted-arrays perhaps check this?
Hey guys! I wanted to get a bit of help in my code...
There's a role, and I already got the amount of how many members have that role...
Now, would like to get the half of the members that are in that role... How could I get it?
(Ping when answering to my doubt, please) - Thanks! ^^
@cinder patio solved?
I prefer not using any external packages
@coarse topaz you mean you want to divide it by two?
${(object.size/2) +1} ?
ooohh okay... let me try 🙂
i think that should work
@cinder patio you can dig through the source code, it has no dependencies
But adding the code would basically be the same as indtalling a module with no dependencies
can someone help?
oh man, that worked, @oak cliff Thanks for your help!!
Could you help me in something else? x)
i can try to :)
let guild = bot.guilds.cache.get(`675254454139748352`) const channel999 = guild.channel.cache.get(`694189734146211901`) channel999.send({ embed: embed }) });
-ask2ask @earnest phoenix
@earnest phoenix
Don't 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 and just ask the question.
Please read https://dontasktoask.com/ for an explanation on why this is an issue.
ok
ur fine
?
@earnest phoenix what seems to be the issue with your code?
How could I figure this out?
paste code
It needs to be inside a template literal


spoonfeeding