#development
1 messages · Page 913 of 1
yeah because ready isnt firing...
which is caused by invalid token in majority of cases
does anything get logged when you run this code
since i changed this
Shouldn't it be bot.login?
oh probably
u have a mismatch
i deleted your thing
whats the name of ur bot client
NOW IT WORKS
...
is because this is wrong
bot.on('ready', () => {
// put code here
})
i know
This is why you shouldn't have client and bot both defined, like I said earlier.
.addField("Invite me!", `Your text here: [invite](generate)`)```
i added this field but its not working, the link might be invaild but its a discord invite link
https://discord.com/oauth2/authorize?client_id=${client.user.id}&scope=bot&permissions=392192
is this inside the ready
@white anvil this is the top of their code earlier where you can see it https://cdn.discordapp.com/attachments/272764566411149314/707894801709662259/unknown.png
wait
bot.guilds.get("700671859800408105").channels.get("707662830081540178").send('a votat voxility')
^
TypeError: Cannot read property 'channels' of undefined
Line 2 and 4, both defined
Why 2 clients!?
https://discord.com/oauth2/authorize?client_id=${client.user.id}&scope=bot&permissions=392192
@earnest phoenix What does it send as? Any errors?
under it
..
u need
well idk what u need i dont use discord.js
i assume u need bot.login and bot.on in this instance
Create one client, log in and listen to the ready event
not client
wait
You shouldn't have client and bot, choose one or the other, else it gets confusing.
yeah client is useless here
bot.user.tag (again why you shouldn't have both)
its ok i fixed it
Lots of bad copypasting
tru
u can vote
@high geode use the test vote function
where is that
what {vote.user.tag
is
vote.user = id
i need really#0001
the tag
vote.tag
?
thanks for help
😉
=)))
@frail ocean
i did it
but what is the user tag
function
vote.user.tag is the id
how can i do it to show really#0001
?
let user = client.users.get(vote.user)
let tag = user.tag```
Since vote.user is the id
let user = client.users.get(vote.user)
let tag = user.tag```
Now you got an api probelm so go to #topgg-api
Hi. I made a function at the bottom of my code but I’m trying to add something that mentions guild but when I run it, it just says guild is not defined. I’m not sure how to define it because I thought it is just part of discord.js
Sure
One sec
const channelChannelID = guild.channels.find(channel => channel.name === collected.last().content)
message.channel.send(channelChannelID)
it says guild isnt defined
Define guild.
how tho
let guild = message.guild```
or smth, depends how you've done it.
no bc its like hundreds of lines long
oh
ok
guild.channels.find is not a function
RIP
now what do i do
im just trying to get it to check if the specified channel is in the guild
discord.js v12?
yh
channels.cache.find
console.log
to check.
channelChannelID is a collection
it didnt find any channel
umm
but the channel is in the guild
const channelChannelID = guild.channels.cache.find(channel => channel.name === collected.last().content)
message.channel.send(channelChannelID)``` is this definitely correct for checking if its in the guild then sending back the id
well all i really want it to do is send a message to that channel
console.log(channelChannelID)
exactly
why tho
that means the channel was not found
but its in the guild
so double check your find parameters
for example, console.log(collected.last().content)
My code. I was using Glitch.com as host
const DBL = require('dblapi.js');
const dbl = new DBL(process.env.TOP_GG, { webhookPort: process.env.PORT });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});
This is not working
you dont need port 3000 in the url
oh
just .me/dblwebhook
@quartz kindle i put js console.log(collected.last().content) console.log(channelChannelID) and it logs the channel id but then undefined
collected.last().content is the channel id?
my bots offline ?
apparently so...
then why are you comparing channel.name to a channel id?
what did you type?
@earnest phoenix check #mod-logs for your bot's ID, it might have been kicked
@sacred mountain thats a channel mention
it will show up in the message content as [#895739845793845](/guild/264445053596991498/channel/895739845793845/)
so your find function is doing if channel.name === [#384598375305](/guild/264445053596991498/channel/384598375305/)
@quartz kindle I fixed how to add back
@earnest phoenix dm the mod who kicked it
ok
Tim how do I send a message to that channel now
So like store it in quick.db then later send a message to it
you can use message.mentions.channels
ok
the same way you use message.mentions.users or .members
Ohh
So if I stored it by doing db.set(key, message.mentions.channels) then how would I later send a message to that channel
@quartz kindle Would I do ```
Const thechannel = dB.fetch(key)
Message.thechannel.send(“test”)
no and no
Oh
did you ever use message.mentions before?
ever
then you know how to use it
Not in that way no
channel mentions work the same as user mentions or member mentions
Ik
how did you use user or member mentions before?
dont you have any code that uses them?
Idk it would take a while to find it but I didn’t use it sending a message to it
Wait
I might have
One sec
Yup
Found it
so you'll notice you cannot use message.mentions.channels directly
because it contains a list of mentions, not a single channel
Yh
so you should know what to do
now, you cannot store an entire channel in a database
because a channel is a complex structure that only works inside the program's memory, it cannot be transferred to a database or any other program
so you need to save only the channel id in the database
user is undefined, cannot read 'tag' from undefined.
Maybe the user isn't cached yet
but I want my name
or the user name before
i use "discord.js": "^11.4.2",
any ideas to fix?
isnt it only a member who has 'tag', not user?
like, isnt 'tag' exclusive to a member>?
ahh ok lol
do you have any ideas
how can I do
to show the name
before the vote
like
really#0001 voted voxility
@earnest phoenix Get the guild count and update the bot's status
What library are you using?
me?
No, Genesiz
@high geode this is basic stuff...
.send(tag+" message here")
v11 or v12?
@high geode this is basic stuff...
.send(tag+" message here")
@frail ocean i need when someone votes
message.mentions.channels.first().id I believe it was
hmm lemme test
@high geode I said what you needed earlier, multiple times.
wth
and if I use
let user = client.users.get(vote.user)
let tag = user.tag```
let tag = user.tag
^
TypeError: Cannot read property 'tag' of undefined
what the hell

@high geode #topgg-api
let is scoped so you are defining tag outside of the scope
im not really sure if that belongs in api as its just a code error
but ok
is it possible to get the message ID of an embed you send in a command? want to store the message id for editing the embed later
Tag isn't defined anywhere, stop just copypasting code without giving it the slightest thought
@high geode you are mixing client and bot
I mean you could of just used the code it shown instead of adding the let user things
console.log(`User with ID ${vote.user} just voted!`); });
But just make it look for a channel instead of console and change it from vote.user to vote.user.tag
@lusty quest .send() returns a promise that resolves to the message object
thx
docs says this function exists, but it apparently doesnt https://link-is-qt.lumap.me/vsaimf9u.png
v12? @tight plinth
yes
perhaps the cache doesnt have the user data or something? not sure on that one dude sry 😦
f
Then it'd be cannot read property fetchFlags of undefined, wouldn't it?
yea it should be if that was the case
I tried with message.author.fetchFlags(), same error
oooohhh
it seems v12 didnt have fetchFlags but 'stable' does, according to docs
are you sure your on latest v12?
Im very confused. js let thechannel = newMessage.mentions.channels.first() if(!thechannel) return message.channel.send(`Either I could not find the channel specified in this server or you did not specify one`) returns that it cant find it even though i provided one
I think it's worth asking in the discord.js server cause it may be a bug
message.mentions.channels.first().idI believe it was
@zenith terrace @sacred mountain
or wait lemme see
Wait what are you trying to do
ye im in 12.0.0
As in command
fetchFlags was added after v12 become stable afaik
so it should be added in v12.1 or something
my bot wuld not work in discordjs v12.1, but apparnetly now it does in v12.2
thx u guys
when I havent updated my v12 code yet
console.log(collected.last().content)
let newMessage = collected.last().content
let thechannel = newMessage.mentions.channels.first()
if(!thechannel) return message.channel.send(`Either I could not find the channel specified in this server or you did not specify one`)
db.set(`thechannel_${message.guild.id}`, thechannel)``` the console then shows ``` [#691631449115459679](/guild/264445053596991498/channel/691631449115459679/)
ReferenceError: mentions is not defined
at C:\...\index.js:178:40
at processTicksAndRejections (internal/process/task_queues.js:93:5)``` does anyone know how i can fix this?
[#691631449115459679](/guild/264445053596991498/channel/691631449115459679/) is the id of the collected message?
no the channel i mentioned in the message
sorry i forgot to explain that
but that is a mention
so why does it say mentions is not defined
you're trying to get mentions from the content
no idea dude, maybe collecting messages doesnt return a full message body or something?
oh
const Discord = require("discord.js");
let coins = require("../coins.json");
const fs = require("fs");
module.exports.run = async (bot, message, args) => {
if(!coins[message.author.id]){
return message.channel.send(":no_entry_sign: **Nu ai nicio moneda!**")
}
let pUser = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0]);
if(!coins[pUser.id]){
coins[pUser.id] = {
coins: 0
};
}
let pCoins = coins[pUser.id].coins;
let sCoins = coins[message.author.id].coins;
if(sCoins < args[0]) return message.reply(":no_entry_sign: **Nu ai destule monede!**");
coins[message.author.id] = {
coins: sCoins - parseInt(args[1])
};
coins[pUser.id] = {
coins: pCoins + parseInt(args[1])
};
message.channel.send(`> :white_check_mark: ${message.author} **i-ai oferit lui** ${pUser} ${args[1]} **monede!**`);
fs.writeFile("../coins.json", JSON.stringify(coins), (err) => {
if(err) console.log(err)
});
}
module.exports.help = {
name: "pay",
usage: "lt!pay [mention] [suma]"
}
Why if i have 0 coins i can lt!pay me how much i want ?
@quartz kindle @neat ingot i have another problem now js db.set(`thechannel_${message.guild.id}`, thechannel) ... .setDescription(`test channel has been set to ${db.fetch(`thechannel_${message.guild.id}`)}`) returns test channel has been set to [object Object]
because your returning the database object i think?
https://link-is-qt.lumap.me/5pgrrhmw.png other problem : docs says it should also returns a list of flags
yes but how do i do that
save thechannel.id
db.set(thechannel_${message.guild.id}, thechannel.id)
oh
the badges/perks the user has
oohh, like nitro etc?
consults flags list
its right there in the picture above
Tim, You like a clean profile?
you got no badges
Hello, I though (and I read) that a bot can send emojis of a server in other servers it belongs to.
But mine doesn't do it :/ why ?
on server A which has the emoji
on server B that has the bot but not the emoji
what i should make when my bot is invited in DBL server?
You need the emoji ID
Sooo, can anyone help me or?
I've them
even not working
<:emojiname:emojiID>
oh maybe yes I'll try this
oh yea it might be that format
cant you just send the raw emoji?
thats the only thing i do with emoji - get a list of custom and print
e.g.: 683047469420249176>
<
683047469420249176>
Oop
Dont work on users lol
@small prairie idk never felt like doing whatever weird shit you need to do to get them
i dont understand the houses thing either lmao
let newMessage = collected.last()
let thechannel = newMessage.mentions.channels.first()
db.set(`thechannel_${message.guild.id}`, thechannel.id)``` how would i now take .id off the end of it because im trying to send a message to that channel but it doesnt work as thechannel.id, i need to change it into thechannel but im not sure how to do that
sending it in a channel @small prairie
@sacred mountain you need to get the channel from the id you have in the database
how do i do that tho
channelID = db.get(whatever)
channel = client.channels.cache.get(channelID)
of you're using v12
@small prairie what <:discordbotlist:id> = <:servername:emojiId> ?
does anyone have a "shiny BH badge" emoji?
if (message.content === "=work") {
let timeoutworked = 36000000
let worked = await db.fetch(`worked_${message.author.id}`);
console.log(worked)
if (worked !== null && worked - (Date.now() - worked) > 0) {
let time = ms(timeoutworked - (Date.now() - worked));
console.log(time)
message.channel.send(`You already worked, you can come back and work in **${time.hours}h ${time.minutes}m ${time.seconds}s**!`)
} else {
let amountearned = Math.floor(Math.random() * 500) + 1
let jobs = ["Scientist", "Developer", "Streamer", "Youtuber", "Cashier", "Shopkeeper", "Investor", "Engineer", "Biologist", "Astronomer"]
let jobworked = jobs[Math.floor(Math.random()*jobs.length)]
let embed = new Discord.MessageEmbed()
.setAuthor(`${message.author.tag}, it payed off!`, message.author.displayAvatarURL())
.setDescription(`${message.author}, You worked as a ${jobworked} and earnt ${amount} coins`)
message.channel.send(embed)
db.add(`money_${message.author.id}`, amountearned)
db.set(`worked_${message.author.id}`, Date.now())
}
}``` it says you can work again in 9 hours why its set to 1 only
@junior bobcat That is workin g for me
<:servername:emojiId> ?
@junior bobcat the bot mught not have external reactions perms
oh maybe yes
omfg
ive just been trying to figure out why my bot now wasnt doing the custom emojiis
yes, it was the perms for me
:/
^ helper function i use, in case it helps
no u es6 me -_-
it's working with <:serverId:emojiId> and the permission x) thanks
also, when im printing custom emojiis on other servers, i dont need to use <: id: id> thing
just use `${emoji} test` if you're on djs
yes
if it doesn't turn into <> then it can be sent as unicode
\😄
cba to fix
forgot that \ escaped the :
woah don't
Hi again. I’m making a form of giveaway feature but how would I send a dm to a random user in the guild?
get a list of users in an array, pick one at random.
How would I do that
wait when u say randomNumber do you mean a random number or actually type randomNumber
assuming you have an array of users, you can get a random array elemnt using:
const randFromArray = array[Math.floor(Math.random() * array.length)];
How could I get an array of users
ye you can also convert the collection to an array by using .array()
or map
map is good
client.users.cache.array()
ahh, fair enough 😄
How would I do map
[...collection.values()] seems to be a recommended way to get an array from a collection, which users is.
gotta love destructuring 😄
Wait so guild.members.collection.values()?
cache if you're on v12
guild.members.cache.collection.values()?
you don't need collection
no '.collection'
cache is already a collection
Oh
^
K
yes
dm would only go through if they have enabled dm from members on server
Aight thanks
I have another question 🤣. How would I send a random thing in the database with like half the key because I have themessage_${message.guild.id} but I want to basically send something random that starts with themessage
if (message.content === "=work") {
let timeoutworked = 36000000
let worked = await db.fetch(`worked_${message.author.id}`);
console.log(worked)
if (worked !== null && worked - (Date.now() - worked) > 0) {
let time = ms(timeoutworked - (Date.now() - worked));
console.log(time)
message.channel.send(`You already worked, you can come back and work in **${time.hours}h ${time.minutes}m ${time.seconds}s**!`)
} else {
let amountearned = Math.floor(Math.random() * 500) + 1
let jobs = ["Scientist", "Developer", "Streamer", "Youtuber", "Cashier", "Shopkeeper", "Investor", "Engineer", "Biologist", "Astronomer"]
let jobworked = jobs[Math.floor(Math.random()*jobs.length)]
let embed = new Discord.MessageEmbed()
.setAuthor(`${message.author.tag}, it payed off!`, message.author.displayAvatarURL())
.setDescription(`${message.author}, You worked as a ${jobworked} and earnt ${amount} coins`)
message.channel.send(embed)
db.add(`money_${message.author.id}`, amountearned)
db.set(`worked_${message.author.id}`, Date.now())
}
}``` it says you can work again in 9 hours why its set to 1 only
@hardy vector
I have another question 🤣. How would I send a random thing in the database with like half the key because I have themessage_${message.guild.id} but I want to basically send something random that starts with themessage
@neat ingot @pale vessel
let time = ms(timeoutworked - (Date.now() - worked));
how i can restart the bot with a command
ms = parse-ms a npm package
I have another question 🤣. How would I send a random thing in the database with like half the key because I have themessage_${message.guild.id} but I want to basically send something random that starts with themessage
@pale vessel @neat ingot
which language @earnest phoenix
discord.js
.hours is a method from parse-ms
process.emit('SIGNINT')
is what i used to rebot my bot. (node.js)
what this does is send the SIGINT event to the process, which you can hook into to shutdown safely
for example:...
(sec)
basically if i did console.log(time)
{
days: 0,
hours: 9,
minutes: 59,
seconds: 50,
milliseconds: 354,
microseconds: 0,
nanoseconds: 0
}
that comes up
wut
oh
'process' is a default node.js thing
ok
contains the running process info
@shut inlet wdym by that
@neat ingot when ur done with that are you able to help me. How would I send a random thing in the database with like half the key because I have themessage_${message.guild.id} but I want to basically send something random that starts with themessage
by sending process.emit(THING) you are sending an event to the process to trigger it. SIGINT will shut down node. hook it to save data to database or w.e you may need to do, then you can shutdown knowing your database isnt somehow comprimized or corrupted
@sacred mountain cant just strip the message.guild.id from the message?
for example "themessage_987123654".replace('_987123654', '')
@neat ingot I don’t want to get rid of that bit it’s just I want it to send a random bit of data where the key starts with themessage_
idk what you mean. can you give an example of what a message you want to send would look like?
k
@neat ingot me or him?
u 😛
If there is themessage_198392917 and the data is “hello” and there is also themessage_09485903 and the data is “bye”. I want it to send the data for a random thing that starts with themessage_ so it would be either hello or bye
Ignore the italics
I’m trying to do _ but it makes it italics
lol
So what would I do
im still confuzed 😄
RIP
Find all entries in the database that start with the message and https://stackoverflow.com/questions/5915096/get-random-item-from-javascript-array
how i can do -loop?(music)in python
:diamond:
@neat ingot can we go dm bc I can explain better
sure, but i respond slower in dm cause i dont look at my notifcations 😄
and i can see this chat window constantly on other monitor (but notifications are cut off) 😛
what will happend when there is no stackoverflow
xD
tbh ive always found stack overflow to be very elitist
So let’s say there are 3 things in the database, one called themessage<underscore>83282947392 with the data “one”, one called themessage<underscore>1038492024 with the data “two” and one called welcome<underscore>3927294 with the data “three”. What I’m trying to do is make something that sends a random piece of data from one with the key starting with themessage<underscore> therefore it could randomly send either “one” or “two” but it can’t send “three” because the key doesn’t start with themessage<underscore>
how i can do -loop?(music)in python
oooohhh ok
so, lets assume that you are able to get the list of all valid things from the database, in this case, both of themessage_'s . once you have that, just pick a random element and return its data
for example
[{the_message_0123: 'one'}, {the_message_0124: 'two'}]
^ is the array of messages. then just get a random array element and return the data, something like
const rand = array[Math.floor(Math.random() * array.length)];
But how would I find the ones starting with themessage_
depends on the database you're using
yea, depends on the database
How would I do it with quick.db
i have never used quick db, so idk their query options 😦
Oh
you could get all elements of the database, and then just iterate over them, filtering out the ones that dont match
Imagine if you had thousands of elements though
oh yea, its not a performant solution at all
I recommend switching your database
but its a potential solution for smaller databsaes
I mean, switching ORMs
Couldn’t I make a table then I won’t have to filter
Since quick.db is an ORM for sqlite3
Wait first how would I send a random thing from the whole database
you get all the entries in an array, generate a random number between 0 and the array's length
I’m not sure how to convert quick.db into an array
imagine not reading the docs
const db_data = [
{the_message_0123: 'one'},
{the_message_0124: 'two'},
{other_messsage_1: 'tada'}
]
db_data.filter(element => {
return /the_message_/.test(Object.keys(element)[0])
})
would be one way to filter the elements from the array once you have them. this tests each elements key and ensures it matches the_message_ (note: your database probably doesnt quite store data in the same format, so this probably wont work and is only intended as example)
Simplest way to do it is to use a good ORM, not quick.db
mongodb/mongoose for lyfe ❤️ (or till i discover something i like more)
how i can check is there duplicate on databse
depends on db
depends ?
yes ?
?
?
oh i using mysql
rip ~ i suck with sql
😦
i mean, most databases allow for some kind of unique key/identifier/element.
ok. i mean, most databases will allow yuo to have data that has to be unique, so it automatically disallows elements that have duplicate data.. for example, an id is generally made to be unique. when the datbase tries to save another with same unique id, it will fail
example from mongoose (mongodb)
notice how my discorD_id has the 'unique' flag set to true
only thing im having a problem with now is it not registering the cooldown
wait maybe in mysql has unique funciton
wait let me see
this will disallow saving any new item into that database with the same id
dbl.webhook.on('vote', async vote => {
let discord = require('discord.js')
let embed = new discord.MessageEmbed()
.setTitle(vote.user.username+" has voted")
.setColor(client.config.color)
.setDescription(`
${vote.user.username} has voted **Epoxy** in [top.gg](https://top.gg/bot/697318252744933406/vote)
${vote.user.username} has recived ${client.config.amount.vote}${client.config.emoji.coin}
`)
.setThumbnail("https://top.gg/images/dblnew.png")
client.channels.cache.get(client.config.vote).send(embed)
});
if i try, database throws a fit and says no
Help
vote.user is just the id? no?
yea
so it doesnt have a .username property
you would need to use the id, and get the user from your client.users before you can access the specific username data
if its just the id, you would have to get user first from discord
as far as i remember, sql does support unique keys.
been a few years since i used it tho
yea it does, thats some code form an old sql highscores list database
whats currentList['name'] for?
ah yeah nvm, thats yeah for tables
does c# have wrapper for mongoose?
is it possible to retrieve messages that has been sent before the bot login ?
I've a channel where I sent "hello"
and with this code it isn't working
// assume we got the channel variable thanks Client.server....
channel.fetch().then(updatedChannel => {
updatedChannel.messages.cache.each(message => console.log(message));
});
``` nothing has been logged, but I logged the channel and I know the variable `channel` is ok
@restive furnace yes https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-mongo-app?view=aspnetcore-3.1&tabs=visual-studio
This tutorial demonstrates how to create an ASP.NET Core web API using a MongoDB NoSQL database.
google says: https://github.com/cesanta/mongoose/blob/master/mongoose.c
@restive furnace
@neat ingot thats C lol
lmao, my bad 😄
aight
c and c# is completely different
yea, i know there are differences
i would say c and c++ is the same
couldnt name you a single one tho
its like saying C++ and Java is the same
ive never used c#, used c++ a little with arduino and ruby extensions
can u answer me please, and after continue this discussion between langs ? 😛 thanks x)
hi here is the answer: answer
c & c++ are like js and jquery if we can compare
c++ has more functions at default, what makes it higher level language, c if im right is the lowest level programming language in the world (excluding machine code)
well c++ ≈ node-gyp
'Access denied for user \'\'@\'localhost\' to database \'bot_cool\'',
pls help
i am using linux
you havent specified an user
idk it shows nothing?
or username ??
nah nvm
const Discord = require("discord.js");
module.exports = {
name: "uptime",
category: "info",
description: "Shows the bots uptime.",
run: async (client, message, args) => {
function duration(ms) {
const sec = Math.floor((ms / 1000) % 60).toString()
const min = Math.floor((ms / (1000 * 60)) % 60).toString()
const hrs = Math.floor((ms / (1000 * 60 * 60)) % 60).toString()
const days = Math.floor((ms / (1000 * 60 * 60 * 24)) % 60).toString()
return `${days.padStart(1, '0')} days, ${hrs.padStart(2, '0')} hours, ${min.padStart(2, '0')} minutes, ${sec.padStart(2, '0')} seconds, `
}
message.channel.send(`I have been online for: ${duration(client.uptime)}`)
}
}
why doesn't it record the days so it only says 23hrs 59mins then it just goes to seconds and restarts without adding a day
Oh it was root not my name
@earnest phoenix, i'd recommend using moment and moment duration for formatting times/dates/durations
wrong adam you pinged
is it discord.js?
yeah
idk documentations says .fetch only returns channel, not guildchannel
@junior bobcat you must .fetch() on messages too.
for example
channel.messages.fetch({ limit: 10 })
.then(messages => console.log(`Received ${messages.size} messages`))
.catch(console.error);```
when you .fetch a channel it only returns a few data, so you would have to fetch the too messages
but, channels should be cached shouldnt it?
[ RowDataPacket { id: 1, user_id: '545490362568015873', user_coins: '10000' } ] how i can get only user_coins
ok, i was on the phone, sorry for slow af reply.
adam, the reason i suggested moment and moment duration, is because its much easier to handle the data, for example, you could do this:
const duration = moment.duration(ms);
const string = duration.format("D [days], H [hrs], m [mins], s [secs]");
[ RowDataPacket { id: 1, user_id: '545490362568015873', user_coins: '10000' } ] how i can get only user_coins
@neat ingot ?
@neat ingot i found the issue
otherwise, heres a function to do a similar thing.
function timeConversion(millisec) {
var seconds = (millisec / 1000).toFixed(1);
var minutes = (millisec / (1000 * 60)).toFixed(1);
var hours = (millisec / (1000 * 60 * 60)).toFixed(1);
var days = (millisec / (1000 * 60 * 60 * 24)).toFixed(1);
if (seconds < 60) {
return seconds + " Sec";
} else if (minutes < 60) {
return minutes + " Min";
} else if (hours < 24) {
return hours + " Hrs";
} else {
return days + " Days"
}
}```
src: https://stackoverflow.com/a/32180863/4766190
i logged a few things
1588857996957
1588854390000
3600000
3606957
the reason its doing that is becuase its seeing it as it over the cooldown
its seeing the cooldown is lower than the now - lastTimeBumped
@earnest phoenix just get the .user_coins value from the object?
undefiened -_-
const data = [ RowDataPacket { id: 1, user_id: '545490362568015873', user_coins: '10000' } ]
data[0].user_coins```
lmao
i honestly cant remember your exact issue 😛
okk
something with timestamps or something
yeah i fix the timestamp issues
Bruh when they gonna change my name
TT
but now i can keep bumping without it putting the timer in becuase like i said above
1588857996957
1588854390000
3600000
3606957
the reason its doing that is becuase its seeing it as it over the cooldown
its seeing the cooldown is lower than the now - lastTimeBumped
which is plus 11 mins
whenever i check for a cooldown on a thing, i would check if 'now - timestamp' is greater than some value
is your 'cooldown' a value of milliseconds?
yes
3600000
is 1 hour basically
im logging it like this
}
const now = Date.now()
const lastTimeBumped = new Date(result[0].last_time_bumped).getTime()
if (now - lastTimeBumped > cooldown) {
console.log(now)
console.log(lastTimeBumped)
console.log(cooldown)
console.log(now - lastTimeBumped)```
hello help pls?
props.help is undefined
I know what you need help with
idk why that wouldnt be working :/
ofc
@earnest phoenix Make sure in /commands all files have module.exports.help
dek thats what im saying lol
😛
im gonna log console.log(result[0])
that's not the best way of doing it
Thx
that's just the Youtube®️ Tutorial™️ way
tbh, the world would be a better place without youtube.
@neat ingot i logged it and got this https://gyazo.com/c080823bb5cd0cf804f494f55937c113
no
much more boring, but yea...
@quartz kindle i done it but now its seeing it higher than the cooldown lol
const lastTimeBumped = new Date(result[0].last_time_bumped).getTime() its something in this
why are you pinging tim?
because
if I was tim I wouldn't like being always pinged in #development
well your not tim
he isn't even online
const lastTimeBumped = new Date("2020-05-07T12:38:55.000Z");
lastTimeBumped.setHours(lastTimeBumped.getHours() + 1);
if (lastTimeBumped - new Date() < 0){
}
is an alternative way to check a cooldown
by taking the date the action occurred, adding an hour to it, then making sure that time - current time is then < 0
still lets me bump unlimited
Do you also update the timestamp?
:/
he mongo
^ database and personality
https://top.gg/bot/534632914445664267 why is iframe not working?
hahah
legit im not sure why the now lasttimebumped is higher than the ooldown lol
because the website your trying to link via iframe does not allow iframes
Because the source website blocks iframes from displaying it's contents
^
oh
@earnest phoenix Have you got some example values with which we could test your code?
is how i got around the iframe issue (thats code my nginx configuration)
@earnest phoenix show full code
the part: frame-ancestors 'self' https://top.gg/bot/652216670370398231" is what allows top.gg to iframe my site
is how i got around the iframe issue (thats code my nginx configuration)
@neat ingot can you paste it here pls
my entire nginx.conf? none of us wants that, trust me!
no, just the csp header
its only the content security policy header thats needed anyway
add_header Content-Security-Policy "default-src * data: 'unsafe-eval' 'unsafe-inline'; frame-ancestors 'self' https://top.gg/bot/652216670370398231" always;
thanks
np 🙂
@strange mango https://securityheaders.com/ is useful to tell you if your headers are valid
flex
"..., please see warnings below"
lmao
if (command === 'vote') {
const filter = m => m.content.startsWith(`${config.prefix}vote`);
channel.awaitMessages(filter, { max: 4, time: 60000, errors: ['time'] })
.then(collected => console.log(collected.size))
.catch(collected => console.log(`After a minute, only ${collected.size} out of 4 voted.`));
}
Channel is not defined
however, google only gets a C rating, so idm 🙂
oh, D rating for google now ~ rip
lol
if(!args[0]) return message.channel.send(embed)
if (args[0] == 'credits') {
let money = db.startsWith(`money_${message.guild.id}`, { sort: '.data'})
let content = "";
for (let i = 0; i < money.length; i++) {
let user = bot.users.get(money[i].ID.split('_')[2]).username
content += `${i+1}. ${user} ~ ${money[i].data}\n`
}
help ? db.startsWith
@earnest phoenix Define it, can't just use random variables
hahaha my site has a D rating
rip :/
dek i did what you said now its under the cool down
but still letting me bump hahah
I'm not gonna fix mine anytime soon
if (channelType === 'text') {
channelID = c[0]
break
}
}
if (now - lastTimeBumped > cooldown) {
const channel = channels.get(msg.guild.systemChannelID || channelID)
channel.createInvite().then(invite => {
bumpLogic(msg, row, invite)
sendEmbed('msg, Bumped .')
})
}
}
})```
most likely an issue here
wait no
something is wrong with the bumplogic
it still shouldnt be calling the bumplogic when its below the cooldown
well yeah thats what i mean
and dw @topaz fjord your on par with google security, just think of it that way 🙂
if(!args[0]) return message.channel.send(embed)
if (args[0] == 'credits') {
let money = db.startsWith(`money_${message.guild.id}`, { sort: '.data'})
let content = "";
for (let i = 0; i < money.length; i++) {
let user = bot.users.get(money[i].ID.split('_')[2]).username
content += `${i+1}. ${user} ~ ${money[i].data}\n`
}
help ? db.startsWith is not a function
startsWith is a function for strings
counts backwards
not a database
if (message.content === "=work") {
let timeoutworked = 3600000
let worked = await db.fetch(`worked_${message.author.id}`);
if (worked !== null && worked - (Date.now() - worked) > 0) {
let time = ms(timeoutworked - (Date.now() - worked));
message.channel.send(`You already worked, you can come back and work in **${time.hours}h ${time.minutes}m ${time.seconds}s**!`)
} else {
let amountearned = Math.floor(Math.random() * 500) + 1
let jobs = ["Scientist", "Developer", "Streamer", "Youtuber", "Cashier", "Shopkeeper", "Investor", "Engineer", "Biologist", "Astronomer"]
let jobworked = jobs[Math.floor(Math.random()*jobs.length)]
let embed = new Discord.MessageEmbed()
.setAuthor(`${message.author.tag}, it payed off!`, message.author.displayAvatarURL())
.setDescription(`${message.author}, You worked as a ${jobworked} and earnt ${amount} coins`)
message.channel.send(embed)
db.add(`money_${message.author.id}`, amountearned)
db.set(`worked_${message.author.id}`, Date.now())
}
}```
Anyone know how I can enter certain variables in a json for example:
let json = file.ITEM but the item is a variable?
if (1748409 > 3600000) {
console.log('need refreshed')
} else {
console.log('doesnt')
}```
it puts negative
how can I get urls from a string in node.js as an array
what
I tried using a node module which did that but it doesn't really work
I mean something like
"string".match(/(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?/)``` i think
nice spoon-feed
"this is a string https://example.com"
googling regexp isnt really spoonfeeding 😛
@neat ingot And what else should i do? i tried 20 different ways and nothing :/
I don't understand regexp anyways
Time to learn it
regexp is the best way to do it
simplified version https://stackoverflow.com/questions/33211233/how-to-detect-and-get-url-on-string-javascript
you don't need all of it
with some regex magic you can apparently get it all by detecting http(s)
damn you regex for not being readable
idk what your trying to do sabin, but you need to get the data from your database before you can check if an element from it startsWith()
my bot does not start, neither on the vps nor on the pc know what it can be?
do you have an error
regexp: /(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$])/igm
Regex101 allows you to create, debug, test and have your expressions explained for PHP, PCRE, Python, Golang and JavaScript. The website also features a community where you can share useful expressions.
my bot was on yesterday, so I'm off now I can't connect it anymore, I've tried to use shards and nothing.
it just stays like this.
never starts
no go away
well do you have it log anything?
@earnest phoenix Please don't post any invites or OAuth links
not
the only thing i can think of is that your bot is stuck in some kinda infinite loop before it tries to connect, do you log normally anything to console on ready event?
like, 'connected' or some crap
if not, try logging something on the ready event to see if its ever connecting to discord
got it sorted out
@neat ingot
I tried to connect it on a base with nothing, and di a console.log on ready and nothing.
How can I define random ?
Math.random() * yourdesirednumber
floor
^
round would be better
ok
since otherwise the upper limit would never be reached
Math.floor(Math.random() * number);
Math.round(Math.random() * number);```
@lyric mountain Can you come in dms please?
subject?
sounds suspicious
idk then carter, sry 😦
i would check my token to make sure its valid, i've had issues with my token becoming invalid due to a lot of reboots in quick succession
@lyric mountain i have trouble with a code, and i think i can learn easier if we were just us
I'm not a JS dev, there's only a few things I can help you with
I have trouble with that random thing, i'm trying to make a roulette command
how
just get a random index using this #development message
let vip = await db.fetch(`bronze_${user.id}`)
if(vip === true) random = Math.floor(Math.random() * 200) + 1;
if (vip === null) random = Math.floor(Math.random() * 100) + 1;
let embed = new Discord.RichEmbed()
.setDescription(`✅ You robbed ${user} and got away with ${random} coins`)
.setColor("#FFFFFF")
message.channel.send(embed)
db.subtract(`money_${message.guild.id}_${user.id}`, random)
db.add(`money_${message.guild.id}_${user.id}`, random)
db.set(`rob_${message.guild.id}_${user.id}`, Date.now())
isn't this correct?
try it and find out 🙂
side note: i'd do this to get the max value:
const vip = await db.fetch(`bronze_${user.id}`);
const random = Math.floor(Math.random() * (vip ? 200 : 100)) + 1;
@neat ingot Ok, ty
db.subtract(`money_${message.guild.id}_${user.id}`, random)
db.add(`money_${message.guild.id}_${user.id}`, random)``` is concerning tho
its sub/add to the same user. idk if thats desired
but like, its just going to end up the same amount
help?
guild is undefined
i mean 1000 - 100 + 100 is 1000, you know?
also, you need to pass a function for .find
find can be used like that im sure, but is depreciated.
👌
equivalent function would be e => e.name === 'welcome'
so, find(e => e.name === 'welcome')
how does member.guild make sense to you
it should work
@neat ingot yes, it's deprecated
how can i do it for id?
how does member.guild make sense to you, again
member.guild makes sense tho
Is 3d in C# 3 represented in double datatype?
how did you define member?
yeah and
i dont know the defines
🤦♂️
what is it
wdym
ok snails you do this
I'm on classes rn
i dont know the defines
couldnt have, or guild woulldnt be defined
no fuxk you I'm done
I only came here to read
oh, nvm then... lol
i need const user =
my brain is about to explode
can someone tell me pls
what's the ?
you can get the user from the message object
assuming you have access to that
lmao
you can't be serious
lmao
Hi so I'm getting the error that it can't read sell_summary of undefined any idea why? Am I doing something wrong?
data.products[miniontype].sell_summary[0].pricePerUnit (This is an API btw)
omg
Good grief
goodness gracious
😂
hi, so I'm having issues where iframe are getting blocked, I'm using nginx
@high geode that means you're literally doing "".guild
ik
this is like yesterday
yeah
Hi so I'm getting the error that it can't read sell_summary of undefined any idea why? Am I doing something wrong?
data.products[miniontype].sell_summary[0].pricePerUnit (This is an API btw)+
No need to repeat yourself so soon




