#development
1 messages · Page 569 of 1
just post it here
unless it has sensitive content
that is the current working code?
yea
or the one with the build error
Why don’t you separe the css in another file?
Understandable xD
try this js <%if(user.id === bot.config.ownerID) {%> <a class="dropdown-item" href="/admin"><i class="far fa-user-secret"></i> Admin</a> <%}%>
yes
Are you making a dashboard?
ejs is weird af
ye
require your bot config file somewhere
I am liking ejs. But I dont know if my dashboard is "good" or "nice looking"
can I post links here?
Hopefully I dont get in trouble. https://redqueenbot.xyz
What is ejs?
Oh
looks good @dusky steeple
const
@dusky steeple isnt that the idiots guide dashboard
It is
@earnest phoenix are you using a render function? like .render("yourfile.ejs")
yes but I have modified it extremely
you can pass it through there
like .render("yourfile.ejs",{config:yourbotconfig})
in your dashboard you do require(botconfig)
rigfht
hmm
how are you defining config?
const config = require("../config.json")
is your config file in the folder before?
hmm
idk how glitch works, but its possible that if the file is being run from the base folder, not from the web folder, then the require will follow the base path as well
try doing require("./config.json")
just to see if it works
ah rip
then idk, the previous one should be working, but if its coming up empty in the console, then something is wrong
the config file itself is not empty, is it?
try console.log(config.ownerID), right after the require line
k
!p xdr begallasi lula lula
😢
switched to python yet having trouble with pip installing discord.py

