#development
1 messages ยท Page 995 of 1
^
new Date(Date.now()).getTime() will return a unix timestamp @lusty quest (also how will a document be made after you peform the action)
@golden condor That's literally the same thing as just doingDate.now()
Although I don't know if that's what you need.
You don't need to pass Date.now() into new Date, It's kinda pointless.
@warm marsh ty so much it works now
He said Date.now() returns milleseconds
sounds like a unix timestamp with extra steps
So does getTime
@warm marsh that does not return the correct time
What are you trying to do?
Date.now() returns the milliseconds between January 1st,1970 and today
I just read a couple stack forums and it said .getTime returned unix
My time => 17:11 => your function i tested => 12:18 @warm marsh
You have to change the locale
^
But your image time won't be updated like embeds.
Changing locale

Inside the toLocaleString('localehere')
try use moment
const seconds = Date.now( ) / 1000 >> 0;
console.log( `Current UNIX time is ${ seconds }.` );
@golden condor i dont need the Unix Timestamp. i want that MongoDB gives me a Document where the timestamp < Date.now()
does anyone have a tutorial for mongodb currency system?
well thats my database call function : client.getEndedAuctions = async time => { const data = await Data.findOne({ timestamp: {"$gt": time} }); if (data) return data; else return; };
and here i call it const time = new Date(Date.now()); const fauction = await client.getEndedAuctions(time);
maybe i need to use $gte
http://node0.s8s.app/F5D3 this is the timestamp in the database
and the time value is at 2020-06-26T12:58:22.895Z
Can I have some help, I get this error with my eval command
You're doing timestamp is greater than the current time?
the eval command is
const args = message.content.split(" ").slice(1);
if (message.content.startsWith(prefix + "eval")) {
if (message.author.id !== "529770099285032980")
return message.channel.send(
"**error** Only the bot owner can execute this command!"
);
try {
const code = args.join(" ");
let evaled = eval(code);
if (typeof evaled !== "string") evaled = require("util").inspect(evaled);
message.channel.send(clean(evaled), { code: "xl" });
} catch (err) {
message.channel.send(
"`:x: Error preforming eval command`" + "(" + err + ")"
);
}
}
});```
Shouldn't it be less than?
What is "clean"?
the timestamp in the database is always in the future. and i want to return only the timestamp that is in the past
Clearly you didn't define it, which is exactly what the error is telling you
So if they're in the past, they'll be lt
Saw it on a github turtorial
i think i know what bot framework he uses. there is a way to clean out the Client Keys etc
Don't just copy-paste
but when I removed it I get 921937284684676 errors (11 errors)
so it will not return any sort of important stuff in a error
if (typeof(text) === "string") {
return text.replace(/`/g, "`" + String.fromCharCode(8203)).replace(/@/g, "@" + String.fromCharCode(8203));
} else {
return text;
}
};````he misses this
can someone help me?
can someone help me?
h
only if you ask something in first place
@lusty quest - Old dates will be lt the current.
thx
does anyone have a tutorial for mongodb currency system?
one sec
https://www.youtube.com/watch?v=pfuW83GdBK4 @pure lion yes i know youtube, but he usually got a Github repo for this stuff
hi, with css or bulma, does anyone know how i can make it show a word and add somethign to show they're different things, so i've got rn:
how can i make it be soemthng like word 1 | word 2 | word 3 etc ?
@digital ibex - Are they individual elements?
yeah, its just: html <table class="table"> <thead> <th>Custom Commands</th> </thead> <tbody class="table-body"> <% commands.forEach((command) => { %> <tr class="row"> <th><%= command.name %> </th> </tr> <% }) %> </tbody> </table>
You could use borders and just use css nth child
on th, i done border-color: red; but nothing changed
Have you tried border: 1px solid red;
hmmm
Tables may require that you change the border styles of the actual table, not just the cells
ah ha
Like border-collapse and such
Now just remove top and bottom
And you can use something like last child and first child to remove the left and right borders for them
Why are you using a table for that anyhow?
i kinda like it, i think if i changes the colour and the background colour, change the font it wouldnt look bad
because
its going to go down, and after every like 10 commands, its going to go to a new page, and on that line, you can edit the command
if that makes sense
let lois = 0;
for(ise of this.split(/ +/)){
if(ise.includes(string.toString())){
lois+=
}
}
return lois;
}
"EEE".howMany("E");```
`Syntax error: Unexpected token '}'`

Lol
Is there a way to make a currency system, Like dank memer? Where its global
Use a DB
use a Database
But what's confusing me is that you're adding rows with tr... But it's actually adding columns according to your images
(dont use a file database)
^^^
You can use a mysql database. Thats fairly easy to setup for NodeJS
ok
Can somebody tell me how does this have an Unexpected token of '}'?
let lois = 0;
for(ise of this.split(/ +/)){
if(ise.includes(string.toString())){
lois+=
}
}
return lois;
}
"EEE EEE".howMany("E");```

