#development
1 messages ยท Page 1513 of 1
ยฏ_(ใ)_/ยฏ
and it crashed several times
my phone kept constantly saying "connecting"
thats fixed
update it
role names are dead thoguh
imma update discord again
for the i think 3rd time today
one of the updates they announced with the update as well
https://tinyurl.com/y47hj6uh
This message has been sent on andriod alpha.
Btw roles still dont load
At least user profiles do now
ima wait till everything works again lol
K
should i make a role unboxing bot or a ticket bot
android discord developers and competency really dont go hand in hand huh
Yeah, this makes the most sense
is there a way to get data from a FormData node js
const data = new FormData();
data.append('json_payload', JSON.stringify({ content: 'test' }))``` I want to be able to get json_payload from this
headers with boundaries
so is there any way for me to get the json_payload back?
probably
@quartz kindle do you know how I would go about doing this?
it just occurred to me
should i store images in a mongodb database?
(probably a bad idea i think)
there are pros and cons
like its easy and you can just export everything
but max is 16mb iirc and the bigger the db the slower requsts should be iirc
a few people are proficient
yeah just ask
for my image host, I store servers in like a subsystem server meaning I can kinda host files in any server that can run node
thats poggers
i would say contabo if their reviews weren't shit
so i recommend galaxygate @stuck pike
GalaxyGate Hosting
I use https://hostingbot.net/
go to their Discord Bot Hosting packages, starting from $1.75 to $4.00
I use ovh lowest tier is about 3usd
Any idea what cpu they use for those plans?
how many cores?
I would tell you but their website is a potato and is taking 30 seconds to load a page
lmao
Oh man the cpu on those plans are literally going for a few dollars on ebay.
the bot hosting plans are meant to be cheap so idk
1 vCore
Oh yeah, its not a bad deal for an extremely cheap hosting plan assuming its not oversold.
Just not for me as I need some cpu power.
i dont need much cpu power, so it's good enough for me
On discord.js how do you get the bot's uptime?
bot or process?
<Client>.uptime
bot
Okay thanks
np
I prefer process
Id suggest using the process up time if you dont have a specific reason for using bots uptime.
The bot might dc for a split second but not go down
? so how do i use process?
process.uptime() is in seconds?
I d k, lemme check
nope
what unit is it then? I got this lol
Looks like the number of seconds the bots been up 
So do i add math.floor to the code or just keep it like that cuz it's been seconds?
Its generally cleaner to round it down like that
yeah
Okay i will round it
okAy
Or converting it into minutes hours days weeks is better 
how can I get author from guild member
you mean user?
yeah jus to get displayavatar
isn't it literally GuildMember.user
true, searching that in the docs yourself would be faster than asking it here tbh, at least to me
let URL = user.displayAvatarURL({
dynamic: true,
size: 1024,
format: 'png'
}) || user.author.displayAvatarURL({
dynamic: true,
size: 1024,
format: 'png'
}), type = "png";
wait nvm
eNgLisH
hmm, ill go look at the docs for you.
thanks
message.mentions.first would give you undefined
so user is probably undefined
which im guessing what your error is?
so are you getting an error? or?
TypeError: user.displayAvatarURL is not a function
I asked how to
member.user
so in your case
user.user.displayAvatarURL()
since you named your member user
Ill change it to member to make it more clear thanks
??
let member = message.mentions.members.first() || message.guild.members.cache.get(args[0]) || message.guild.members.cache.find(c => c.displayName.toLowerCase() === args.join(" ").toLowerCase()) || message.member;
if (!member) {
return message.channel.send({ files: [message.author.displayAvatarURL({ dynamic: true })] });
} else return message.channel.send({ files: [member.user.displayAvatarURL({ dynamic: true })] });
Tried this havent read what you sent after the ??
got it
thank
With ytdl-core is there a way to skip to a certain part of the video?
did you check the readme for a seek method?
idk if there is
but I think that was it
as well as options for startat
idk its name
Hey, guys! I have a question for someone if you're up for it ๐ค
Regarding singleton / cache principles
I have this in my cache.js:
const Keyv = require('keyv');
const Cache = new Keyv();
Object.freeze(Cache);
module.exports = {
Cache
};
and this in my index.js:
const { ShardingManager } = require('discord.js');
const { Bot, TopGG } = require('./config');
const { App } = require('./server');
const manager = new ShardingManager('./bot.js', {
totalShards: 'auto',
token: Bot.token,
});
manager.on('shardCreate', (shard) => console.log(`Launched shard ${shard.id}`));
manager.spawn();
App.listen(TopGG.webHookPort);
Then this in my server.js:
const express = require('express');
const { User } = require('./classes/user');
const { TopGG } = require('./config');
const app = express();
const webhook = new Topgg.Webhook(TopGG.webHookAuth);
app.post('/dblwebhook', webhook.middleware(), (req) => {
const { vote } = req;
const user = new User(vote.user);
user.voted('tgg', vote.isWeekend);
});
module.exports = {
App: app,
};
What's weird is that when the Cache object is referenced from the user.voted() command in server.js, it's as if it creates a whole separate Cache object than the one that's reference from the discordjs module ๐ค
Even though, I thought cache.js froze the object?
In the same user.js file, I print out the Cache and it references two different objects (user.voted vs. user.getCoins ... which is supposed to reference the same require(./cache) ๐ค
why does this still return uvu hello
"uvu hello".slice(3)
I don't know what else is going on behind the scenes, but "uvu hello".slice(3) returns hello
Something else is going on there ๐ฌ
๐
Lol, no worries
@solemn latch -> I'm sssooo sorry for the ping. You mentioned to me earlier that you used some sort of protocol or something to communicate between your webhook server & discord bot?
ipc?
That was ti!
it just means interprocess communication. its not really a protocol, its just saying the two programs talk to each other,
How did you actually 'communicate' between the webhook server and your discord bot? I'm having a really oddball problem with my singleton Cache instance. For some reason, when running the discord bot + webhook from the same index.js ... it instantiates two Cache objects ... which is weird.
Legit, that's all I'm doing.
tim would spot the issue in 30 seconds
I'm starting to think it spawns two different processes ๐ค
Which uses two different versions of 'Cache' object.
I appreciate your response, Woo!
did you start all 3 files with the same process?
just a guess(not worked with object freeze before) but you are creating a separate cache object, so its not frozen, because its its own new object.
cache 1 is created
cache 1 is frozen
cache 2 is created
cache 2 is frozen
Technically, I have the index.js that calls the two files ๐ฌ
const { ShardingManager } = require('discord.js');
const { Bot, TopGG } = require('./config');
const { App } = require('./server');
const manager = new ShardingManager('./bot.js', {
totalShards: 2,
token: Bot.token,
});
manager.on('shardCreate', (shard) => console.log(`Launched shard ${shard.id}`));
manager.spawn();
App.listen(TopGG.webHookPort);
i think Woo is right. you call the cache file from 2 points
I think that's true as well; however, if that's the case, how do I just call it from one location and share it among all the files that consume it?
I require the Cache from multiple places.
if i get it right you want to share the cache between 2 processes?
Correct ๐
why not Redis? sure its not directly in memory but i guess managing it would be easyer
I may end up switching to redis.
I'm already using docker anyways ... would be easy to spawn two containers ... one with the discord bot ... one with redis
yea
i probably switch to K8 in the next months, finnaly everything running in containers
nice!
But, without Redis, is there a straight forward way to share the same Cache among two processes?
ยฏ_(ใ)_/ยฏ
ask Tim, i guess at this point they should create a Channel and name it Ask Tim.
poor tim
he signed up for this by being so good
how can I console.log() an invite to every guild my bot is in on startup?
why does this only allow me to use all commands not just ones in the owner category
the easiest way is to map all the guilds in the cache by their name @valid temple
let ownerCMDs = bot.categories.get('Owner');
if (!ownerCMDs.toString().includes(cmd) && message.author.id !== "485987127809671168") return message.channel.send("Owner only command!");
didnt we discuss this yesterday
tostring maybes the table a string
_ _
an array?
yea
use ownerCMDs.includes(cmd) then
without ! and toString()
why are you negating the value
?
that just made it "if command is non owner only and author isn't owner, return"
is there a way to disable everyone and here in !say command ?
either escape that or disable the mention I suppose
How to disable mentions ?
allowed mentions, idk what lib you're using, but rtfd ig.
djs
take a look at allowedMentions parameter, it takes MessageMentionOptions ig
oh there's also disableMentions
honestly everyone and here should be disabled by default.
how can i host my bot 24/7 ?
run the code and leave it alone
lol
@earnest phoenix i suggest you to use heroku
heroku isnt 24/7 after 550 hrs
allowedMentions: {parse: []} this property in message options works
to disable mentions
check the pins in this channel for VPS hosts
Um ok
how to fix (process:6572): Pango-WARNING **: 13:40:18.814: couldn't load font "Noto Serif SC Heavy Not-Rotated 30px", falling back to "Sans Heavy Not-Rotated 30px", expect ugly output.
install the font
What?
heroku doesnt offer free 24/7 you get 550 On Hours per month, if they are reached you go offline
^
already
Is there any free host that gets my bot online 24/7?
nope
Uh
But
What about if i usually update my bot rebooting it
There is still the hours limit?
Or that limit is for getting the bot 24/7 without any update?
the limit is till there
yes
no one will give you free hardware
well they give you free hardware there has to be a catch
I bought a hosting due to this
Crashed at the last moment of test
Thx to free hosting
Which is more efficient?
In which case should I use which method?
class A {
hello = 100;
/* OR */
get hello() {
return 100;
}
}
Use get when you want the value computed every time
Use the latter if you don't want to recompute it every time.
does using get, takes up memory?
For example, if I did A.hello on get hello() {...} 100 times, it would run {...} 100 times. If I use hello = 100, that single value is returned every time.
It's not really a memory question. It's a, "Do I want to compute this every time?" because there are cases where you may want to recompute a property.
So in this case, it is better to not use the getter. Right?
If you don't need recomputation, yes.
Can anyone give me a code for this? .js
I dont need any computation, but what is the downside of still using a getter?
so i'm trying to do a dashboard for my bot, and i never did that before. I figured out how to get the code from OAuth, i just have two questions:
-How exactly do i use the code to get the user's info?
-How to use cookies/cache for the user to stay logged in?
@rocky hearth The body of the hello property is recomputed every time you access .hello. To visualize this, see this: ```js
class A {
get hello() {
console.log("Hi!");
return 500;
}
}
let alphabet = new A()
for (let i = 0; i < 100; i++) {
alphabet.hello
} // Prints "Hi!" 100 times.Now, seejs
class A {
hello = 100;
}
let alphabet = new A()
for (let i = 0; i < 100; i++) {
alphabet.hello
} // Prints nothing because I didn't tell it to, but if it could, it would only print "Hi!" once -- when the class was initialized.The downside is you're using cpu/power to do something you don't need to do. There are cases where getters are useful. See this,js
class Rectangle {
constructor(width, height) {
this.width = width;
this.height = height;
}
get area() {
return this.width * this.height;
}
}```
area gets recomputated every time it's accessed. This is important because if width or height change, area will still return the correct area of the rectangle.
oh a bit long
I use express and EJS, yes
ok use express-session for handling cookies, and i can recomend looking into passport and passport-discord
Oh man, so much appreciated and thanks for your time. But I'm aware of using members and getters, and how they work.
I just wanted to know, are there any downsides of using a getter that just returns a literal.
The downside is very trivial, but pretty much the same: using cpu power to do something you don't need to do.
hmm thanks again!
so i tried with the passport-discord gh repo example, just to see how ti works, but whenever i go to the page to login i get a "Invalid OAuth redirect uri", any reason?
nvm figured out, i'm just being dum
ye
you can also pass the Intends you want to use with it directly in a easy way.
i use it to get the member object of the User and the Guilds of the user
Can I see who voted for my bot?
you want to add cooldowns to your commands?
i would recommend using Redis for such stuff, you can get a Free Database online. Redis is more or less designed to persistent store temporary data. You can set a TTL for each entry and if the TTL reaches 0 it fires an event you can listen to.
still would recommend redis. using a DB that is designed to store stuff persistant will get unnecessary read /writes with such stuff
you call the function to remove the cooldown inside an If statement i guess
and the delete time on finish i would set inside an event that is called when the bot starts -> starts a timeout for each cooldown stored in the database
also with your current way its possible that a guild get stuck in a infinite loop of repeating cooldowns
delete it
if you set it to 0 you still could set a timer since it exist
this is why i suggest redis, if you set a TTL you will have way less issues
if the TTL reaches 0 the data self destructs
and on each time the command is used just check if the Cooldown exist in Redis if yes return with an error if not execute command and then set a cooldown in redis
anyone can help with bal cmds that is working
ok
would still recomend redis, the way you do it rn uses more CPU power, this can cause issues if you scale larger.
I'm trying to send a get request using axios to my api which is currently running on the same machine, but every time I get "connection refused" and no requests logged on the api - what could I be doing wrong?
did you need to send a header?
also can you connect to the api with something like postman?
Yeah I've got the header with my auth token and stuff, and the api will respond with a 403 if the authentication fails
Yeah postman works fine
how did you send the header?
I threw all the request config including the header, body, request type etc into a config variable and then passed that to axios, since that's what postman suggests
maybe there is the issue, that you send something with the wrong attribute
I'll have a look into it thanks
where's my question gone lmao
how do I redirect the user when it's done verifying (bot verification etc) to a specific link?
...what?
if req.session.guilds always returns undefined, what am i doing wrong?
how do I know if two instances are of the same class?
did you use oAuth2 to get the Guilds? if yes did you use the Guild Intend?
log what your oauth workflow returns, maybe its attached wrong
it should return a object or how did you check if it exist?
it returns the user
yes it should return the user object
yes
so it cant be a true or false
but idk why guilds is not returning an object
is it attached to the user object?
res.render('dashboard', { user: req.session.user, guilds: req.session.guilds, cli: client })
no
how did you access oAuth?
i use passport and the profile object returns the guilds together with the user object
gg you do it barebones.
i need to fetch the guilds correct?
yea i guess you need to use users/@me/guilds
but it is limited to 100 Guilds. i get the guilds of the User with oAuth
method: 'GET',
headers: {
authorization: `${response.token_type} ${response.access_token}`
}
})```
this will only give the you first 100 Guilds tho
i only want the guilds the bot and user are in
for the guilds for the bot i needed to use a Websocket connection to get all guilds
idk why you dont get the Guilds, i use Passport for handling the oAuth authentification and this gives me the stuff i send with the intends in a single variable i can deconstruct
idk never rlly used passport
its relatively easy
idk
oh nvm I misread the question
but they both are same instances
yea I misread it
ooh lol, np
but idk the SomeClass
actually I've four childclasses of a static parent class
And I want to know if two instances are of same child class, on one of parent method
the other instance is passed as an arg
so I've this and childInstance on that method
hmmm, ๐ค
Turns out localhost is not a valid address so it was sending requests to http://3000 ffs
There's no place like 127.0.0.1
localhost is valid for me?
but only if you run it on your pc and access it over a browser on your pc
i do localhost with axios on my frontend?
am i doing something wrong
<a class="btn2" href="./guild/config?id=<%= guild.id %>" >Manage</a>
router.get("/guild/config?:guildID", checkAuth, async (req, res) => {
app.use("/guild", require("./routes/server"));
it looks like the path should be /guild/guild/config?guildid
which one?
the last one is in your main file pointing to your routes/server where i guess the 2nd one is the path you want to access right?
then you either use in the 2nd one /config?:guildid or change it in your first one to ./guild/guild/config?id=
and keep the app as app.use("/guild")?
@cinder patio If I do instance.constructor, on any parent method, will it always return the name of the child class?
yeh first time using it
i suggest reading the docs
what docs
the one for Express
<a class="btn2" href="./guild/guild/config?id=<%= guild.id %>" >Manage</a> well i changed that and still same error
so idk
I'm not sure, you should test it
hey could somebody help me out a bit
after running my bot on my vps it shows this icon
and the filter !bassgboost is extremely distorted
but on heroku everything works fine?
i use the npm package discord-player.
@lusty quest i read the docs and figured it out thx
if (client.guilds.cache.get(req.query.id).members.cache.get(req.session.user.id).hasPermission('ADMINISTRATOR')) return res.redirect('/server/config?id=' + req.query.id)
res.render('server/config', { user: req.session.user, guild: req.query.id, djsclient: client })
})
router.post('/config', async (req, res) => {``` why does this send 404 everytime
instance.constructor refers to the Function you call to instantiate the class which instance is an instanceof
Idk if you're able to reference the class which supersedes the instance's unless you have a method in the class which returns the keyword super
i would use redis
other than that
sure not as fast as direct in memory but its easy
i tried memcached but its not setting anything
memcached is like redis just works a bit different
never used memcached.
#[tokio::main]
async fn main() {
let (sender, receiver) = std::sync::mpsc::channel();
let mut users: std::collections::HashMap<String, User> = std::collections::HashMap::new();
let mut channels: std::collections::HashMap<String, Channel> = std::collections::HashMap::new();
let server = TcpListener::bind("127.0.0.1:9001").expect("Unable to start server");
for connection in server.incoming() {
let sender = sender.clone();
tokio::spawn(async move {
let mut ws = accept(connection.unwrap()).unwrap();
ws.write_message("You connected".into()).unwrap();
loop {
let msg = ws.read_message().unwrap();
let msg_json: WSMessage = from_str(&msg.to_text().unwrap()).unwrap();
let close_opts: CloseFrame = CloseFrame {code: coding::CloseCode::Normal, reason: std::borrow::Cow::default()};
match msg_json.opcode {
Opcodes::Connect => {
if msg_json.data["login_pkg"] == Value::Null {
ws.write_message(Message::Binary("{\"error\":\"missing login data\"}".into())).unwrap();
ws.close(Option::from(close_opts)).unwrap();
} else {
let token = gen_token();
sender.send(token.to_owned()).unwrap();
ws.write_message(Message::Binary(format!("{{\"connection\": {{\"token\":\"{}\"}}}}", token.to_owned()).into())).unwrap();
}
}
}
}
});
}
println!("{}", receiver.recv().unwrap());
}
```I have a websocket server that handles connections in a blocking loop, and i want to have data sent between threads so they can be set onto the `users` and `channels` hashmaps. The issue is that the loop is blocking the sender from sending the data, so how can i have it send data to the receiver?
wat
he means barebones
ah
like i want to access that stored data from 2 node js processes
Decent hosting for under 5$?
i guess Tim or PapiOphidian maybe know a solution
@lusty quest
is my question
i can recomend Digitalocean but they are at 5$/Month alternative Vultr
Ok
usually you use some sort of database, but you dont want to so i guess you would have to go barebones with some wired stuff
anyone know how to turn on safe search in dogpile website?
make it accessible in a "shared" area that they can both read and write to
i dont think memory will be aviable bcs in how it works
wait there is something to make pointers nice
my question is why not use a lower level language anyway
one has a big ip
read
the price?
they have different amount of Ram, with this the price scales
tiny amount of ram
they mean the two in frame
512MB can be enough if you have a small bot that dont use much ram
Yea m not dumb
why?
i need to share this object with 2 node processes
i store also objects in redis without any issues
you've mentioned
ohh well
Till 150 servers
just set up a ws connection xdxdxdxd
Decent bot
i run around 300 and use around 80-100MB ram
what exactly are you storing
the message object
maybe you could look into breaking down your bot into microservices
i know
thats what im trying to do
i have 2 node processes that need to look in a memory to get an object with methods
there is an outdated github repo of an node bot that is made in microprocesses
https://gist.github.com/DasWolke/c9d7dfe6a78445011162a12abd32091d this guy got the stuff in his repo
pylint or flake8?
can someone explain why post dosent happen? ```js
router.get('/config', async (req, res) => {
if (!req.session.user) return res.redirect('/')
if (!client.guilds.cache.has(req.query.id)) return res.redirect('/')
if (client.guilds.cache.get(req.query.id).members.cache.get(req.session.user.id).hasPermission('ADMINISTRATOR')) return res.redirect('/server/config?id=' + req.query.id)
res.render('server/config', { user: req.session.user, guild: req.query.id, djsclient: client })
})
router.post('/config', async (req, res) => {```
does it 404?
where is server/config?
no, show me the routes in your js file
like these ones
Has the bot verification been stopped or is it false news?
where did you hear that
oh lol
:(
even discord staff have family they wanna celebrate the holidays with
bottom tbh
i don't like backgrounds so 2nd
@crimson vapor every time i try to append data to formdata, i get TypeError: source.on is not a function
what are you adding?
body.file ?
data.append("file", body.file.buffer, {
filename: body.file.filename,
contentType: 'application/octet-stream'
}) : {}
buffer being a buffer ofc
<% user.guilds.cache.forEach((guild) => { %> returns undefined, user is req.session.user
why?
unless your bots in every guild said user is in there's no way you'd have them cached
i want all the users guilds
if the bot is in change to configure if it isnt its invite
don't think you can get them.
let model = await nsfwjs.load()
let optionsboi = ["Neutral"]
let probboi = 0
if(msg.attachments.size > 0){
msg.attachments.forEach(async(Attachment) => {
async function fn() {
const pic = await axios.get(Attachment.url, {
responseType: 'arraybuffer',
})
const image = await tf.node.decodeImage(pic.data,3)
const predictions = await model.classify(image)
image.dispose()
console.log(predictions)
let i = null
for (i = 0; i < predictions.length; i++) {
console.log("Works First")
if(optionsboi.includes(predictions.className)){
console.log("Works Second")
if(predictions.probability > probboi){
console.log("Works Third")
Attachment.delete()
}
}
}
}
fn()
})
}
It works till - console.log("Works First")
But doesn't work any further
i'm also gonna assume you're using d.js
predictions.className is an array
yes
loads of dashboard do it? there has to be a way
you can get it only using Oauth
yeh im using that aswell
^^
[
fetch('https://discordapp.com/api/users/@me', {
method: 'GET',
headers: {
authorization: `${response.token_type} ${response.access_token}`
},
}),
fetch('https://discordapp.com/api/users/@me/guilds', {
method: 'GET',
headers: {
authorization: `${response.token_type} ${response.access_token}`
}
})
]```
im only getting the users and bot guilds?
if that isn't returning guilds your temporary user token is wrong or something
actually wait
its returning the user just not there guilds
are you permissions correct?
wdym
you need permissions when you sign in to get certain data
scopes?
scopes yes
hm.
so what is the problem?
res.render('servers', { user: req.session.user, guilds: req.session.guilds, cli: client })
using this
i'm not 100% sure then
Just read chat history. If you use the built in worker_threads module, multi-threaded processes share the same memory space which means you can share global variables. Threads can also share locally scoped references by sending messages to each other which you can just pass the reference since the data isn't being duplicated across two different memory spaces.
If they absolutely have to be multiple processes, you have to use something such as redis. I don't know of another database which allows for unstructured and fast K,V storage
You could write your own proprietary Map based cache worker and hook that over a REST api but Node has a bit of overhead which isn't worth it
@lament rock guess whaaaat
What, cutie?
i'm still having a problem with things
What's the problem
file sending
Hoh boy. Still multipart requests
eeeeyup
glitch
There are IDEs for iOS but it's not very efficient since not many of them are mature
although it's recommended you code on a computer
If I had one I would happily do that
Lol
Hm glitch?
Will the website be online 24/7?
for a website you can use literally any platform that supports webview
Oh, so hm is there something else?
idk
it depends on which kind of website you want
Just like dyno
yikes
Why uh...
it requires full stack development knowledge and a proper vps
^
lol fullstack coded on Mobile, if you pull this off you either Insane or get insane
especially on ios lmfao
Lol
android, okay, fine, android can be unlocked and pushed to its fullest potential

but ios is a literal cage, good luck doing anything without jailbreaking
There is a vscode online
@lament rock visual studio code?
I haven't tested on iOS, but 
you need code-server running somewhere
no?
So, uh ima be honest visual studio code can be installed on iOS
I don't believe so. I was able to run a sandboxed version with just vs liveshare
I mean in the website
Oh @lament rock and btw is visual studio code better than repl.it?
By every stretch, yes
Ima try to get it
visual studio code is just an editor
repl.it is an editor which automatically runs your code afterwards and hosts it
@lament rock now as i was saying, i was trying to use the form data package
body.file ?
data.append("file", JSON.stringify(body.file.buffer), {
filename: body.file.filename,
contentType: 'application/octet-stream'
}) : {}
data.append("payload_json", JSON.stringify(body))
i get silence when i try to send data like this
Please help me
Please ๐ข
if the 2 other logs don't appear, it means both your 2 conditions were false.
But why ?
It's true
Code is very bad then
Does anyone think they could help me make the bot check if the user they are trying to ban/kick is above the user who ran the command
just compare their "highest role" position
@umbral zealot so what should I do
thanks
fix the code
It had a property Neutral
How ?
What's wrong in the code
May I send the logs ?
Start by console logging your values maybe
You made the assumption that those conditions could return true. They're not. That assumption is false, so verify the data
console.log(optionsboi) and console.log(predictions.className) and see why one doesn't include the other. And then console.log(preductions.probability) and console.log(probboi) and check why THAT isn't working.
if(msg.member.highestRole.comparePositionTo(BanUser.highestRole) <= 0)
returns the error TypeError: Cannot read property 'comparePositionTo' of undefined
now i just woke up so im probably being really dumb rn
is highestRole the correct variable?
idk i just woke up
maybe read the docs
of whatever lib you're using
@ornate otter are you using d.js?
mhm.
and yes
Traceback (most recent call last):
File "C:/Users/Link/Documents/Programming/Expirements/Game-Bot-50d61accd6850640ef71cb832fcfd95c2f19b64b/train.py", line 34, in <module>
main()
File "C:/Users/Link/Documents/Programming/Expirements/Game-Bot-50d61accd6850640ef71cb832fcfd95c2f19b64b/train.py", line 29, in main
model = train_model(model, X, X_test, Y, Y_test)
File "C:/Users/Link/Documents/Programming/Expirements/Game-Bot-50d61accd6850640ef71cb832fcfd95c2f19b64b/train.py", line 20, in train_model
model.fit(X, Y, batch_size=batch_size, epochs=epochs, validation_data=(X_test, Y_test), shuffle=True, callbacks=checkpoints)
File "C:\Users\Link\Documents\Programming\Expirements\Game-Bot-50d61accd6850640ef71cb832fcfd95c2f19b64b\venv\lib\site-packages\keras\engine\training.py", line 952, in fit
batch_size=batch_size)
File "C:\Users\Link\Documents\Programming\Expirements\Game-Bot-50d61accd6850640ef71cb832fcfd95c2f19b64b\venv\lib\site-packages\keras\engine\training.py", line 789, in _standardize_user_data
exception_prefix='target')
File "C:\Users\Link\Documents\Programming\Expirements\Game-Bot-50d61accd6850640ef71cb832fcfd95c2f19b64b\venv\lib\site-packages\keras\engine\training_utils.py", line 138, in standardize_input_data
str(data_shape))
ValueError: Error when checking target: expected activation_6 to have shape (4,) but got array with shape (36,)
anyone know how to fix
def train_model(model, X, X_test, Y, Y_test):
print(X, X_test, Y, Y_test)
checkpoints = []
if not os.path.exists('Data/Checkpoints/'):
os.makedirs('Data/Checkpoints/')
checkpoints.append(ModelCheckpoint('Data/Checkpoints/best_weights.h5', monitor='val_loss', verbose=0, save_best_only=True, save_weights_only=True, mode='auto', period=1))
checkpoints.append(TensorBoard(log_dir='Data/Checkpoints/./logs', histogram_freq=0, write_graph=True, write_images=False, embeddings_freq=0, embeddings_layer_names=None, embeddings_metadata=None))
model.fit(X, Y, batch_size=batch_size, epochs=epochs, validation_data=(X_test, Y_test), shuffle=True, callbacks=checkpoints)
return model
this is my code
it errors out on the model.fit line
ValueError: Error when checking target: expected activation_6 to have shape (4,) but got array with shape (36,)
if (!webhook) webhook = await channel.createWebhook(name, {
avatar: avatar
});
Anyone knows why my code just gets stuck here?
no errors
nothing in console
It just stops there
it also doesn't create a webhook
it used to
but the last few tries it doesn't anymore
code looks valid, maybe the if check blocks it from getting executed
The Content-Type needs to be
`multipart/form-data; boundary=${formData.getBoundary()}`
hm.
const formData = new FormData();
formData.append("file", data.file.file, { filename: data.file.name });
formData.append("payload_json", JSON.stringify(data));
return req({
url: endpoint,
"POST",
data: formData,
headers: {"Content-Type": `multipart/form-data; boundary=${formData.getBoundary()}`}
});
hey
async def open_account(self, user):
users = await get_bank_data()
with open("mainbank.json", "r")as f:
users = json.load(f)
return users
if str(user.id) in users:
return False
else:
users[str(user.id)] = {}
users[str(user.id)]["wallet"] = 0
users[str(user.id)]["bank"] = 0
with open("mainbank.json", "w")as f:
json.dump(users, f)
return True
async def get_bank_data(self):
with open("mainbank.json", "r")as f:
users = json.load(f)
return users
@commands.command()
async def balance(self, ctx, open_account):
user = ctx.author
open_account = open_account
await open_account(user)
users = await get_bank_data()
wallet_amt = users[str(user.id)]["wallet"] = 0
bank_amt = users[str(user.id)]["bank"] = 0
embed = discord.Embed(
title=f"{ctx.author}'s balance.", color=discord.Colour.blue())
embed.add_field(name="Wallet Ballance โฃ",
value=wallet_amt, inline=False)
embed.add_field(name="Bank Ballanceโฃ", value=bank_amt, inline=False)
await ctx.send(embed=embed)
discord.ext.commands.errors.MissingRequiredArgument: open_account is a required argument that is missing.
error
The user didn't give a open_account argument.
If I ran !balance it'll error.
If you want it to be optional default it to None
Aka open_account=None
but i want the account to open whenevr this command is executed
it worked fine without the cogs
but with cogs it is giving error
Because open_account isn't defined
I don't even know why you're giving it the same name as the function
It's a method, so you need to refer to it with self
async def balance(self, ctx, open_account):
no cuz theres code after it that doesn't get executed
CogName.open_account(self, user) is equal to self.open_account(user)
do i add that in the param or under async def
Bruh, making a discord bot in python without knowing how python works is pain
lmao
why are you listening for argument errors
What
??
It's raised by default anyway unless you silent it
@earnest phoenix i am sorry for asking stupid questions i just suck at coding i just started it
everyone has to start somewhere
Bad idea to start off with discord bot, but nothing is stopping you
Except rule 8.a
i started with like a game you wanna see?
Nah
What is a pentester
nvm
someone who is specalized to attack software/websites
nop3
to check if there are vulnerabilities
Oh, pen refers to penetration?
yea
Yes
No
Yes thats right
data.file.file, is that a buffer or a string
@lusty quest are you one?
no but i know a few
Umm do you exploit open ports
wdym
im not out for attacking others, i have no intention to do so
hello :)
I have a Question
How do I know the names of the servers my bot is joining?
I think they added my bot to the fake servers
Because it has become a member of 60 servers in three weeks
also it can get you into trouble
sounds like normal Growth
Nvm

if you use js you can just run a loop over the guild manager and then get the name from each guild
i would be worried if it would be way more
Can my bot be blocked if it joins many fake servers?

not really
anyone gonna help me with this
looks like Tensorflow on py. but there ends my knowledge
i dont know py
and only did some small research on tensorflow
I only know its some sort of problem with the layers
need to convert it somehow
idk how
sadly google didn't really help me either
guess I will have to ask in the python discord
Buffer
@lament rock hii
i don't think my form is sending at all
Hi. Do you need something?
no nice pfp
Is the request even being made?
i'm trying to see
how can I host a webhook locally using Flask?
do you know the flask basics?
yea
J
yea I setup a basic flask server last night but the webhook on Topgg never reached it, I had the correct port open as well
What to do about this ?
vote your bot by yourself and make it reach
there's a test vote feature
yea I used that to test
and it never reached my server for some reason
I set the webhook url on Top.gg to: http://mypublicip:5000
you probably routed it wrong
or disabled post
and then on my flask server
so it's listening on the / route
then
so it's listening there?
I then tried to run my flask server in different ways, one on localhost and one on 0.0.0.0
did you try curl from any other device ?
like making a fake request and testing if it's reachable
or postman
yeah if it's not working, your device isn't port fowarded and can't receive non local requests
yea I think thats the problem, the port isn't open
for some reason
yea its not working on other devices on my network
something is wrong
then use the IP of your local machine to access it from other devices on the network
@gloomy yew
open the port on your pc
you can open ports with netsh interface portproxy add v4tov4 listenaddress=127.0.0.1 and then append listenport=9000 to set a port to listen on
connectaddress=the IP connectport=whatever port as a connection to the proxy
I'm not sure if this is Flask specific, but when I run an app in dev mode (http://localhost:5000), I cannot access it from other machines on the network (with http://[dev-host-ip]:5000). With Rails...
see this
thank you I'll check it out
unity uses it for some backend stuff
isn't that deprecated
its common that software use Mutiple languages
idk my friend and I were discussing if Cpp or Cs was better
(he wants to start coding)
and wants to do game dev
Cpp is better
tell him to go with Unreal Engine
It's Cpp
Cs is definitely not EASY
I thought Cs was easier then Cpp
if you know already a language is easyer to pick up
Cs is more like Java and I hate Java
thats why I told him to do js or something like that to at least get an easy language toi start with
but he wants to do game dev
people are starting with C++ or C# its not an issue but its harder to pickup as js, py or lua
imagine starting with Java
i know 2
ahum minecraft devs
ahem all android Devs before Kotlin
I have an API that I am using for my bot, and I can get data to it easy enough through the appropriate requests, but I also need the API to send stuff to the bot which I plan to use webhooks for. How would I structure my code in order to allow my bot to do certain things based on the request sent to my webhook?
you can just use your bots stuff inside the webhook event
should be delete? it would be in the docs.
It doesn't work.
But how would I get it there because at the moment I have the actual express app in a separate file, which has it's export set to the express instance
Apparently it's remove according to the docs โข๏ธ
Thank you! ๐
its easiest to look at the docs yourself to find it.
True
Im not sure of the "proper" way, but all my exports export classes which are used to setup stuff like express, or webhooks.
in cases where i need data from the initializing file*
Hi, I'm saving fetched user object in my db as JSON so I don't have to fetch it every single time someone uses the command.
The problem is if I call avatarURL() on the user object from database it throws an error (is not a function I think), is the issue that discordjs uses collection and the avatarURL() can't be called on object? I'm not really sure how collections work because of the fact js doesn't even have any right?
How do I get avatarURL() from preserved JSON user object?
best bet, log the json user object to find it.
or, rather than saving the whole user, save only the parts you need.
the first one is original fetch, the other one is the preserved db object, couldn't find any difference ๐ฆ
the problem is avatarURL() throws error on the second one while working on the first one even tho they're the same
uhmm
the first one is the class user, so it gets all the methods from that.
which wont be saved.
constructing the url isnt hard at all.
https://cdn.discordapp.com/avatars/136583532972605440/0292de8c83b3e8e3558e9be9886b02cb.png?size=128
^ my url
https://cdn.discordapp.com/avatars/userid/avatar.png?size=128
can drop the size.
user.saveAvatar = user.displayAvatarURL(); JSON.stringify(user) if you're lazy
I seee, thanks a lot ๐
flaze
Does someone use node.js?
Nope
What kind of question is that... ofcourse someone uses it ๐
yea
But who?
would you like a list?
lol
Just ask your question about node.js xD
Okay
"platform": "discord",
"url": "[webhook link]"
}```
How do I put that configuration on the app?
trying to make an object?
(you shouldn't share webhook URLs either, regenerate it rn)
dfiscored?
your trying to run it in a command?
what exactly what do you want to do
maybe a startup configuration?
i think nodejs has flags n stuff
I just want help on how to type that!!!!!!!!
well, theres lots of ways to
and you said no to the two most common
looking to make a config file?
the article says you have to do a config.json file
store it in a variable?
Is there a way to type like exactly this?
"platform": "discord",
"url": "[webhook link]"
}```
yeah put it in a config.json file as the article says
i mean, in a json yes.
I can't paste that text on the app
But I need the app to open that file
if you want to do it through the app, you might be able to use flags.
jason.db
you can't escape jason.db
it wont be exactly that, but it would serve the same purpose.
What program do I use to open .json files?
the article doesn't say anything about flags tho
nodejs can
sure, but im answering the question he asked, not what the article says to do :p
I opened the .config.json by that program, and the window disappears.
So I can't put the config on the file
well, generally nodejs isnt a text editor. If you want to use it as a text editor, youd have to write some code. just saying .config.json wont do it.
Can I write the code on Notepad++?
thats a text editor, so yes?
how can I convert a buffer to an array
how can one page look like this, and the other like that
same location file, exact same code
@solemn latch ?
if its a json file, .json
thx
its the exact same code in each file
css might not have loaded
that can happen?
check console for what though?
Hard refresh cache
none
ctrl r
Are you linking the page first of all 
i had to reset again and it worked, but now this happens
ghoal
<link rel="icon" type="image/png" href="../assets/imgs/Untitled-1.png" />
lang
jsd
isn't a buffer already hex bytes
(This is a stack overflow kind of question)
hey @solemn latch
do you have any idea how i can serialize an object with methods and maps and functions?
you can't really serialize functions, not a good idea
well, you can, youll just have to eval them to run them
guess, still not a good idea
you only serialize the needed data
the function can be created on both processes and ran with the serialized data
no point to serialize functions
yeah, i mean i do need the methods to send back data and do other stuff with it
so
for example the message object that djs gives
im actually trying to share this message object with 2 node processes
the weird thing is i have a good vm of 7gb ram and 2 cpus and its still not able to handle 50 users concurrently and lags
don't use node if you're targeting performance
Serialize only the important data you need like channelId, guildId, content, id, etc. Then on the process that receives the message you'd do something like this:
const {Message} = require("discord.js");
const receivedMessage = new Message(client, messageData, client.channels.get(messageData.channelId));
receivedMessage.delete();