using pycharm
What's your problem?
anyone know why this
levels: config.levels,
format: winston.format.combine(
winston.format.timestamp({
format: 'dddd, mmmm dS, yyyy, h:MM:ss TT'
}),
winston.format.colorize(),
winston.format.simple()
),
outputs like this
Shard: Launching 0 Shards [1 of 1] {"timestamp":"Thursday, 3333 43, yyyy, 7:02:32 TT"}
full month and full year should be all capital Ms and Ys
this is what I was going for: Saturday, June 9th, 2007, 5:46:21 PM
so the problem is it's saying that pip (python installer program) is not a available command for pycharm
linux or windows?
pycharm's installed on my mac :/
doing sudo easy_install pip from the terminal doesnt work?
enter your mac's password
oh
duh
oml now this problem is showing up
is your account not an admin?
you need an admin account
well then
anyone have a quickdb leaderboard command I can borrow
Did Tehi make the raid
Lmao
@sick cloud I am its not working
then make it yourself
you can do anything your mind can think up
AHHHHHH
first you have to actually create the leaderboard
So, I'm making a command to take every letter and place |||| after it. How would I do that?
or just split then join
Oh yeah
I have:
let msg = args.slice(0).join("||||")
message.channel.send("||" + msg + "||")
But that only splits each word... I don't know how to split each letter
agrs = message.content.split(" ") (messages split on spaces)
just create another variable which equals message.content.split("") (messages split on nothing, ie all characters)
Oh, thanks! 👍
Woohoo, got it working!
if (command === "spoiler") {
let msg1 = message.content.slice(9).split("")
let msg = msg1.slice(0).join("||||")
message.channel.send("||" + msg + "||")
}
Can someone help me setup a hosting thing on OpenShift?
OpenShift is an open source container application platform by Red Hat based on top of Docker containers and the Kubernetes container cluster manager for enterprise app development and deployment.
hey
so I got the top five of my leaderboard
let leaderboard = await db.startsWith('userBalance', { sort: true });
for (let i = 0; i < 5; i++) {
console.log(leaderboard[i]);
}
and it returns { ID: 'userBalance_235542521894273024', data: 3500 }
{ ID: 'userBalance_268767449288146944', data: 2000 }
{ ID: 'userBalance_439802941906485258', data: 1596 }
{ ID: 'userBalance_345349646253817857', data: 1514 }
{ ID: 'userBalance_282876816736124930', data: 1216 }
but I only want the ID and data
how would I do that?
also if you could, find the id of the person
learn about arrays
fine ill do type of
oh ok thanks
id or data
ok\
Hey can someone help me
it doesnt apply here
oof
we are here to serve you
im using discord.js 11.4.2 and i dont understand awaitMessages
use message collectors then
what are those?
And some examples here: https://stackoverflow.com/questions/45856446/discord-js-reply-to-message-then-wait-for-reply
Does anyone know an API where I can get random lick gifs?
google is just going to put a captcha once you hit unhuman rates, it's more than enough to scrape images
.
Anyone know why my bot OAuth link would be taking people to the wrong redirect uri?
the wrong one, and the one i want it to be, are both added in my application as approved urls, and in the full oauth URL im using, the one i want it to be is definitely the one specified as the redirect URI, but it still takes me to the old one
if(!data[0]) {
await bot.db.insert({doc}, (err, data) => {
if (err) console.error(err)
})
}
if(data) {
curxp = data.xp;
curlvl = data.lvl
}
})
console.log(curxp + "\n" + curlvl)``` it logs undefined for curxp and curlvl?
joinedAt is a property of guild member
so it only works if target is a member, not a user
and it should be target.joinedAt
hmm ok lemme try it
message.mentions.users is a user. you can try message.mentions.members instead, to get a member object
and message.author is also a user, instead use message.member
when i try this i get the stats of my own even this user id is from a user of the server
try hardcoding the id to test it
can you show all the code again? with the hardcoded id
thats not what i meant with hardcoded id
doing that basically does this: "8707050598305".id which is undefined
oh...
i meant put the id in the members.get()
id is an string
bruh
bruh
yea works then
yea i get a undefined
undefined from args or args[1]?
ah ok
👍
i need to look that up
var is old and was the only option for a long time
ok
let and const are new, and have new use cases
and let for variables you are going to re asign
ah ok
let and const are considered "safer" because they throw an error if you accidentally try to re-declare/replace an existing one
when var just does it and possibly screws up your code
ok so i can change all var to let?
the difference between let and const, is that the value of const cannot be changed
ugh winston is starting to really make me mad
why use it then :^)
cause I want to learn it lol
xD
I know I have something set up wrong but haven't figured out what yet
winston 
it works for 1 file correctly but wont for another
this one works fine 1logger.log('Shard', Launching ${shard.id} Shards [${shard.id + 1} of ${Manager.totalShards}]);but this one don't lollogger.log('Log', Loading a total of ${client.commandsNumber} commands.);`
er
How many servers is your bot in
You dont need to shard before 2k
just preparing for future
everyone tell me not to add it yet
im like 🖕 I am adding now so I don't have to later
Yeah that’s understandable
Paired with the matrix.js library
dual channel memory
It eill be epic
this works
logger.log('Shard', `Launching ${shard.id} Shards [${shard.id + 1} of ${Manager.totalShards}]`);```
and outputs
`Shard: Launching 0 Shards [1 of 1]`
but this
```javascript
logger.log('Log', `Loading a total of ${client.commandsNumber} commands.`);```
outputs nothing at all 🤔
samething outputs nothing
what if you put "Shard" instead of "Log"
then check if winston has specific settings tha need to be configured for each log type
all the other ones I have working fine. Just something with Log
wait you can only have 5 levels in winston right?
as for ID of user to know his username?
@dusky steeple levels are prioritized from 0 to 7 (highest to lowest).
@daring trellis you want to get a username from an id? which library are you using, discord.js?
@quartz kindle yes discord.js
@daring trellis client.users.get(id).username
thanks
Got a python question
Let's say I have an async tcp client listening for messages from a server, but at the same time I want to be able to get input from the console. How can this be achieved?
So far what I could only manage is get the client to continuously wait for tcp messages and take action accordingly
with a flux compasitor installed 😛 🤔
i dont know python either, but if your tcp listener is async, you should be able to setup another listener on the console
and process both events as they arrive
I have no idea how to do that in python
In C# it was as easy as not awaiting an async method
In python however, idk how to fire an async function without awaiting it
check this https://github.com/vxgmichel/aioconsole
Ok I can not figure this all. I can use all the levels except 7. Anyone see what I am doing wrong?
const winston = require('winston');
// Logging Levels
const config = {
levels: {
Error: 0,
Debug: 1,
Warn: 2,
Data: 3,
Info: 4,
Shard: 5,
Dash: 6,
Cmmds: 7
},
colors: {
Error: 'red',
Debug: 'blue',
Warn: 'yellow',
Data: 'grey',
Info: 'green',
Shard: 'magenta',
Dash: 'yellow',
Cmmds: 'cyan'
}
};
winston.addColors(config.colors);
const logger = module.exports = winston.createLogger({
levels: config.levels,
format: winston.format.combine(
winston.format.colorize(),
winston.format.simple()
),
transports: [
new winston.transports.Console()
],
level: 'Dash'
});
i dont see anything wrong there, except for why do you have module.exports in the middle there?
idk
I didn't really grasp the concept of "event loops" yet so I think that's where my issue is
i saw it in the tutorial I was watching
i mean, it works, but thats kinda redundant
it's not needed I take it?
because you assign the function to logger and at the same time you export it
meaning you can use the function in both the main file and the module file
but the function is already exported, so the module file doesnt really do anything else anymore
I take it out though it errors and bot don't start
logger.log is not a function 🤔
so do it like this? module.exports = winston.createLogger({
yes
ok
this is a normal module file
no worries glad you noticed it 😄
@quartz kindle clarification, How to find out the user ID which is not in the bot?
about the level 7 thing, i dont know. the configuration looks fine. how are you trying to use it?
logger.log('Cmmds', `${message.guild.name}/#${message.channel.name} (${message.channel.id}):${message.author.username} (${message.author.id}) ran command ${message.content}`);```
@daring trellis if you're using version 11 (stable), you can try client.fetchUser(id)
If I change Cmmds to any other one of the levels it works fine
@dusky steeple level - Log only if info.level less than or equal to this level
you have js level: 'Dash'
set it to the highest
so set it to Error?
oh duh lol
@quartz kindle
Worked perfect now 😄 ty
@daring trellis also, fetchuser is a promise
so either await fetchuser or fetchuser().then()
iam back with a lil problem :))
add a ; to that closing bracket for con.query. Not sure if that is actually right or not.
ewwwwwwwwwwwwwwwwww 😐 🔫
why not use something like visual studio code?
sublime
Webstorm is good if you want a paid ide
there is a bunch of them 😄
for me the theme i use depends on the environment im in
if im sitting in my dark room, i want a matching dark theme that doesnt burn my eyes out
if im sitting in a public, well lit place, give me that white theme yo, dark is unreadable
i like sublimes theme
I use dark for everything lol
not too dark not too light
monokai? yeah its great
yup
yoyo its me, i try to programm that every 10levels the needed xp increases by 100xp and i dont really know how i could implement zhis :/
i could make a new collumn in db and make a counter to 10 but i think this is kinda weak
(and reset it ever to 0 when its 10)
I always wanted to know how to increase the xp per level
ez
reqxp = default + (currlvl+1) % 10 * 100
something like that
no idea if thats actually correct
% = modulo?
do you want to increase xp on every 5 levels?
10
% is modulo iirc
again i didnt test shit, i just wrote down an idea
or the shorter version (!level%10)
Note to self. Dont make a crappy logger so you have to redo it. 🤔
too high iq
Could you please explain why its not allowed to have a multibot (one bot consisting of multiple bots) for multiple voice connection per server? i dont understand. Is it ok when i put the links only inside the bot, not on the discordbots.org page?
bruh i wasnt asking for permission
why do you need to do 2 bots for 1 thing?
kind of stupid if you ask me
1 bot can do what you need
can 1 bot handle 2 voice connections in a single server at the same time?
why couldnt it
why would you need it to
does rythm need you to add a different bot for every server? hell no it doesnt
I dont think people would invite 2 bots that did the same thing anyways
bcuz he want's multiple people to use the bot
or something
make it reconize 1 channel when active and if someone else joins another and tries to use bot send a message sayin it's in use in another channel
why would you need single server for multiple connections??
because two people in the same server might want to use or trigger the bot at the same time
Most people have 1 music channel... Or none
^^
does any bot actually do that? no. then why would you want it yo
they will in fact when switching channels, as it can announce leaving and joining channels
Im just saying I wouldnt invite 2 bots that did the same thing
I forsee the bot constantly crashing and using unneeded resources for something like that
i mean
Seems like earrape to me
that bot
thats in second place in votes
mudae or something
they have multi bots
you invite mudae, and then you invite mudamaid to get higher usage limits
man mudae from dbl xd
Thank you very much Tim, once again. Actually i accepted that it is forbidden, and was asking why it is that way...
Now i'm confused.
who said it was forbidden?
an mod
well which one
eh
Xignotic
@coral trellis could we have a clarification?
So what I assumed he was asking was that he wanted to switch invites between the current bot on the site to allow all of the bots to be added to servers
well i was asking both. Nr 1 and if yes Nr 2
so it should be fine if there is one main bot on the website, and the other bots can be invited with just a link, without being in the website
or perhaps you can have it in the description
okey nice. This still counts if all bots are "equal", working independently without any other bot, and the serverstats are calculated by unique servers, not simply added up.
I am just asking because i think it would be nice to evenly distrbute the workload of the bots
you could do something like this
have 1 bot in the website
and in the description, list all bots, including the main one, and their current server usage
so a person can chose whoch one they want based on which one has less usage for example
just, the bot in the website will always gain more servers. Nr 2,3,4.. will have decreasingly less
if they read the descrioption that is
But i think im gonna ask that again when i actually need it 😃
[insert description tlaking about why your bot is split into multiple bots]
bot 1 (total servers) - invite link
bot 2 (total servers) - invite link
bot 3 (total servers) - invite link```
you could design it into something similar to chosing an MMORPG server
lmao
join server "huehuehe" (20k users online)
later on you could just make a website for it
yeah thats exactly how i did it in my awaiting-approval-state bot today. Just was not sure if that okey
Thnaks again very much tim
And i have another theoretical question.
If you log into the same bot from two different servers, will discord(js) automatically loadbalance all guilds between all shards of both logins/servers?
If yes: with the shards broadcast functions you can communicate between shards. Can you then communicate only server-intern or accross all shards of both servers at once?
discord assigns guilds to shards
you can't control that
and afaik broadcastEval only works on shards under the same master
^yeah, if you want to split shards into multiple machines, pretty sure broadcast eval will not work
you would need to create an internal api or something
i did it with ipc that supports http connections. this way i should have the same as broadcastEval, just cross-bot and cross-server at once.
but sad it doesnt work with intern methods
internal methods only work locally, the only way is to exchange commands and replicate the method remotely
Hello, I'm getting this error while trying to host on Heroku!
Running npm install node-js on ⬢ waffle-bot-host... up, run.7761 (Free)
npm WARN discord.js@11.1.0 requires a peer of bufferutil@^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.1.0 requires a peer of erlpack@hammerandchisel/erlpack but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.1.0 requires a peer of node-opus@^0.2.5 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.1.0 requires a peer of opusscript@^0.0.3 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.1.0 requires a peer of sodium@^2.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.1.0 requires a peer of libsodium-wrappers@^0.5.1 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.1.0 requires a peer of uws@^0.14.1 but none is installed. You must install peer dependencies yourself.
npm WARN waffle-bot@0.0.1 No license field.```
The reposit is here, if you want to see it. https://github.com/Sublands/WaffleBot
Please tag me, when responding!
thats not an error
its just warnings, they are normal and can be safely ignored
@raven bronze
@quartz kindle One problem, the bot doesn't run and returns.
Error: Cannot find module 'discord.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/app/bot.js:1:79)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)```
Please tag me, when responding!
@raven bronze discord.js is not installed properly
@quartz kindle How can I fix this. 
run npm i discord.js
@quartz kindle
Running npm i discord.js on ⬢ waffle-bot-host... up, run.9547 (Free)
npm WARN deprecated snekfetch@3.6.4: use node-fetch instead
npm WARN discord-rpc@3.0.1 requires a peer of register-scheme@github:devsnek/node-register-scheme but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.4.2 requires a peer of bufferutil@^3.0.3 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.4.2 requires a peer of erlpack@discordapp/erlpack but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.4.2 requires a peer of node-opus@^0.2.7 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.4.2 requires a peer of opusscript@^0.0.6 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.4.2 requires a peer of sodium@^2.0.3 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.4.2 requires a peer of libsodium-wrappers@^0.7.3 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.4.2 requires a peer of uws@^9.14.0 but none is installed. You must install peer dependencies yourself.
+ discord.js@11.4.2
added 7 packages from 6 contributors in 1.965s```
@quartz kindle
2019-02-08T14:51:41.830687+00:00 heroku[worker.1]: State changed from crashed to starting
2019-02-08T14:51:44.642007+00:00 heroku[worker.1]: Starting process with command `node bot.js`
2019-02-08T14:51:45.419755+00:00 heroku[worker.1]: State changed from starting to up
2019-02-08T14:51:47.544081+00:00 heroku[worker.1]: State changed from up to crashed
2019-02-08T14:51:47.526569+00:00 heroku[worker.1]: Process exited with status 1
2019-02-08T14:51:47.445961+00:00 app[worker.1]: internal/modules/cjs/loader.js:583
2019-02-08T14:51:47.445980+00:00 app[worker.1]: throw err;
2019-02-08T14:51:47.445982+00:00 app[worker.1]: ^
2019-02-08T14:51:47.445983+00:00 app[worker.1]:
2019-02-08T14:51:47.445985+00:00 app[worker.1]: Error: Cannot find module 'discord.js'
2019-02-08T14:51:47.445987+00:00 app[worker.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
2019-02-08T14:51:47.445989+00:00 app[worker.1]: at Function.Module._load (internal/modules/cjs/loader.js:507:25)
2019-02-08T14:51:47.445990+00:00 app[worker.1]: at Module.require (internal/modules/cjs/loader.js:637:17)
2019-02-08T14:51:47.445992+00:00 app[worker.1]: at require (internal/modules/cjs/helpers.js:22:18)
2019-02-08T14:51:47.445993+00:00 app[worker.1]: at Object.<anonymous> (/app/bot.js:1:79)
2019-02-08T14:51:47.445995+00:00 app[worker.1]: at Module._compile (internal/modules/cjs/loader.js:689:30)
2019-02-08T14:51:47.445996+00:00 app[worker.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
2019-02-08T14:51:47.445998+00:00 app[worker.1]: at Module.load (internal/modules/cjs/loader.js:599:32)
2019-02-08T14:51:47.446000+00:00 app[worker.1]: at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
2019-02-08T14:51:47.446001+00:00 app[worker.1]: at Function.Module._load (internal/modules/cjs/loader.js:530:3)```
can you show the contents of bot.js?
need to call discord.js into the file?
@quartz kindle | @dusky steeple https://github.com/Sublands/WaffleBot/blob/master/bot.js
looks fine, i guess its heroku being stupid
you can try adding discord.js to your package.json and see if heroku installs it automatically
I should prob know this, but do I do that (again)
"dependencies": {
"discord-rich-presence": "^0.0.8",
"easy-rich-presence": "^1.3.2",
"random": "^2.0.13",
"discord.js":"^11.4.2"
}```
in your package.json file
lol
i mean
add the discord.js line
to the dependencies
not create and entire new depencencies section
XD oh my oof
@_@
@quartz kindle ❤ Thank you so much, XD
2019-02-08T15:00:00.456579+00:00 app[worker.1]: Waffles are good!```
xP
ERROR Unhandled rejection: Error: Cannot find module './data/client_secret.json'
I keep getting this error, but the file is there
if(!data[0]) {
await bot.db.insert({doc}, (err, data) => {
if (err) console.error(err)
})
}
if(data) {
curxp = data.xp;
curlvl = data.lvl
console.log(curxp + "\n" + curlvl)
}
})``` every time i send a message it just adds a new line to the db with exactly the same information? (nedb) also when it console logs curxp and curlvl, its just undefined
i answered this before
data is an array, right?
if there is no data, data[0] is undefined, but data is an empty array, which the if interprets as true (because it exists)
so instead of if data i use if data[0]?
but here's an example of it written ```{"doc":{"userid":"312617227490951168","serverid":"539058992136323082","xp":0,"level":1},"_id":"FYwDA7d0rmZH3Qm1"}
{"doc":{"userid":"312617227490951168","serverid":"539058992136323082","xp":0,"level":1},"_id":"fFH7N8IQ8OKIuZm3"}
yeah i just tried that
its just written to the db again
every message just writes the same thing...
show the code again, after you changed it to else
await bot.db.find({userid: message.author.id, serverid: message.guild.id}, async (err, data) => {
if(!data[0]) {
await bot.db.insert({doc}, (err, data) => {
if (err) console.error(err)
})
} else {
curxp = data.xp;
curlvl = data.lvl
console.log(curxp + "\n" + curlvl)
}
})```
rn xp.db is just this: ```{"doc":{"userid":"312617227490951168","serverid":"539058992136323082","xp":0,"level":1},"_id":"FYwDA7d0rmZH3Qm1"}
{"doc":{"userid":"312617227490951168","serverid":"539058992136323082","xp":0,"level":1},"_id":"fFH7N8IQ8OKIuZm3"}
{"doc":{"userid":"312617227490951168","serverid":"539058992136323082","xp":0,"level":1},"_id":"yGqBlnd6jDR9fw7y"}
so the find function is not finding anything
o
lets see
{ userid: '312617227490951168',
serverid: '539058992136323082',
xp: 0,
level: 1 },
_id: 'RVZmDPBGrJELe52z' } ]
undefined
undefined``` comes from ``` await bot.db.find({doc}, async (err, data) => {
console.log(data)
if(!data[0]) {
await bot.db.insert({doc}, (err, data) => {
if (err) console.error(err)
})
} else {
curxp = data.xp;
curlvl = data.lvl
console.log(curxp + "\n" + curlvl)
}
})```
so data is an array containing doc
so the else block should be curxp = data[0].doc.xp
ok
finally![ { doc: { userid: '312617227490951168', serverid: '539058992136323082', xp: 0, level: 1 }, _id: 'RVZmDPBGrJELe52z' } ] 0 1
ty ❤
👍
ah just found smth interesting...
as soon as level is 2, this happens... ```{"doc":{"userid":"312617227490951168","serverid":"539058992136323082","xp":0,"level":2},"_id":"RVZmDPBGrJELe52z"}
{"doc":{"userid":"312617227490951168","serverid":"539058992136323082","xp":0,"level":1},"_id":"zZGhivwRfoNesEZA"}
it writes another one with level 1
btw this is my schemas.js const make_xp_doc = function (options = {}) { return { userid: options.userid, serverid: options.serverid, xp: options.xp || 0, level: options.xp || 1 } } module.exports = { make_xp_doc: make_xp_doc } (its how i get doc)
it seems it's just writing another one with level 2 instead of overwritting
no, i changed it to level 2, for testing smth
that would be because you use the entire doc to find, instead of only userid and serverid
ah
that's my guess at least
if(!data[0]) {
await bot.db.insert({doc}, (err, data) => {
if (err) console.error(err)
})
} else {
curxp = data[0].doc.xp;
curlvl = data[0].doc.level;
console.log(curxp + "\n" + curlvl)
let nextlvl = curlvl*(curlvl+1)/2*300;
console.log(nextlvl)
}``` if i don't use doc to find it, we're back to the issue of it writing the same thing again and again @heady zinc
as i said
feeding
you'll need to do js await bot.db.find({ "doc.userid": message.author.id, "doc.serverid": message.guild.id }, async (err, data => { //your stuff });
oh
that is documented here https://www.npmjs.com/package/nedb#basic-querying
that works om ty
might help if you showed the code 😉
I'm wroking on it.
Its python btw. idk what ur using.
Anyone have any Ideas on how to have your bot stop crashing from missing permissions?
I can't seem to stop it from happening.
try catch blocks
@jaunty stump depends on what language your using m8.
.js
Aka javascript
yea
The fix is an easy one, first check if your bot has permissions to do the action you want to do :)
That is the problem x3
people invite the bot, mess with the perms, the bot will ditect that it needs to do something but it can't because of missing perms and it crashes
if(!data[0]) {
await bot.db.insert({doc}, (err, data) => {
if (err) console.error(err)
})
} else {
let xpadd = Math.floor(Math.random() * 15) + 11
curxp = data[0].doc.xp;
curlvl = data[0].doc.level;
let nextlvl = curlvl*(curlvl+1)/2*300;
let newxp = curxp + xpadd
await bot.db.update({ "doc.userid": message.author.id, "doc.serverid": message.guild.id}, { $set: { "doc.xp": newxp}}, {}, function(){})
console.log(curxp + "\n" + curlvl)
console.log(nextlvl)
}
})```
>
```{"doc":{"userid":"312617227490951168","serverid":"539058992136323082","xp":0,"level":1},"_id":"94jjqPipk5cv96jY"}
{"doc":{"userid":"312617227490951168","serverid":"539058992136323082","xp":17,"level":1},"_id":"94jjqPipk5cv96jY"}
{"doc":{"userid":"312617227490951168","serverid":"539058992136323082","xp":41,"level":1},"_id":"94jjqPipk5cv96jY"}
{"doc":{"userid":"312617227490951168","serverid":"539058992136323082","xp":63,"level":1},"_id":"94jjqPipk5cv96jY"}
{"doc":{"userid":"312617227490951168","serverid":"539058992136323082","xp":79,"level":1},"_id":"94jjqPipk5cv96jY"}
my update is doing something wrong...
that basically helps with checking to see if a person in the server has the right perms in order to use my bot.
Paradox y'know what's wrong for me?
it is as simple as js if (!message.me.hasPermission(['banMembers']) { dont(); }
actually don't quote me on that, me isn't a thing anymore on v12 
@zinc pawn not really sure, does it insert a new one instead of updating?
yey it works
yes
^^
but with the new value.. @heady zinc
that really shouldn't happen at all, so i don't know sorry
are you sure this is right? ```await bot.db.update({ "doc.userid": message.author.id, "doc.serverid": message.guild.id}, { $set: { "doc.xp": newxp}}, {}, function(){})
Still crashing, It is an anti-spam/anti-raid bot, Like I said, I assume people are messing with the bots perms so it can't do its thing and it just gives me this.
it should be, it should update the matched document and it shouldn't ever insert if no document has been found unless the upsert option is true
djs v12 errors aren't really helpful are they
im guessing somewhere in your bot you don't check perms but if it doesn't tell you where...
It doesn't tell me where... it just crashes and gives me that. So I don't know where to put/add the permissions check
Best way to set up a db?
if(!data[0]) {
await bot.db.insert({doc}, (err, data) => {
if (err) console.error(err)
})
} else {
let xpadd = Math.floor(Math.random() * 15) + 11
curxp = data[0].doc.xp;
curlvl = data[0].doc.level;
let nextlvl = curlvl*(curlvl+1)/2*300;
let newxp = curxp + xpadd
await bot.db.update({ "doc.userid": message.author.id, "doc.serverid": message.guild.id}, { $set: { "doc.xp": newxp}}, { upsert: false }, function(){})
console.log(curxp + "\n" + curlvl)
console.log(nextlvl)
}
})``` even with upsert: false it still writes a new one... wtf...
@heady zinc just found out smth weird, when it restarts the previous lines disappear leaving only the most recent line?
what
so when i send the message this happens: ```{"doc":{"userid":"312617227490951168","serverid":"539058992136323082","xp":122,"level":1},"_id":"94jjqPipk5cv96jY"}
{"doc":{"userid":"312617227490951168","serverid":"539058992136323082","xp":141,"level":1},"_id":"94jjqPipk5cv96jY"}
but when i reboot it it gets rid of the old doc, leaving only the most recent
no, that's in the database
ok, what if you try to update by id
I am? await bot.db.update({ "doc.userid": message.author.id, "doc.serverid": message.guild.id}, { $set: { "doc.xp": newxp}}, { upsert: false }, function(){})
ohhhhhhhhh
ic
:)
so its not writing a new line, but its not actually updating either..
did you do doc._id or _id
oh that id, i thought you meant like this for some reason heh await bot.db.update({ userid: message.author.id, serverid: message.guild.id}, { $set: {xp: newxp}}, { upsert: false }, function(){})
i'll try doc._id 1 sec
?
"doc._id": data[0]._id
ah
so i have this now: ``` await bot.db.find({ "doc.userid": message.author.id, "doc.serverid": message.guild.id}, async (err, data) => {
if(!data[0]) {
await bot.db.insert({doc}, (err, data) => {
if (err) console.error(err)
})
} else {
let xpadd = Math.floor(Math.random() * 15) + 11
curxp = data[0].doc.xp;
curlvl = data[0].doc.level;
let nextlvl = curlvl*(curlvl+1)/2*300;
let newxp = curxp + xpadd
await bot.db.update({"doc._id": data[0].id}, { $set: { "doc.xp": newxp}}, { upsert: false }, function(){})
console.log(curxp + "\n" + curlvl)
console.log(nextlvl)
}
})``` but it still isn't updating
stored like this btw: {"doc":{"userid":"312617227490951168","serverid":"539058992136323082","xp":141,"level":1},"_id":"94jjqPipk5cv96jY"}
ok
and it's data[0]._id not data[0].id
oh my bad lol
its back to doing this... {"doc":{"userid":"312617227490951168","serverid":"539058992136323082","xp":141,"level":1},"_id":"94jjqPipk5cv96jY"} {"doc":{"userid":"312617227490951168","serverid":"539058992136323082","xp":156,"level":1},"_id":"94jjqPipk5cv96jY"}
wait what now they have the same id?
ok but does bot.db.find({ "doc.userid": message.author.id, "doc.serverid": message.guild.id} returns both of them
\/
db:
Datastore {
inMemoryOnly: false,
autoload: true,
timestampData: false,
filename: './xp.db',
compareStrings: undefined,
persistence:
Persistence {
db: [Circular],
inMemoryOnly: false,
filename: './xp.db',
corruptAlertThreshold: 0.1,
afterSerialization: [Function],
beforeDeserialization: [Function] },
executor: Executor { buffer: [], ready: true, queue: [Object] },
indexes: { _id: [Index] },
ttlIndexes: {} },
query:
{ 'doc.userid': '312617227490951168',
'doc.serverid': '539058992136323082' },
execFn: [Function],
_projection: {} }```
@heady zinc?
oh 1 sec
no just this: [ { doc: { userid: '312617227490951168', serverid: '539058992136323082', xp: 181, level: 1 }, _id: '94jjqPipk5cv96jY' } ] 181 1 300
does that mean its a visual glitch?
idk, what matters is that it doesn't seem to actually duplicate
so your bot should run smoothly
that's a relief then, thanks.
owners_id.includes(user.id)
why wont this work
for multiple ids
<%if(user.id === config.owners_id.includes(user.id)) {%>
config.owners_id.includes(user.id) will return a boolean
Whereas user.id will not
so how could i resolve
Don't compare anything?
<%if(user.id === config.owners_id.includes(owners_.id)) {%>
so just
<%if(user.id === config.owners_id) {%>
Now you are comparing an integer to what I assume is an array
yeA>?
And that won't work
To be correct, it will be false. And no
You don't need to compare anything
You want to check if user.id is in config.owners_id array, right?
@slender thistle <% is ejs afaik
"owners_id": [
"friend id",
"my id"
]
Is ejs different from js? 
very
ejs is just a weird php
^
Well, I doubt this case is affected by that
but shivaco is right
hm
@earnest phoenix config.owners_id.includes(user.id) this returns a boolean. a boolean means the value is either true or false. doing what you're doing is the same as doing if(user.id === true)
you dont, includes checks it for you
you dont need to compare anything
when you do config.owners_id.includes(user.id), the includes function does the compare internally
and returns true if one of the compares worked, or false if none of them worked
so you just need to feed it directly to the if
ok
he was supposed to figure it out lol, but yeah, thats all you had to do
?
for my website
.. k lol
Why does this make a Syntaxerror? css let warns = JSON.parse(fs.readFileSync("./warnings.json", "utf8"));
let warns = JSON.parse(fs.readFileSync("./warnings.json"), ("utf8"));
maybe like that idk
@rocky dagger
let warns = JSON.parse(fs.readFileSync("./warnings.json"), ("utf8"));
the file is empty
and its "utf-8" not utf8
It can be utf8
let warns = JSON.parse(fs.readFileSync("./warnings.json", "utf8")); is valid js
They use utf8 in the fs docs
It needs atleast a {} to be valid iirc
yea I got that now
Working then?
:+1:
what is a good like phpmyadmin for linux desktop use?
I want something so I don't have to install phpmyadmin on my vps and use on my desktop to see and create databases.
There are many tools that you can download for that on PC and on mobile.
im on linux
It is important to learn how to do it programmatically though
https://goo.gl/M6bJty
software recommendation - MySQL GUI Tools - Ask Ubuntu
@harsh nova no need for them to change their entire db
They used json?
Oh my bad
😄
Check the link out I sent
I’m confused
Np 😃
why dosen't the bot remove the "muted" role after 10 seconds? can som1 help me?```css
if(warns[wUser.id].warns == 2){
let muterole = message.guild.roles.find(name, "muted");
if(!muterole) return message.reply("You should create a muted role. quick tip: do -tempmute @ranom guy 1s");
let mutetime = "10s";
await(wUser.addRole(muterole.id));
message.channel.send(`<@${wUser.id}> has been temporarily muted`);
setTimeout(function(){
wUser.removeRole(muterole.id)
message.reply(`<@${wUser.id}> has been unmuted.`)
}, ms(mutetime))
}```
you have the mutetime set to 10s?
let mutetime = "10s";```
I don't know if I am right or not as I am new. But by the looks of it you have it set to unmute after 10s
thats not how you use await
unless you have a function called await
but if you're trying to use async/await thats not how
async/await is await wUser.addRole(muterole.id);
it adds the role but doesn't remove it
@quartz kindle await(promise()) is valid
is it?
didnt know that lol
typeof as well? also didnt know lmao
the () just resolve to the inner expression
typeof(x) is similar to console.log((x))
are you gonna tell me let(x = 10) is also valid?
lmao
you can wrap expressions in ()
not random stuff
typeof/await apply to the expression directly after them
here is the whole code if you want https://github.com/Madmadz16/FirstBot
Can anyone help with my glitch project @quartz kindle can you fix it again lmao
Anyone know how to add a bot that you see on another server to your own server?
Which in my case
@ tim is offline
google the name of the bot
No results
write o.help
o.help doesn't present link
bot might be private then
Its not private
why dosen't the bot remove the "muted" role after 10 seconds? can som1 help me?```css
if(warns[wUser.id].warns == 2){
let muterole = message.guild.roles.find(name, "muted");
if(!muterole) return message.reply("You should create a muted role. quick tip: do -tempmute @ranom guy 1s");
let mutetime = "10s";
await(wUser.addRole(muterole.id));
message.channel.send(`<@${wUser.id}> has been temporarily muted`);
setTimeout(function(){
wUser.removeRole(muterole.id)
message.reply(`<@${wUser.id}> has been unmuted.`)
}, ms(mutetime))
}```
In a help embed, how could I make certain commands show to people who have certain permissions?
Like this:
@rocky dagger One I wouldn't put the mutetime in ""
Can anyone help with my glitch project
it looks at it as a string and not an int
So my bot you know the description can someone fix that as i broke mine?
it just don't show up
@earnest phoenix No one is going to do it for you but show code and we can try and help
I mean yes i dont want help i just need the code and need help with what i did wrong
lemme get a pic
i said im gonna show code
Whatever
what program is that?
okay
Not gonna read through a screenshot
i mean the application not nodejs
That is glitch @grim aspen
Mk what is the problem Arda?
they're having connection issues
It says playing doesn't it
oof you should really clean your code 😮
instead of Watching
Also the Presence if I remember correctly is like idle, dnd, online etc
You want setActivity
You can, but not the way he is doing
i've never seen an bot with an custom url
You'd want to put it in the message
I meant like
they would need to put it in their message
Oh idk
why dosen't the bot remove the "muted" role after 10 seconds? can som1 help me?```css
if(warns[wUser.id].warns == 2){
let muterole = message.guild.roles.find(name, "muted");
if(!muterole) return message.reply("You should create a muted role. quick tip: do -tempmute @ranom guy 1s");
let mutetime = "10s";
await(wUser.addRole(muterole.id));
message.channel.send(`<@${wUser.id}> has been temporarily muted`);
setTimeout(function(){
wUser.removeRole(muterole.id)
message.reply(`<@${wUser.id}> has been unmuted.`)
}, ms(mutetime))
}this doesn't even go offcss
message.channel.send(<@${wUser.id}> has been temporarily muted);```
@rocky dagger I already told you it should be let mutetime = 10
the bot will look at it as a string instead of an int
how do i run a code on glitch again?
not
@grim aspen https://anidiots.guide/other-guides/hosting-on-glitch if you really dare
Lol
ah
Glitch abuses Discord API i think
huh
That is what I was told
oh i forgot
who tf uses an second to ms converter
since there is a cap of ho many times a bot can login
Glitch doesn't abuse any API, it's just not designed for bot host
@lusty dew I tryed that
but it works
@keen drift Glitch auto saves everytime it atutosaves it logs into the bot and discord has a bot login cap of 1000 times or smth
autosaves*
That's more of your personal problem rather's than glitch's
It happened to me lol
Glitch even offers their own virtualized env
10 seconds = 1E4
How is that a personal problem?
just use that
Whateveer not gonna argue
Editing bot in production sounds like a personal problem
https://hastebin.com/uboqubapuf.js can someone help make it say Watching for -help Don't do it just help
I have offered help
Not sure what you are trying to bring up
There's plenty of throttling options for glitch
nah glitch is leaggly gae
Can you show an updated code
https://hastebin.com/uboqubapuf.js can someone help make it say Watching for -help Don't do it just help
if(warns[wUser.id].warns == 2){
let muterole = message.guild.roles.find(`name`, "muted");
if(!muterole) return message.reply("You should create a muted role. quick tip: do -tempmute @ranom guy 1s");
let mutetime = 10;
await wUser.addRole(muterole.id);
message.channel.send(`<@${wUser.id}> has been temporarily muted`);
setTimeout(function(){
wUser.removeRole(muterole.id)
message.reply(`<@${wUser.id}> has been unmuted.`)
}, ms(mutetime))
}```
Stop reposting
@earnest phoenix
@rocky dagger wtf is ms()
isn't ms an npm package
can you show declaration
or am I wrong?

This boi
@earnest phoenix bruh
Reposting isnt gonna get you help faster
@inner jewel Hey, control tis repost
^^^^^^^^^^^^^^
Run
This guy is getting on my nerves
Runnnnnn
I'm not gonna help him forget it
ikr
HELP ME THEN 😄
https://hastebin.com/uboqubapuf.js can someone help make it say Watching for -help Don't do it just help
😄 👋
stfu
Lmfao
I'd honestly stop resposting before yasmin comes
yeh i agree
Just advising you
🙄