@earnest phoenix did u tried it without eval?
if you cant afford a database server. SQlite style databases like quickdb or Enmap are good in the beginning
No @earnest phoenix
Then try :d
Doesn't matter where you use it
are you sure
This works but turning that into that function gives that error
for(es of args.join(" ").split(/ +/)){
if(es.includes("es")){
lvs++
}
}
lvs```
Ok, is there an NPM package?
depends on what database you want to use (yes)
ok
can someone help me?
what is your issue?
store the pokemon that should spawn into a DB. then get the command and check if the pokemon is spawned
depends on the database
the usually 3 used are Mysql, postgres and MongoDB
then there are SQLite databases like enmap and quick.db
ok
(sqlite is local on the machine)
idk. never used a json database
I have a json db
And my problem is that when I run cmd that changes data in the json file, it change sthe data but the bot doesnt read it after it restarts, how can I fix it
(Small server)
did you load the file after a restart?
not to say the horrible IO speed
and can DDos your own bot if you store a stupid amount of data
Its 20 users wont use mongo or any other db. I know json isnt recommended
also you can get a free MongoDB instance
also, the amount of stored data per user will be unbearable for a json db
you can store about 500MB of data in there (a efficent bot with 14k users can use about 200MB of data)
hello everyone
alright alright,................................................. I will use mongo, god
its nothing against you. just json dbs are extremely fragile and inefficent
you can store about 500MB of data in there (a efficent bot with 14k users can use about 200MB of data)
@lusty quest my bot with 100k+ users barely reached 100MB lol
gg
does anyone know why my text isn't going into the middle of the table? my code is: html <thead style="text-align: center;"> <th style="color: tomato; display: inline-block;">Custom Commands</th> </thead>
then it depends on how much you store per user
i've got the text align to center on parent, and the child has display: inline-block
@lusty quest this is the size of my database backup files, since they're compressed let's double the size, it's still 18M at most
I store a "spawn and catch" data, credits system, customization/profile data, xp system, badges, tamagotchi data and most used commands/log about each user, and that's ONLY the member stuff
all that data would easily reach 1GB if I used a json db
wow and then only 100MB in the DB nice
i currently make a Auction Bot. that will store "only" a per Server Config and some data for the auctions
nope, this is the total size of my db when restored from backup
Guys
efficent
what is your issue?
bcs you dont remove the tagged user from the reason
you need to remove the first word from the argument
if (!msg.member.hasPermission("BAN_MEMBERS"))
return msg.reply("Sorry, you don't have permissions to use this!");
let member = msg.mentions.members.first();
if (!member)
return msg.reply("Please mention a valid member of this server");
if (!member.bannable)
return msg.reply(
"I cannot ban this user! Do they have a higher role? Do I have ban permissions?"
);
let reason = args.slice(1).join(" ");
if (!reason) reason = "No reason provided";
await member
.ban(reason)
.catch(error =>
msg.reply(`Sorry ${msg.author} I couldn't ban because of : ${error}`)
);
msg.reply(
`${member.user.tag} has been banned by ${msg.author.tag} because: ${reason}`
);
}```
Have you tried let reason = args.slice(2).join(" ");?
If that doesnt work try console logging the args to see where exactly it is
Whats the issue?
@lyric mountain THanks ๐
<thead style="text-align: center;">
<th style="color: tomato; display: inline-block;">Custom Commands</th>
</thead>``` isn't making it go to the middle
its the table thing
hm
Have you checked the width of the parent / child
yeah, looks like the table itself isn't 100% the width
yeah, tables width is 100%
Change either thead or the child to width 100%
pls help
if (!msg.member.hasPermission("BAN_MEMBERS"))
return msg.reply("Sorry, you don't have permissions to use this!");
let member = msg.mentions.members.first();
if (!member)
return msg.reply("Please mention a valid member of this server");
if (!member.bannable)
return msg.reply(
"I cannot ban this user! Do they have a higher role? Do I have ban permissions?"
);
let reason = args.slice(1).join(" ");
if (!reason) reason = "No reason provided";
await member
.ban(reason)
.catch(error =>
msg.reply(`Sorry ${msg.author} I couldn't ban because of : ${error}`)
);
msg.reply(
`${member.user.tag} has been banned by ${msg.author.tag} because: ${reason}`
);
}
change thead to?
so here?
ok wait
let reason = args.slice(2).join(" ");try this
or do ```javascript
let reason = args.slice(member.name.lenth).join(" ");
So someone told me you should always use let instead of var but now I'm wondering why is that exactly?
ziggy, im confused wym me to do?
var is useless chickendev
const and let do exactly what var does
var is deprecated
not exactly but
<thead style="text-align: center; width: 100%;">
<th style="color: tomato; display: inline-block; width: 100%;">Custom Commands</th>
</thead>``` isn't making it go to the middle
@digital ibex try that
its still there bcs of compablility
My friend told me it was cuz var was function scope but that seemed weird
Have you tried putting text-align center on the th?
pls help me i asked 5 times yesterday and no one helped i get this error
https://hasteb.in/adisutem.js
it does the role menu but then it crashes and gives me this error at Function.Module._load (internal/modules/cjs/loader.js:879:14)
(node:1704) UnhandledPromiseRejectionWarning: OverwriteModelError: Cannot overwrite ReactionRole model
will my boat be approved?
wait 2-3 weeks
2-3 weeks or after it floats
lol
does someone know how can i do the custom status of a user when i do userinfo? (discord.js)
yeah
not sure i understand your question
what do you mean DO the custom status?
you want to access user presence?
@hardy vector ```
const newData = {
Guild: message.guild.id,
Reaction: args[2],
MessageID: msg.id,
Role: args[1],
};
where do i put that
well, im assuming thats it, so here we go
in ReactionRole.js?
@knotty sigil
nvm
also you need to do Model.save()
@opal plank ye user presence like if he playing something it will show it
thats what i sent above
how did you then tell MongoDB that you want to save the dataset into a DB?
https://www.youtube.com/watch?v=pfuW83GdBK4 @pure lion yes i know youtube, but he usually got a Github repo for this stuff
@lusty quest sjsjjsjsjssjj thanks
@hardy vector nvm you are right
lol
and isnt newdata supposed to start like this const newData = new ReactionModel({
bc i imported the reactionrole model
?
forget a part of the stuff. i have running the database stuff in a different file.
need to sort it out to post it here
hmmmm
not entirely
the first thing u said is right?
client.createData = async data => {
const merged = Object.assign({ _id: mongoose.Types.ObjectId() }, data);
const newData = await new Data(merged);
return newData.save();
};
``` this function creates a database
const mongoose = require("mongoose");
module.exports = mongoose.model(
"ReactionRole",
new mongoose.Schema({
Guild: String,
MessageID: String,
Reaction: String,
Role: String,
})
);```
i have that
for my reactionrole model
const newData = {
timestamp: expireHuman,
auctionid: auctionid,
authorid: authorid,
highestbider: "",
currentbid: settings.startingbid,
item: item,
messageid: messageid,
channelid: config.tradechannelid,
url: url,
Platform: platformformated,
};
try {
await client.createData(newData);
} catch (error) {
console.error(error);
}
``` this sends the data to the function
anyone here been using the dbl-api js module?
const newSetting = {
Guild: message.guild.id,
Reaction: args[2],
MessageID: msg.id,
Role: args[1],
};
const newData = await new Data(newSetting);
newData.save()
change new Data to your model
@opal plank yes
perfect
lemme ask you this then
const DiscordBotListAPI = require('dbl-api');
const dbl = new DiscordBotListAPI(config.botID, config.ggtoken, client);
requirement, now. If you look at the Client base dbl-api is, you'll see this
that forces a crash after a short period of time
you dont send the Authorisation Header
@opal plank i think u have to ask in #topgg-api
does it not expect an auth header on the Client?
That doesn't look like an official library
you make a simple HTTP request i think. i use the Client but only for the Webhook
using this
it might be for the webhook
though thats what im trying to hook into
since it already handles eventListeners, was hooking into it to trigger some commands
why not the official one? https://www.npmjs.com/package/dblapi.js
did not even know there was an official one, i'll port the code to use that one
ty flazepe
can someone help me?
someone knows how can i display gif in userinfo?
Use imageURLOptions @knotty sigil
its ok
Or you mean like a normal gif or
how do i get the most recently called pokemon ID (the number from the array)(log it to a DB)
then when the person writes .catch, the pokemon name that was most recently called is logged into the mons.json
don't use json for pokemon-related stuff
regarding the question, you gotta store the called ID in a global var
dot dot dot
dude
first of all, why don't u use a switch-case?
also, you do know that there are HUNDREDS of pokemons, right?
Like 700 or 800
It would probably be good to have a pokemon handler, like a command handler
still
those pokemon
hardcoding it is extremely bad optimized and time-wasting
you should make a loop handle that for u
what do u reccomend me doing?
1 - Creating a generic pokemon embed
2 - Using a rng to get a pokemon from the list and saving it to a variable
3 - Showing the pokemon info on the generic embed
a json contaning properties of each pokemon would work on your case. Say, name, region, rarity, image
load it all on memory and access when needed
did someone say JSON
do NOT do database calls for something you'll be accesing constantly
yes, i DID say json
Lol
nice
you could actually get the amount of files inside pokemon folder and get a random json from it
^
this way you'd not need to load all jsons in memory
that'd be using fs quite a bit, no?
making it less intensive on the random access memory
according to stackoverflow:
const fs = require('fs');
const dir = './directory';
fs.readdir(dir, (err, files) => {
console.log(files.length);
});
imgur or something would work great for that
{
"name":"Pikachu", "region":"Unova","rarity":"1","image":"someurl.com/pika"
}
list them all, keep it on memory
im thinking about buying a domain
better yet:
but my shitty isp prevents me from port fowardingh
[
{
"name":"Pikachu", "region":"Unova","rarity":"1","image":"someurl.com/pika"
},
{
"name":"Raichu", "region":"Unova","rarity":"1","image":"someurl.com/rika"
}
]
instead of 800 files in this case
thats what i meant
obj containing the info of each pokemon out there
all i can say is good luck building that
850+ pokemons will take a while
i am doing galar
could be automated to some extent
Could grab it from the wiki
regoin only
he could probably use bulbapedia API
^
300 pokemon i think
that'd work really well actually
300 pokemon made by hand is still quite a bit
could at least get a premade array of all the pokemon and loop a forEach to help you at least build it
idk how to do that stuff
unless you really eager on doing it all by hand
^^
.....
you completely ignored both our switch case and json ideas, didnt you?
if that's hard you should give up on pokecord-esque features
what part of it is hard?
they ain't easy to make
@long yew - regarding your image, there's a chance that none of those execute.
all of it is hard
@long yew - regarding your image, there's a chance that none of those execute.
@paper phoenix how?
if that's hard you should give up on pokecord-esque features
@lyric mountain it isn't gonna be like pokecord that much
you are trying to chew more than you can bite currently
It's picking a new random each time. So that second if, it could roll a 1.
your options are to learn how to properly do it, or give up on it if you arent motivated
we are here to help, but you'll likely not be spoonfed
kk i am motivated
It's picking a new random each time. So that second
if, it could roll a 1.
@paper phoenix how?
try first doing what Kuu sugested, make a generic embed
to do the 300 db entries once i would get a proper DB first. makes handling it way easyer
@long yew - Each time you can random_pokemom, it ois a new number. It could pick a number you've previously checked for.
i do have embeds
depending on how often its being called its better to have it easilly accessible rather than doing DB calls every request
@long yew - Each time you can
random_pokemom, it ois a new number. It could pick a number you've previously checked for.
oh
or make a global variable that can be accesed for the function
even though i dislike globals
this bot is gonna take me like 5 years
learning a language isnt suppose to be quick
from the looks of it, you jumping head on something completely unknown
You have to want to learn the language tho
i doooooooo
@long yew - Think about it like I had a function to flip a coin. If you have:
if( flip( ) === 'heads' )
doStuff( );
else if( flip( ) === 'tails' )
otherStuff( );
That second if flips again. And that second flip could be heads.
hmmm
there are so many wrong things in that code, we usually just point you towards a better direction to accomplish what you want
like Stev said, you want to generate a number once
if you REALLY want to follow your way of thinking, start by doing something like
let n = randomGenerator()```
then access N
also switch cases
So, if taking your approach, it should be changed to:
const pokemon = random_pokemon( arr );
if( pokemon === 1 )
stuff( );
else if( pokemon === 2 )
...
But, as others have pointed out, switch.
though for what i said, you wouldnt need any of that if you use a json to keep the object loaded in memory for being quickly accesible
generate the number and then match it with the object size
@paper phoenix use switch() or the code will be as inefficient as yandere sim
index it
lets say the pokemon.json contains all 300 pokemon, what you can do is check for size if you put it on a map or something, then access is by number on index
instead of having a case for each pokemon
its a much better approach, nowhere near perfect though
@earnest phoenix what
Say it in your native language
bot use LANGUAGE, not OPERATIONAL SYSTEM
i-
imagine a discord bot operating system
ikr
language = java, javascript, python
Operational system = linux, windows, mac
i got discord.js out fo that
ยฏ_(ใ)_/ยฏ
i got i5
or specs
me need help w/ quick.db
i wanna implement a per-guild command disable thing, but i am unsure as to how i:
write the guild ID to the table
delete it later
(it says target is not an array and im retarded too)
do smthing like guildID.disabled.<command> and set it to true
then check if thats true when the command is ran and tada @pure lion
how fix this error as i am not able to run start cmd through vs code terminal!
@summer torrent get ur ass in here ma boi
i have that system in place, and it works, but idk how to delete the value
Do you guys know how to access that object called 0?
or set it to either be there or not

@earnest phoenix variable["0"]
Oh lemme try
sir can you explain the existence of a facebook account on your profile?
you mean boomerbook?
yes
i'd also like to know that
my pc runs on gasoline and facebook.isis
how do i make a user info command
brhh
I have a question, (Don't judge me), Do I put my commands like this (In a index.js file)?
if (command === 'balance') { 'Your balance.' + message.author.balance } else if (command === 'duel) { if(message.author.bot) return; **code here** } else if (command === 'leaderboard') { if(message.author.bot) return; if(!args[2]) **my code** } });
uh
You can, or you can make an actual command handler @still merlin
@still merlin use switch case uwu
Okay thanks!
which will be useful if you have more than 20 commands
since every command has its own file
constantin i cannot say how much i agree
its literally highlighting the stuff thats wrong
ikr
no
bad, copy paste = bad
im guessing you new to bot development
then whats that link for?
it pretty bad ngl
Can anyone suggest me some commands to make for my bot just to learn how to make them?
Hmm
@still merlin remove the } before else if
ok
you could make a ban command idk
I did
actually
wtf
the best tutorial is: read the docs
people will copy paste that and instantly come here saying "how do i do this?"
Lol
how do i make a user info command
making guides is fine, but please dont provide pre-made code
snippets are fine like in the docs
Does anyone know why this is happening? I saw it on the guide while I was trying to learn more discord.js
if (command === 'balance') {
message.channel.send('Your balance.' + message.author.balance)
else if (command === 'duel) {
if(message.author.bot) return;
//finish soon
else if (command === 'leaderboard') {
if(message.author.bot) return;
if(!args[2]) //finish soon
}
});```
still getting errors tho
and the code is
if (command === 'balance') {
message.channel.send('Your balance.' + message.author.balance)
else if (command === 'duel') {
if(message.author.bot) return;
//finish soon
else if (command === 'leaderboard') {
if(message.author.bot) return;
if(!args[2]) //finish soon
}}}```
if (command === 'balance') message.channel.send('Your balance.' + message.author.balance);
else if (command === 'duel') {
if (message.author.bot) return;
//finish soon
else if (command === 'leaderboard') {
if(message.author.bot) return;
if(!args[2]) {} //finish soon
};
}``` @still merlin
you cant leave an if statement open
o
lol i was gonna say that
If(something) do (what?)
but half the time i give help it doesnt work lol
also, you're confusing single line ifs with multi line ifs
that code just gave me an aneurysm
same turtle, same
time to leave Tim to this because he specializes in this
in the code above you're doing ```js
if(message.author.bot) {
return
} else if(command === "leaderboard") {
}
which is likely not what you want
;-;
if (command === 'balance') {
message.channel.send('Your balance.' + message.author.balance)
}
else if (command === 'duel') {
if(message.author.bot) return;
}
else if (command === 'leaderboard') {
if(message.author.bot) return;
if(!args[2]) {/* stuff */}
}```
i was hoping you'd notice
question: have you learned js
likely not
also no @opal plank
question: have you learned js
I know the basic's-
there's no need to put if(message.author.bot) return in every single command
@prime storm
make it global
just put it at the beginning of the message event
^^
you know scopes?
no .-.
let a = 1
if(something) {
let b = 2
}
console.log(a)
console.log(b)
what would happen here?
dont run this code, its just logic
trying to teach you a quick lesson on scopes
A is 1 B is 2 and the if something is (Havent learnt yet) and your logging a b
b would return undefined
ok
b is inside this scope
if i moved console.log(b) right after let b = 2 it would work fine
cuz it can access that scope
same way for the commands you are doing
ok
throw new _mongoose.Error.OverwriteModelError(name);
^
OverwriteModelError: Cannot overwrite ReactionRole model once compiled.
im tryna make a reaction role cmd but i get this error
https://hasteb.in/adisutem.js
it does the role menu but then it crashes and gives me this error
pls help
my 6th time asking
make the author prevetion outside of the scopes
if(command = a) {
stuff
}
if(command = b) {
more stuff
}
But I thought I should mention this is all I know (plus the doc's and guides out there for discord.js)
@hardy vector i think you somehow try to overwrite it wrong
.-. Its not related I just wanted to mention I'm still learning like basic stuff
did you create it or update it?
ah, i see
@hardy vector thats the wrong syntax for retriving data
wait so what do i do
how do i get avatarURL of a message author
author has the url property
did you want to Create, Update or get the data?
does message.author return the user or member object?
message.member @misty sigil
@hardy vector i guess you want to update the data. then replace findOne with updateOne
does
message.authorreturn the user or member object?
@misty sigilmessage.authorreturns user andmessage.memberreturns member
so message.author.avatarURL?
displayAvatarURL
yeah
author and member works
avatarURL() works too
you should use displayAvatarURL since it returns default avatars if the user didn't set one
oh yeah i forgot that works too
displayURL returns ?string so it's not guaranteed to have a result
sounds illegal to me
sounds like unsolicited marketing



user.bot is undefined
ยฏ_(ใ)_/ยฏ
is your user defined?
yea
wait a sec
iirc will return a boolean
let member = message.mentions.members.first() || message.member,
user = member.user```
both return the user object so member = user
pong
wait? why did you want to get the user object of a member?
@summer torrent get ur ass in here ma boi
@earnest phoenix
it would be easyer to get message.author and message.mentions.users.first()
lol
user object of member, im making a user info command
technically bots can only be used in testing right? not sure if doing an eval here would be fine, since it likely doesnt have perm to post here regardless
yea
much easier to show it here right away than going and showing an example in testing
which testing channel?
either works
2
you need lockdown and unlockdown command ?? see my channel :)
if i wanted i could make a lock and unlock command myself
^
not like its hard
cant be more annoying than switching the code from Mysql to MongoDB
i'd recommend postgres, but mongo is fine too
took me 3 days to learn the backend stuff for getting the mongoDB server running and then getting 3 of them Running in a Cluster
i dont switch again
after i changed one bot already
@hardy vector i guess you want to update the data. then replace findOne with updateOne
@lusty quest wait but they told me i was overwriting it somewhere
its all i can say bcs there was the wrong syntax for getting the data i guess. or did you got somewhere a save down there?
I can send embed with webhooks?
idk, do you wanna?
the bot say
2020-06-26T16:28:35.522037+00:00 app[worker.1]: (node:4) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message```
help anyone
const bots = await Bots.find({
state: "verified"}, { _id: false, auth: false })
i want sort it by desnding
const bots = require("@models/bots.js")
why is my member.bot returning true for bots and undefined for users
i told you
member.user.bot
member doesnt have a bot property accesible in it
you need to access user for that
Print(abc)```
const Bots = require("@models/bots");
const bots = await Bots.find({}, { _id: false, auth: false })
return bots.filter(bot => bot.state != "deleted")
help me
i want make it sorted by descending
thats Mongoose or MongoDB
where is your .sort()
how do i use id as a ui command arg?
Where i can find yt api?
can you help me with making a discord.js bot because i try making one and it never gets online
wait
k
what is it
its old
where did you copy paste it from
the problem is im still learning javascript and i still havent found a way to get it online
Each time a user executes a command and its has one of a pokemon on it or buys a pokemon how do I display the pokemon they have-
Alright thanks
const discord = require ('discord.js');
var client = new discord.Client();
const token = "token";
client.on("ready", ()=> {
console.log("Ready!");
client.user.setActivity ("sw! help " (type: "GAMING"))
});
newFunction();
function newFunction() {
cost;
prefifx = "sw!";
}
client.on ("message". (message)) => {
};
that
const token isnt actually your token
oh
but you censored im a dummy
then what
then put client.login
const token = "your token"
k
also i havent checked that out but is the discord.js tutorial from the website accurate and does it work
throw new _mongoose.Error.OverwriteModelError(name);
^
OverwriteModelError: Cannot overwrite ReactionRole model once compiled.
im tryna make a reaction role cmd but i get this error
https://hasteb.in/adisutem.js
it does the role menu but then it crashes and gives me this error
someone else said its cos im defining schema twice but im not
Is it possible to extend the GuildMemberManager structure from discord.js?
Is Math.floor(Math.random() * 6 + 1) a random number between 6 and 1?
yes
ok thanks
@earnest phoenix yeah, with classes
does anyone know if its possible to check if a message is an image? im using eris btw
i cant find anything in the docs about it
I mean... That's what I'm trying to do...
RangeError: "GuildMemberManager" is not a valid extensible structure.
didnt tim explain extensions
what does ur code look like?
return class GuildMemberManager extends GMM.BaseManager{
Newest(Amount){
return this.cache.map(m => m).sort((a, b) => a.joinedTimestamp - b.joinedTimestamp).map(m => m.user.tag).reverse().slice(0, parseInt(Amount));
}
}
});
message.guild.members.Newest(1);```
class... You see it
oh woops
u can just do something as simple as: ```js
const { GuildMemberManager } = require('discord.js'); // or however u get GuildMemberManage from d.js
class E extends GuildMemberManager {
someting() {
return // cde
}
}```
Umm
im not sure about the Discord.Structure.extend bit and what its really needed for
im not sure
Umm, i don't think that's how it's but imma try
does someone know if you can switch Booleans in a mongoose query? want to invert the boolean
@bot.command()
async def giveaway(ctx, channel, duration, winners, item):
embed = discord.Embed(
title = "**Giveaway**",
description = item + "\n **React with ๐ to enter!** \n **Number of winners: **" + winners + "\n **Ends: **"
)
msg = await ctx.send(embed=embed)
await msg.add_reaction('๐')
Whenever i use the command
it doesnt specify a time
even tho i said 2m
lol
surely it's because you're not adding duration to the string
How To Make A Bot Unlimited Host Time?
host it on a vps
What Is VPS?
Virtual private server
But How?
Are They Are Any Way To Get It for Free?
or you could host a bot on a rasbery PI
no
no free hosting is 24/7
Free option - rasbery PI hosting. (Ideal for small bots)
Expensive or cheap option - vps. (Ideal for big bots)
how do i get user object from ID
If I Hosting It From Rasbery Or VPS Are My Bot Still Work?With The Commands I Set In
Using Discord Bot Designer App?
aslong as you upload all the code
so, how do i get the user object from a member object?
in d.js?
yes
member.user
If I Hosting It From Rasbery Or VPS Are My Bot Still Work?With The Commands I Set In
@earnest phoenix If you upload your code to them it should work
ty for the docs btw
can i set a per-guild custom prefix with quick.db?
yes
member.joinedAt is displaying BST, which it was when I joined
user.createdAt is returning a GMT time, which was when I made my account
how could I convert this into GMT
I haven't toutched this file and I get a error- could someone please help (My main file is client.js and the first line is requering fs)
C:\Users\Jon\Desktop\Pokedex\node_modules\uuid\dist\esm-browser\index.js:1
export { default as v1 } from './v1.js';
^^^^^^
SyntaxError: Unexpected token 'export'
at wrapSafe (internal/modules/cjs/loader.js:1050:16)```
it cant handle the export
what's your node version
I havent exported anything though
well depends
export is ES6 syntax
that's an es6 export
I haven't even written in index.js
es6 works in node 14
14 is the newest iirc
you'll need to update
How do I do that without it braking my bot
nothing should break
you can try to run it in harmony mode instead, but updating node shouldnt break your bot
Okay
change the package data to match the proper node version
How do I update node? is it like a command prompt or terminal thing or a pc installing prosess?
member.joinedAt is displaying BST, which it was when I joined
user.createdAt is returning a GMT time, which was when I made my account
how could I convert this into GMT
are you on windows or linux?
windows
so im making a bot in python that reads one line off a document then deltes it but my code deletes everything on the document, can anyone help?
@misty sigil that just returns a date, which defaults to the OS's timezone you can use <Date>.toUTCString() to get the gmt string (gmt and utc are basically the same)
gmt is just utc+0 anyways
HI, i have this code: js switch (message) { case message.content.length: embed.fields.push({ name: 'Content', value: message.content.slice(0, 350), inline: true }); embed.fields.push({ name: 'Deleted By', value: `<@!${us}>`, inline: true }); break; case message.attachments.length: embed.image = { url: message.attachments[0].url }; embed.fields.push({ name: 'Content', value: message.content.slice(0, 350), inline: true }); embed.fields.push({ name: 'Deleted By', value: `<@!${us}>`, inline: true }); break; } and when a message gets deleted, its just saying a messgae has been deleted with no fields, i have this switch statement to add the fields.
any ideas what im doing wrong?
can you show more the the surrounding code?
kk
trying to set new prefix
let GuildPrefix = await commandBLdb.get(`GuildPrefix.${msg.guild.id}`)
let prefix;
if (GuildPrefix == null) {
prefix = PREFIX
} else {
prefix = GuildPrefix
}
if (msg.author.bot) return;
let args = msg.content.substring(PREFIX.length).split(" ");
let _command = msg.content.toLowerCase()
if (!_command.startsWith(prefix)) return;
ive set a new prefix but its not working at all, even with the new prefix
One sec
I dont think that's how switch works https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch
i mean it's not showing up on my embed
You'd probably want to use if's/elses, or you can do this dumb workaround lmao https://stackoverflow.com/questions/36845389/passing-an-object-to-switch-case-javascript
steven, theres no way i can use- yeah
@misty sigil are you on d.js v12?
yes
then it's a function
oki, i'll just use if else
.avatarURL()
thank
yep
now just to get
emoji working lmao
I need help with my bot. When i run node . it says this error: https://sourceb.in/2f445968ed
the code where the error is this: https://sourceb.in/d5399fbad8
hi, im kinda confused how to explain this. when i delete an image, it logs js [ { width: 910, url: 'https://cdn.discordapp.com/attachments/702241622926295092/726153425804591164/unknown.png', size: 29349, proxy_url: 'https://media.discordapp.net/attachments/702241622926295092/726153425804591164/unknown.png', id: '726153425804591164', height: 514, filename: 'unknown.png' } ] so i do message.attachments[0].url and it gets the image, but doesn't embed..
it doesn't embed for some reason... where as https://media.discordapp.net/attachments/702241622926295092/726144270494597240/unknown.png does embed
you can try learning javascript
into this
do something like let ImageEmbed = message.attachments[0].url then create a normal embed message.channel.send(ImageEmbed)
@digital ibex ^
im confused what thats gonna do...
CalumT Can you help me
my issue, is that it doesn't embed. no idea why, it was embedding before, and now its not
CalumT Can you help me
@quick copper using => is for a function which reqEvent isn't a function
amd what should i changed for?
try proxyURL @digital ibex
i tried that too, still doesn't embed for some reason
wait, proxy_url or proxyURL ?
proxy_url, my bad
yeah, that one doesn't embed either
what do you mean by "doesn't embed" by the way
it doesn't show up on discord or it doesn't show up in an embed?
anyone help me trought dm?
Im trying to use mongodb but when I try to create the new db with the settings in the ready events it throws me this error:
TypeError: client.guilds.keyArray is not a function
that's because it's access denied
it probably works on an actual embed where you set the image as
and doesn't show up in the discord embed, i replace it w my avatar and does
@digital ibex both images are deleted from discord when a message is deleted
the urls you get might still work for a few seconds but they will eventually be gone
oh
so both the embed and the url will stop working
GUYS
oof
if you want to preserve the image, you need to download it and resend it as a new image (if there is enough time to download it)
Im trying to use mongodb but when I try to create the new db with the settings in the ready events it throws me this error:
TypeError: client.guilds.keyArray is not a function
discord.js? v12?
mhm
that makes sense, it was working perfectly fine the whole time lol
client.guilds.cache
client.guild.cache.key..?
thanks for the clarification :)
yes
thanks
(process:76276): Pango-WARNING **: 20:43:55.846: couldn't load font "Helvetica Not-Rotated 30px", falling back to "Sans Not-Rotated 30px", expect ugly output. anyone know how to get around this in canvas?
did you use registerFont()?
its good practice to preload the fonts you use, even if they are system fonts, to prevent possible issues
on some systems for some reason it doesnt find system fonts some times
Can someone run me through what I'd need to make a bot dashboard
knowledge of full stack development
full stack includes webserver, network configuration, domain names and dns, databases, client side html css and js
possibly more things
F unck
domain names and dns?
there's always a chinese kid thats better than you btw
@warm marsh if you want to buy a domain name for your website/dashboard
Would it not come under knowledge of "dns" though?
running a website on your home network isn't the smartest idea
I may or may not have kickass internet
you could put them together i guess, but buying a domain is kinda different than configuring it (i did put them together under a single comma separator)
I really wanna be verified okay
.
Fair enough.
I may or may not have kickass internet
it doesn't matter, you're actively exposing your home network to ddos attacks and exposing your ip to anyone lol
use cloudflare
did you use registerFont()?
@quartz kindleregisterFont('Helvetica.ttf', { family: 'Helvetica' });same error
i've probably done something wrong
use cloudflare
Noted
did you copy helvetica.ttf to the same folder?
yes
Are webhook tests working for anyone?
what about Not-Rotated, whats that?
Nothing happens when I click the test button
idk that just comes up randomly
@earnest phoenix not canvas related, but found this in the sharp github maybe it can provide some info https://github.com/lovell/sharp/issues/1162
which links to this https://github.com/lovell/sharp/issues/1277
yep
not sure how canvas uses pango behind the scenes, but its possible that the issue has to do with concurrency
are you doing concurrent drawing of some sort?
can you show code?
yh ill sourcebin
Is this happening to anyone else?
It isnt meant to show anything
you'd get a request to your webserver
not the best for accessibility reasons though, I agree.
unless it said that it sent a request, which I actually forget if it's meant to
I havent have a bot on dbl in a while
@amber fractal It shows a pop up
Its not even sending any requests
ยฏ_(ใ)_/ยฏ
And I try to vote for any bot it says there is an error
@earnest phoenix 2 thoughts: i'd move the registerfont to before the canvas is created, just to make sure, ie right after canvas is required. also, i'd probably do the same for all async functions such as loadImage. Im pretty sure canvas should be well protected for this, but its quite possible that the context switching here could lead to unforeseen issues
for example, you start drawing, you stop drawing to load an image, while the image is loading another command starts drawing on another canvas before the previous is finished
in theory this shouldnt cause any issues, but who knows, its better to be safe
someone uses mongodb?
also im not sure what adding "not-rotated" to the font does, you can try removing it to see if there's any changes
na I didn't have it there before
I added it to see if it does anything different
the issue with pango font loading on windows is quite recent, about 1 month old, while the last node-canvas release is almost a year old
yh saw it on github
some possible suggested fixes is using registerFont with the full font url from the windows fonts folder
And I try to vote for any bot it says there is an error
@ivory pebble I had that issue a few days ago. Is your internet good?
some possible suggested fixes is using registerFont with the full font url from the windows fonts folder
@quartz kindle the font registered
Its been shit the past few days
issue is fixed
I'm actually replacing my modem right now lmao
ty for the help
Ok my internet was slow and that is why I could vote for anything so maybe that is the problem for you @ivory pebble
what fixed it?
@quartz kindle just putting it under the params
I'll try it after I fix my internet
@ivory pebble damn technician out here

How do I
- Use ID for ui command
- Use the
formatparam for .avatarURL
avatarURL({format:bla})
client.users.cache.get(args[0]) @misty sigil this is how I get the user's id
can i remove cache?
im on v12
then you have to keep it
you can use fetch to get uncached members



