#development
1 messages · Page 1971 of 1
it's so strange like people will spend much more money every week on going outside with their friends just messing around but when it comes to buying things they actually need for their hobby they're like nah king I need this to be free?
I hate github pages now
I am doing exactly what they are telling me and making a CNAME record that is pointing to <username>.github.io and they say my DNS records are invalid
dns can take a while to propagate sometimes
Mmm ic
I didn't know DNS also took a bit to propagate
Mmm but it seems it doesn't agree with my angular project it doesn't show my website's content 😢
bruhh fuck that pug language it's sooo annoying
each val, i in highlighted```
what the heck is this supposed to be
i will but i am trying to convert this to ejs first
no stop
watch me add random cpu throttling ima be rich
i have to
ejs is nightmare too
well it's way better than fking pug
they're equally shit
https://pugjs.org/language/code.html just look at this
I've used pug before it's meh
what's wrong with ejs i find it great for small projects
i am trying to go away from pug at least
but idk how to convert most of this shit pug js to ejs js
templating languages always have some cringe limitation. For example ejs doesn't even support the concept of components
Wtf bro I got it working earlier and I made a few changes and repushed and now this shit again 😢
you have to either copy paste code or implement the concept of children or slots using a dynamic import inside a layout file
totally disgusting
<div class="col-md-4">
each val, i in highlighted
if i < 2
each articleVal, i in articles
if articleVal._id == val.article_id
a(href=`/article/${articleVal.num}`)
.article
each catVal, i in category
each subcat, i in subCategory
if articleVal.category_id == subcat._id
p.category-label= subcat.name
if articleVal.category_id == catVal._id
p.category-label= catVal.name
img.img-thumbnail(src= `/uploads/${articleVal.image}` alt='image')
h5= `${articleVal.title.substring(0, 60)}...`
p= `${new Date(articleVal.date).getDate()}, ${new Date(articleVal.date).getMonth()+1}, ${new Date(articleVal.date).getFullYear()} `
span.fa.fa-clock
</div>
just look at thiss
how is my little brain gonna go through this
What the actual fuck is that
dude wyd
you need to do this pre-processing in your controller
send data to your view that's ready to be rendered
don't put this business logic in your templates
shid
you can much more easily manipulate objects and arrays in regular js, send it to pug and simply render the data there in a clean way
it's not really a pug problem here tho
and not pug ejs
the code isn't mine
if it was mine i would've converted it awhile ago
the problem is that i know shit about pug
you do need to convert this into js by moving this whole thing into a data structure you build up in your controller
ejs isn't the solution here
yes that's where i wanna get to
yeah but still i wanna turn it into actual js
not some each val, i in highlighted
like tf is that
ejs sucks just as much it's just syntax difference
in fact I'd probably use pug over ejs cuz it has actual features
i wanna get rid of pug at this moment
wish i could understand pug
is there a way i could convert this pug js to actual js tho
without me having to learn an entire templating language
you're only getting the first 2 elements from the array. So go do
const selected = highlighted.slice(0, 2)
in your controller so you don't need this i < 2 check. Use a nested .find so you don't need the article ID check in the template etc
templates are for taking in data and returning html. If you have all of this crazy transformations in here it means your template isn't accepting the data it actually needs
<% const selected = highlighted.slice(0, 2) %>
this would be on ejs
no
const selected = highlighted.slice(0, 2)
res.render("template", {
selected
})
pass the data your template needs, not whatever you happen to have
ohhh so i can define it from the router
yes that's what a controller is
gotchya
it looks like your template is trying to render something like
const data = [{
article: {
category: [...],
image: "...",
titlePreview: "...",
startDate: Date,
endDate: Date,
}
}]
but because you're not passing it that data you need to do a ton of noisy transformation on it
What does this mean?
in a templating language that's not designed to do that kind of thing
just please for the love of god don't do this. This was the entirety of top.gg codebase when I joined and it's an absolute nightmare of copy paste. Put your transformation logic inside regular javascript so you can reuse business logic and can include your templates as components where you need it
means you kept sending bad data to discord (like an empty message that can't be posted) that made discord error out so they preemptively banned you to prevent you from triggering more errors
ty vm for all the suggestions appreciate it ❤️
const app = express();
const port = 8080;
app.get('/', (req, res) => res.send('Hello World!'));
app.listen(port, () => console.log(`Example app listening at http://localhost:${port}`));
'use strict';
const { ShardingManager } = require('discord.js');
const manager = new ShardingManager('./index.js', { token: process.env["TOKEN"], respawn: true });
manager.on('shardCreate', shard => console.log(`Launched shard ${shard.id}`));
manager.spawn({ timeout: Infinity })```
This is my code but a shard died not too long ago and did not respawned why is that?
mae sure its const not onst
@spark flint in my code it was const I just didn’t copy it right
What's the issue?
When a shard dies it does not respawn
Strange
Why?
It should according to the code
I will keep watch on it if it ever goes down
respawn: true? I've never seen that property and I don't use it and I usually CTRL + C to restart. Although, what does the property do?
it should be true by default
respawn option does exist
What does it do, exactly? I'll check documentation.
It's for the sharding manager
It is self-explanatory, but I need some slight bit of more information.
I'm aware.
if a shard dies it should respawn because of it being true
What's the version of djs you're using?
Well, how would it die, exactly?
v13
Either by an error or a ram issue
I am not too sure tho
Nice
because i did an accidental and purpose mistake
res.error == "true" was intented to annoy akshit
JSON.stringify("application/json") wasn't tho
You deserve programmer hell jail
ok
@old cliff Do you know a tutorial for Lavalink and JDA? Or Nodejs?
no
yes
@woeful pike ${articleVal.title.substring(0, 60)}... sorry to bother but what are the 3 dots in here used for
I've seen it in a few cases in pug
so it's just text?
yeah
it doesn't matter if i get rid of it
don't think so
oki good ty
if '69' in message.content:
while db['que']==True:
await asyncio.sleep(10)
as per my knowledge this code isn't reacting with discord api so I don't think it can get my bot temp banned just asking before implementing
using it so that only one command can be active at a time since my bot commands take more than 2hours to complete
== True you never ever need to compare something to a raw boolean
I don't think it can get my bot temp banned
ye, you only get temp banned if you call the api too many times
discord (or any other service) doesn't care what you do behind the scenes
that said, that piece of code is a pipe bomb
I'd at least limit who can run it
the heck do you do that takes two hours?
Quick question I was thinking about.
What if there would be a decentralized login system. Like if you have a company and the accounts are saved in a blockchain. Wouldn't that be very secure and quite interesting to have? (Hypothetically)
sleep and eat
also very slow
const pug = require('pug');
const ejs = require('ejs')
router.set("view engine", "pug");
router.set("view engine", "ejs");
is using 2 view engines like this a thing
slow? Why, I mean the Solana Blockchain takes just a few seconds and everything's done
highly doubt it
broadcasting news in 1000 diff channels with cooldown of 1 sec before sending a message
using the above code to make it broadcast 1 news first and 2 news will be in queue until broadcast of 1st news doesn't end and turn the boolean into false
a few seconds vs a few miliseconds to connect and check a dedicated database
well okay true... but you don't need to login all the time, do you?
also, wouldnt you need to pay to store a new user in the chain?
If you would have an own blockchain you can choose this by your own...
yeah but if you use an existing chain like solana
yes then you would have to pay.
creating a whole new blockchain just for logins sounds like overcomplicating something simple
I won't I was just wondering about it xD
With this I can not agree
yes true but as I said everything hypothetically xD
Regarding the discussion of last night, complicated is exactly what he wants to have 
would be better to run the next item in the queue, if it exists, at the end of the previous job, instead of checking whether the job is done every x time
Nah I found a simple "workaround" 🤷♂️

tutorial source?
you dont need a tutorial for that, its just simple logic
just do something like this
queue = [];
running = False;
on command:
add job to queue
if running == False:
send_news();
def send_news():
news = queue[0];
running = True;
for channel in channels:
await channel.send(news)
remove item from queue
running = False;
if queue size > 0:
send_news();
``` idk python so idk the exact syntaxes
mass message™️
Hey! My bot won't go online after starting it. It doesn't go online and the ready event isn't triggered
Check if you got banned for 24h for too many login attempts
How?
You missed () like client.once('ready', async () => {
shouldnt be the problem, has always worked like yhat
Catch the client login if you don’t handle errors yet
No error, nothing not even after a few seconds?
nope, i've waited a few minutes now
If you have the chance try to start the bot on a different PC with a different IP address
banned?
how do i know?
if it works from different ip then its either banned ip or rate limited
I’m theory you should receive an error if your IP got banned temporarily
or i mean
it should
It might be some sort of connection issue or really an IP (range) ban even if that’s not your fault
Give it a few hours or at least 24h and try again
Host the bot meanwhile on a different IP if possible
if it is on development then you could use replit and do kill 1 everytime this happens ig
if so then that might be why you get rate limited
Yes.
you've kill 1?
Kill 1 always works for me
yes
yeah
At the end any free service has major downsides
true
async is a reserved word, its incorrect to use it like that
client.once('ready', () => { would be correct
also, you can see what exactly your bot is doing by using the debug event:
client.on("debug", console.log)
not in node v16
what does this log though
everything?
it logs discord.js's internal things, like connecting to the websocket
You can use erlea.js for node
It has a tutorial
Hi, im trying to make a bot for clash of clans which will send clan messages to our discord, I already made such thing using minecraft but I used an already existing yarn package for the actual bot in minecraft, does anyone have an idea on how to make a bot in coc?
Pls ping me if u answer
To use buttons, do i need a onclick event?
like if i want a certain code to be executed
I don't think you will have access to coc messages.... is there a developer api for coc?
for bots? no buttons use a collector for disc bots
buttons fire the interaction event
guess hes speaking about buttons in a website
any ideas why am I getting this error on my new vps (it was working fine on the prev one tho)
Language: Python
Library Used: Pycord (a fork of dpy)
client_connection: Connection<ConnectionKey(host='gateway.discord.gg', port=443, is_ssl=True, ssl=None, proxy=None, proxy_auth=None, proxy_headers_hash=None)>
ok idk how tf but it says "Error: Cannot find module 'lodash/get'"
but
loadash/get isnt a module on npm
and theres loadash.get but i need loadash/get
u have loadash installed?

loadash/get probably means requiring the get dir/module from parent module i.e. lodash
oh
i do
just require it then
oh
yes, but not messages that's why I was thinking of making a bot but I don't know how as I can't use pupeteer for a mobile game
Hey! How would i check if the user who clicks a button is the same user that executed the command?
Do you speak about interactions?
Yes
You don't have to fetch the reply. You can assign callbacks to button custom_ids in your own code and then check that in the callback
The easiest way to deal with buttons is to make your own callback system
But the button interaction does not contain any information about the inital reply
The custom id doesn't change the fact it can be used by anybody.
This is true, but you can use a "nonce" system with unique custom_ids
I mean you could send an ephermal error if the user ID pressing the button isn't the one you expect
https://github.com/AmandaDiscord/CallbackComponents/blob/main/index.js
This is a sample system I made which makes the relation of the Discord.js MessageButton Constructor and callbacks in code
ThunderStorm is my remake of Discord.js, but cacheless
using this example, reply.what?
huh what?
.then(reply => console.log(`Replied with ${reply.content}`))
.catch(console.error);```
reply.content only returns the message i'm replying with
same with just reply
You should probably avoid using that because it would not scale well and you would hit rate limit buckets
oh ok
The best way to do it is the way I suggested
can you explain that a bit easier?
Not directly using what I linked though since that's for my own lib
You should read through the code and try to pick apart what you need
alr
ThunderStorm is basically the same as Discord.js so it's just a drop and rename kinda deal
You should really cache the member ID which executed you command and compare it to the user ID of your custom button ID
That would still require some relation to be made. Buttons should be callbacks anyways
Yeah you could add it to the guild cache or channel cache
That would be the easiest way
what
The next member executing the command would overwrite the ID then

Store the member ID as property of your cached channel, my gosh English is bad today
If a button interaction is used check if the property exists in this channel, if yes, compare the value (user ID) to your button interaction member ID
Couldn't be easier
It would be a good idea to store a map of the interaction ID and the user executed the command
To make sure multiple users running the same command can still interact with the button after
Everyone's code is different so that's largely up to you
I showed you what I believe to be the best and easiest way to go about things without doing anything jank and dependent on ideal conditions
u mean this link right?
Yes
I haven't bothered looking into v14-dev yet, so main
Oh. wait. dev on my repo
dev is outdated
use main
same
// exclude customId from data you pass since it gets overwritten
interaction.reply({ components: [new Discord.MessageActionRow({ components: [new BetterComponet(dataForComponent).setCallback(() => code()).toComponent())] }] });
Then you just pass the MessageComponentInteraction to the lib handle and it takes care of the rest
is it requires Message Intent if I ping my bot?
If your bot requires reading the contents of a message, such as for registering a complaint, a user can ping your bot by doing @KartonMaid, and then your bot will be able to read anything within that message.
Discord sent me as answer to my application
if your bot is mentioned in a message then the content will be sent to your bot without needing the message intent iirc
little question: would ws or fastify-websocket be faster at handling websocket connections?
(ping me back pls, NPMs [node.js] btw)
uWebsockets.js
but it replaces your entire webserver so maybe only use it for the ws handling on a separate webserver
how do I define the function that is called when a button is clicked?
Depends on what library you're using
When using the API, you give Discord a structure for what the components (buttons) will look like. You can't just send Discord a function to run when the button is clicked since Discord only cares about the data on that button.
When a user clicks a button, you'll get some data and indicators for what button was clicked (usually through a custom ID you set).
how do i log votes
Some libraries may streamline this process for you so you can provide a function, but, under the hood, it's doing what I've outlined.
You may be interested in using the webhooks API. https://docs.top.gg/resources/webhooks/
ok
Are you fr rn
you make a loop to dm ppl
Speedy 
Im trying to make this command where if i type the command in the chat and i mention the user it sends a direct message to the user. but ive tried the things that i know and i kept on getting errors. so anyone that knows the code to it please reply to this message
well i tried different codes and kept getting errors
probably best to fix the error rather than replace the code entirely
Well randomly copy and pasting code won’t get you far
The stuff you can find on the ‘net is most likely outdated
i did this code but it didnt work message.author.send(dm);
what error did you get?
yeah i just realized that i didnt put user
You gotta get the member/user object from the message mentions
i got this error Cannot read properties of undefined (reading 'send')
require('discord-reply')
module.exports = {
name: 'dm',
async execute(client, message, args){
let user = message.mentions.members.first() || message.guild.members.cache.get(args[0])
const dm = new Discord.MessageEmbed()
.setTitle('test')
.setDescription('Test')
message.user.send(dm);
}
}```
You define user as your var
Why do you wanna send the message to the message.user then?
user represents your member object
Use it to send the message
Also why do you import discord-reply?
You shouldn’t import stuff you don’t use
saw this on a tutorial for working with postgres, isn't this a terrible terrible idea? Connecting and then releasing each time?
doesnt that defeat the purpose of a pool? 👀
I let my pool connection open until the process exists
It does
i am going to use it so it replys to the user that used the command
message.user.send() sends a message to the user who has executed your command
also as an fyi you wont release the connection if you error on that query
You wanna send your dm to the member you mentioned
Therefore it’s user.send()
Based on your code
dont i use let user = message.mentions; or i have to change it to var
has nothing to do with let, var or const
you are accessing message.user, but havent assigned anything to message.user
you assigned it to just user
so I've never really worked that much with postgres before but I'm trying to move away from mongo because it's a hot mess
is it possible to make a string key and object value in postgres?
if that makes sense
afaik, postgres has no object value, but you can always store it as a string and convert to an object
oh yeah that's probably a good idea
~~i've been dying for the past few hours. how do you get UintContents?
||I found https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder, but I'm not using utf8, nor can find a way to just decode the numbers in Uint8Contents... or maybe I'm blind.||
I'm trying to find a way to send Int8Array() to a websocket then decode that Uint8Contents into an array like [2, 4].
what I'm sending:
let array = new Int8Array(2);
array[0] = 2;
array[1] = 4;
ws.send(array);
what I'm receiving:
ArrayBuffer { [Uint8Contents]: <02 04>, byteLength: 2 }
I'm assuming I need to put something inside TextDecoder().
let string = new TextDecoder().decode(message);
console.log(string)
-> the result i want: create an array [2, 4] (which is based off the received values). ||all i need is the numbers in Uint8Contents as an array.||
-> actual result: outputs (i think) 2 blank spaces.~~
solution: new Int8Array(message);
also how do I query postgres safely without accidentally doing a funny injection attack
nvm I think I figured it out
nevermind again, I'm big stupid
never done much with SQL in general
Var is the short form of variable
In your case let user… is a var you declared
that’s the reason why var is called var 
I think my computer science teacher is el stupido
Exam:
Write an SQL statement to select all fields from the results table where the students are in the art class
My answer:
SELECT * FROM Results WHERE "Class" = "Art"
Mark scheme:
Correct
My mark:
Wrong
You values need to be strings
tried it both ways, same errors
Never saw test being an integer 
mongo >>>>>>>
Postgres exclusive?
Usually it doesn’t matter if double or single quote
time to figure out parameterized queries, and the best way to store an object
You guys know how to update replit version?
All yt vids dont work 😕
But I’m not a Postgres user
wdym replit version
idk i dont use postgres either
JSON stringify it even if I don’t get why you would store an object
.nix method
Might be the app he’s using, SQL syntax doesn’t care about single or double quote actually
I'm using pgadmin for testing some queries, that's probably a postgres thing
Mongo > 🤮
You can’t compare document based databases to complex relational (table based) databases
how do I give buttons functionality
Maybe you updated to v13?

so true 😂
is in v13
You subscribe to the interactionCreate event
Pressing a button will trigger that event
hmm okay I will search that up thank you
Your client receives that event
Yes
The event comes with the interaction object, in your case a button interaction which contains all infos about your interaction
its okay
@lyric mountain I made lots of fixes and noticed that the bot is usually at 0.5%-2% CPU usage, but from time to time (matter of a few hours) it suddenly spikes to 100% and that's when it dies. I looked and I really have no potential infinite loops or something like that. I had many unhandled exceptions which I fixed now. I noticed the CPU doesn't go slowly up so I doubt it's a mem leak or something like that. It's about 0.6-2% for hours and could spike to 100% in a few seconds and then stay at that. I have 2 guesses now
- Maybe someone is stressing the bot? It died twice or 3 times at night and works pretty much flawlessly the rest of the time
- Can it be related to me using async wrongly? I do call some synchronous functions in my code. Namely using sqlite and querying my database for every message received.. should I be using aiosqlite (Sqlite for AsyncIO) (just found about it now)?
just use official (?) sqlite lib
but that shouldn't cause spikes
yep I'm using the official one for now
try using a profiler to see where it spends the most time processing
hmm nice idea. I thought in the direction of cpu monitoring but this is also an idea
ty
also, make sure not to have many async tasks at once
remember it all runs in a single thread
How can I edit a previous sent message when I click a button
get message , edit message
on button click ^
nO pRoBlEm
??!!
what library ?
pretty sure you need the message reference / id
Yes but how do I get that ID
then do channel.messages.fetch()
you either have to get all the messages in the channel then filter them to find the one you want
or parse a link to the message
or have the message id stored from when it was sent
you cant just manifest an id from nothing , there must be some kind of start point
Yeah I am trying it rn with this one
Yes it worked
@wheat mesa shut up kthxbai <3
So me and waffle have been having issues lately when using typeorm. We get this error No repository for "Tag" was found. Looks like this entity is not registered in current "default" connection? after the connection is formed and we then run a command that utilizes the table to create an entry.
yo, I am currently experimenting with a combination of flexboxes and grids to achieve some kinda layout, but somehow my flexbox seems to rather like to have some space in between instead of using the space to have no line breaks
FetchError: request to https://discord.com/api/v9/gateway/bot failed, reason: connect ECONNREFUSED```
???
discord.js giving this error
Discord's API just sometimes goes out. Something you have to deal with. Discord.js is not at fault
it is not, correct
how do i fix this error? Or is there no way?
Try again later
this has been going on for over 2 hours
should i worry?
^^ for the curious and those who enjoy pain
Has it changed since I last checked? I swear there were only a handful.
theres about 30 lol
expand the example programs section
and also third party libs that go alongside it for stuff like youtube streaming
Is there really no C++ interpreter you can pull up instead of raw compiling?
still stuck on this, not sure why. here's our entity: ```ts
import { Entity, BaseEntity, PrimaryGeneratedColumn, Column } from 'typeorm';
@Entity('tags')
export class Tag extends BaseEntity {
@PrimaryGeneratedColumn()
_id!: number;
@Column({ name: 'name', type: 'text', nullable: false })
name!: string;
@Column({ name: 'description', type: 'text', nullable: false })
description!: string;
@Column({ name: 'thumbnail', type: 'text', nullable: true })
thumbnail?: string;
@Column({ name: 'color', type: 'integer', nullable: true })
color?: number;
}
The entity itself isn't the issue here
I can almost guarantee that it is how we are creating the connection
Most likely
nah, C++ isnt an interpreted language
and even if there was such a thing, it wouldnt have access to the native compiled bot
ive seen a few such "interpreters" but generally theyre trash
e.g. they dont support even C++03
Yes, but how about running an interpreted version of it? I haven't used C++, but Cling looks interesting. Plus, you can embed it (so maybe it can access the bot instance)
Pretty much any language should be able to do it
It's just about shipping the compiler (and runtime potentially) with the program.
In the case of c++ it can be run almost directly by java and kotlin (idk abt other jvm languages)
Cuz JNI
So you can make a two-way communication between both languages on same runtime
What you're talking about seems to be more concerned about communicating across languages (externals)
and not about how to make dynamically evaluating C++ code not take a century to load
c++ was never meant to be interpreted, it has no vm like c#/java/js
hell it doesn’t even have a runtime
everything is dynamically linked at compile time
It wasn't meant to, but that doesn't mean it can't. :p
I'm interested in if what I've described is possible and has a less atrocious output than what's currently available.
yeah it’s possible, but that doesn’t mean it will ever be practical
But will it be more practical than the current implementation?
yeah probably but not enough to warrant using it
interpretation will always be slower than native execution and it’s just not worth it in the context of a single command for a discord bot
All of the time right now is being spent on compiling (9 seconds), so interpreting that so it takes, let's say, 0.3 seconds, would be a net positive. Even for one command, you might as well not have it given the compile time is too slow to be useful.
Not having it is probably the solution, but live, dynamic evaluation of code is useful, but at odds with C++.
yeah the design philosophy is just different
it’s cool to see traditionally compiled languages turned into an interpreted version but the debate of interpreted/jit compiled vs traditional compilation is a lengthy one
personally i am a huge fan of compile time errors over runtime errors and it’s not something i would ever want to give up
I don't see it as a debate. I see it more as an integration—run a compiled bot, but, for convenience, test it dynamically. It's a different story for REPL-driven environments like lisps, but that's irrelevant here. It's just about running code and getting a response. Some platforms are just too slow or don't offer the support for that, so interpreters pop up.
The issues caused by having a runtime be the source of errors is not something i think a lot of people would want to experience even in development
and anyway techniques like incremental compilation and optimisation strategy mean that compile times can be very minimal without an interpreter
There are a lot of good things about having a runtime though. You can run and test a program interactively and not have to restart from the very beginning. Heck, lots of software like React's hot reloading and Discord.js examples on creating a reload command came from wanting to develop quicker and more lively rather than editing, compiling (can take a while, but depends, like you mentioned), and running, and still having a chance of hitting a runtime error even with a static type system.
No, like, imagine something like python and cython
Rython
Iython
kekw klay having to defend dynamic typing yet again 
it is a hill I've died on many times
but as I sank into the ground, someone pulled me up, and whispered in my ear, "typescript sucks"
and I was reborn and kept walking
but my preference of dynamic typing doesn't have to do with this discussion.
const data = {},
coede = client.randomCode(6)
data[message.author.id] = coede;
why i have error in data[message.author.id]
What is the error
I don't think you can assign stuff like that to an object
data[req.user.id] = coede;
^
TypeError: Cannot set properties of null (setting '735874386200100974')
at /workspace/src/routers/dashboard/create.js:17:21
at processTicksAndRejections (node:internal/process/task_queues:96:5)
npm notice
npm notice New minor version of npm available! 8.1.2 -> 8.4.1
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.4.1>;
npm notice Run `npm install -g npm@8.4.1` to update!
npm notice
this is the error
coede is null it seems
no i test it in console code is get me random code like qcr3h6
data[req.user.id] as in your error is not data[message.author…] as you wrote above
Well the error seems to be saying you are trying to set that as null value
The code he shows is not causing the error
this is the same thing becouse ithis is node error not discord.js error
I notice that now
Mmm but what you are doing there could be entirely different so show the proper code
create.js line 17
const data = {};
let coede = "";
const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (let i = 0; i < 6; i++) {
coede += possible.charAt(Math.floor(Math.random() * possible.length));
}
data[req.user.id] = coede;
this is the code
okay are you sure coede is actually what you think it is
yes
Have you loggedd it
yes
Please log data and coede and show us the results
Please add this line, too before logging both vars
data.test = true;
ok
TypeError: Cannot set properties of null (setting 'test')
at /workspace/src/routers/dashboard/create.js:12:13
at processTicksAndRejections (node:internal/process/task_queues:96:5)
npm notice
npm notice New minor version of npm available! 8.1.2 -> 8.4.1
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.4.1>;
npm notice Run `npm install -g npm@8.4.1` to update!
npm notice
error again
What about the log results?
nothing just the error
Wut
const data = {}
data.test = true;
let coede = "";
const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (let i = 0; i < 6; i++) {
coede += possible.charAt(Math.floor(Math.random() * possible.length));
}
console.log(coede)
console.log(data)
i now
Even if that doesn’t make any sense
ok ill try
If that doesn’t work please declare data as non-empty object
For example: let data = { test: "something" };
Will brb
data.test = true;
^
TypeError: Cannot set properties of null (setting 'test')
at /workspace/src/routers/dashboard/create.js:12:13
at processTicksAndRejections (node:internal/process/task_queues:96:5)
npm notice
npm notice New minor version of npm available! 8.1.2 -> 8.4.1
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.4.1>;
npm notice Run `npm install -g npm@8.4.1` to update!
npm notice
again same error
🤔
i try it before this is not giving me error
my luck in code = %0🥲
I feel like smth else is going on here
i dont now this is error with no reason 🥲
Mmmm
const app = require('express').Router();
const { Client } = require("discord.js")
const client = global.Client;
const db = require("../../database/models/user.js");
let data = {}
app.get("/create", global.checkAuth, async (req, res) => {
let data = await db.findOne({ userID: req.user.id });
if (data) return res.redirect("/dashboard");
if (!client.guilds.cache.get(config.server.id).members.cache.get(req.user.id)) return res.redirect("/error?code=403&message=To do this, you have to join our discord server.");
let coede = "";
const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (let i = 0; i < 6; i++) {
coede += possible.charAt(Math.floor(Math.random() * possible.length));
}
data[req.user.id] = coede;
res.render("dashboard/create.ejs", {
code: coede,
bot: global.Client,
path: req.path,
config: global.config,
user: req.isAuthenticated() ? req.user : null,
req: req,
roles: global.config.server.roles,
channels: global.config.server.channels,
data,
})
})
app.post("/create", global.checkAuth, async (req, res) => {
const {
botTOKEN,
ownerID,
verify,
} = req.body;
if (verify !== data[ownerID]) return res.redirect(`/dashboard/create?error=true&message=You need to type verify code.`)
const cllient = new Client();
await cllient.login(botTOKEN)
.then(async cl => {
const tt = await db.findOne({ token: botTOKEN })
if (tt) return res.send({ error: true, message: "The token is already added before" })
await new db({
userID: ownerID,
botID: cl.id,
Date: new Date(),
token: botTOKEN
}).save()
}) // success
.catch(error => res.send({ error: true, message: "The token is invaled." + error })); // error
})
module.exports = app;
this is the all code
whats it
How do I setup multiple status for the bot?
javascript
why am I getting this error?
To me it looks like you are defining data twice so it likely doesn't know which one to use
You define it in a global scope for that file and then inside that function scope
Why are you replying to me with that
no i get it 😅
ill fix it
as of right now it probably thinks you are trying to use the one in that function call
pls help
try it and see
not working
no
wait yes
Then post the error
You are giving it an invalid token when logging in
I added the valid token still it's showing error, I just removed to show you
...
It obviously isn't a valid token if it is erroring and saying so
Unless djs fucked up their login method again
It's working for my bots
Then it is likely you are not providing a valid token Jethalal
So please make sure you are
work thank you
No problem
What are you doing
I am making my command work only for voters
upvote command
using top.gg sdk
I assume that is a top.gg sdk erorr but the looks of it
So you need a api token for it to work
so what I need to do now?
Get your api token and use it
ok
this?
yes
ok
I'm already using it
Yikes didn’t expect he already defined the var
nor did i
Oh I see he has overwritten data with his database result
Hardly to see the scopes on mobile
So it wasn’t an empty object anymore
yep
How do I add more that 1 button to an Action row
By making more than one button and adding that other button
🧠 🧠 🧠
Just by adding a second button object to the array
what is the most preferred way of adding slash commands in python bots...Like there are many libraries, discord-py-slash-commands, disnake etc..
which one should i use
Try out all of them and see which one you like
...
"components": [
{
"type": 2,
"label": "Click me!",
"style": 1,
"custom_id": "click_one"
},
{
"type": 2,
"label": "Click me!",
"style": 1,
"custom_id": "click_second_button"
}
]
Didn’t you cry last time when I gave such an answer, I do remember 
py-cord
o
dont use third party lib that is specific just for slash
it will get outdated and you would need to refactor your code
hmm
thanks for the input-
can i ask here a question?
I have a code for fetching all members with the given role. But it keeps giving me an error like this Cannot read properties of undefined (reading 'members') Here's the full detail of the code.
module.exports = class TestCommand extends BaseCommand {
constructor() {
super('test', 'testing', []);
}
async run (client, message, args) {
const roles = message.mentions.roles.first();
if(roles == undefined) {
message.channel.send("Wrong syntax. Please try again")
} else {
const ListEmbed = new MessageEmbed()
.setTitle(`Person who have this ${roles} role is:`)
.setDescription(message.guild.roles.cache.get(role => role.name == roles).members.map(m=>m.user.tag).join('\n'))
.setColor('RANDOM')
.setTimestamp()
message.channel.send({embeds: [ListEmbed]}).catch((err) => {
console.log(err)
message.channel.send("Something went wrong")
});
}
}
}
at Api._request (C:\Users\aweso\Desktop\Mursy\node_modules\@top-gg\sdk\dist\structs\Api.js:76:19)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Api.postStats (C:\Users\aweso\Desktop\Mursy\node_modules\@top-gg\sdk\dist\structs\Api.js:99:9) {
response: Response {
size: 0,
timeout: 0,
[Symbol(Body internals)]: { body: [PassThrough], disturbed: true, error: null },
[Symbol(Response internals)]: {
url: 'https://top.gg/api/bots/stats',
status: 524,
statusText: undefined,
headers: [Headers],
counter: 0
}
}
} ```
I just received this error
ok was just curious first time I ever received this error and wasnt sure what was going on
Is AI based toxicity filter a good idea of a bad idea?
this is a good writeup for why it's not a good idea https://github.com/almostSouji/sentinel
Hmm No I have a custom AI
then it's definitely nowhere as good as perspective
It uses perspective

i do thats why I am wondering if its a good idea
how do you have an AI that uses an existing machine learning model API but is also trained by itself
its not a good idea 
I think if you have an ML model capable of understanding the nuances in everyday conversations without being overbearing you need to create a business not a discord bot
Its not a single AI thats the point.
Its made of 2 AI
that's like an actual billion dollar problem
thats...
2 AI does not fix things
it generally makes it far worse
because then you have two places where the computer can loose it's mind
the other AI is only few kb and is capable of learning on the fly from the main ai
Which helps decrease performance costs and increase response speed
2 AIs be like
if (await ai1.isToxic(message)) {
return yikes()
}
if (await ai2.isToxic(message)) {
return yikes()
}
that does not work like that
like I don't wanna rain on your parade but the thing you're trying to tackle is an incredibly difficult problem to solve correctly
but if all you wanna do is learn more about ML and use it on a bot then go for it sure
No it more like
if(ai1.isToxic(message)){
yikes();
}else{
if(ai2.isToxic(message){
ai1.learn(message)
yikes()
}
}
this is the general gist
but far more complex
so if ai1 doesn't understand the nuances you're screwed
that
then you have good old filtering
Okay, so basically you're using 1 AI to train another AI via Q learning?
to back that up for 50% 50%
good old filtering has never worked
Nope but it does do its job when all else fails
and the AI is uncertain
in a nutshell
yes
also you can't really have that because you're relying on perspective to be right, which often gets things wrong because it's designed for long messages not short texts
and you don't have any way of knowing what message is a false positive and what isn't
Thats my my version is trained on like 128 million discord messages
your version doesn't run until perspective runs
flagged by other ais as toxic
Does Discord know about that data scraping
i didnt scrap
128 Million Discord messages should be about what? 50-60GB of data or so.
I mean it's a cool project but it won't ever become a reliable tool because the problem is so crazy difficult and I don't think you happen to have a phd in artificial intelligence
so it not really my problem https://www.kaggle.com/jef1056/discord-data
no plus its more of a side feature to my bot
Put that into an AI and thats about some 30GB model
atcaully its 4gb
along with reddit , movielines wikipedia
new article
movie reviews
etc
the problem is unlike a side feature like a dice roll command, this feature runs quietly in the background, incorrectly flagging conversations or letting obvious cases slip by
That doesnt sound right, if you've fed it some 23GB of data your model generally should be about the same size or maybe just a little smaller
because you're creating word vectors with NLP like that
Which realistically generally produces more data than the original text if done correctly
This can be solved by adding context allowing reporting of flase positives and flase negatives
if even a big company can't get it right by flagging conversations about LGBT topics incorrectly then like I can't imagine you could get this to work without either being useless or false flagging too many things
also, you fundamentally shouldn't be using Q learning for this task
I am using tansformer so the nlp is pretrained and is like 128 gb but its not my problem
"adding context" is like the most difficult ML problem lol
You need to download said transformer though
which regardless Is probably going to be far too slow to keep up with the rate of messages unless you have some insane hardware
also I feel like users need to opt into having their messages analyzed in order to improve the model and I can't imagine discord would let you do that
also how are you planning on adding context if you're using a pretrained model
No, you can host it on huggingface and use its api
No like the user is given the choice
to report
Its done in the training of the model
You think people will willing give correct information to your AI when asked?
idk man this sounds like a cool project to learn more about ML but not something that could even come close to being accurate in the real world. If any random bot developer could've solved this problem it would already be a successful commercial product 
also Hugging face charge $10 per 1 Million characters
Hmm no like it will be sent to a channel and then I can decide if to train or not to train
so that is... Alot of money if you plan on having hugging face host / run it
if you obey rate limits and use second AI
then you like make only 100 querys a day
to it
okay, but err. That is probably breaking some GDPR or atleast discord tos
wait 100 queries a day? what


You do understand though that you cant have an ai train another ai to be better than itself for this case though right?
Hmm no like when user repot it
A message is sent that this message is being logged for inspection by a team member and if it passes it will be updated
And if you're not using hugging face then you need to run the model somewhere
the big model needs to be on huggingface
yes... But a smaller model is generally less accurate
it can
I guess if the goal is to create a worse perspective api then you could maybe get there with enough training
Accurate AI depends on 2 things:
- How accurate the training data is
- The amount of accurate training data there is.
but perspective itself is not good enough to be used for chat messages. So why would you even have that as a goal
if you're making a smaller model then realistically it's going to be far worse than the big model
but even then even if the model is semi functional
you cannot seriously run it on heroku or repl.it
Well no
you need 3 ais for best one
memory->causal -> general
maybe if you did like... 3 messages an hour
instead of potentially hundreds of messages second
that sentence doesnt make sense
this isnt some sentient being. Its just NLP. NLP that traditionally requires an insane amount of correct and accurate data and alot of resources to be used for the task you're talking about
I mean the best way for you to find out is to try and realize how difficult the problem space actually is
the memory ai is based on 2 thing an learning ai and an aiml bot
Causal ai is about 2gb (and can be hosted on google app engine for free), this is good for normal user convo like how are you etc
general ai is massive like 4-8gb this is when the user ask something really wierd like my socks smell funny

5 minutes into machine learning: "I can't understand why noone hasn't done this yet"
5 days into machine learning: "I understand why noone has done this yet"
Fun fact the NLP are modelled after the human brain
with attention layers etc

Yup it took me one year to make an ai get the results i wanted
an d i had made this
monstorsity
well a good basic version
sounds like you're a pro dude, go and create that bot
now i am fine tuning
what's holding you back
to make that I did have to stop my current training of AI
toxicity detection as a service + heroku/replit in the same concept is just
what could go wrong
I will wait for verification wait for a few days to see demand etc , then add ig
I mean my only warning is, I think you underestimate this
yeah like significantly
Im pretty sure just the word tokenization is enough to put significant strain on the system at larger amounts of servers
even if you use fast wordpiece
there are certain fields of ML where you could piggyback off existing tech like face detection and recognition etc but the toxicity recognition thing is still a field that's developing and unless you're making fairly groundbreaking research I can't see this becoming usable outside of test cases because of how much it impacts conversation when it's wrong
considering how wrong or inaccurate the existing technology that runs on proper infrastructure and not on repl.it is
Its hard enough making a naive search engine be relevant let alone trying to detect toxicity in languages
Well I do have a small beta version of the toxicity recognition running in like 15servers to see load etc
Lol
I aint
Eh i am split on adding it to the main bot
Performance is amazing
But I am afraid of demand after verification
mmm General rule of thumb, If your performance is amazing your model is probably not very accurate
Even on the image detection side it's still pain
I'm living with the pains of this as we speak
What are you doing with it 
https://i.imgur.com/rjEVTgl.png I'm trying to make a command where you can search for a guild through its guild name. but im getting a return of member not found when i use "message"
Can someone give me some tips with this error?
and yes its in discord.py cause stupid school 
Why... Why do you store each user data by their name / message content??????
you know how insecure that is????

ik but its just for my school project thingy then i can work on making it more secure later you know 
nice
It better than all other alternatives but i messes every one in 50 or so.
Which is way better than almost all other ones which miss almost all
as well as i don't really know what else i could do
sounds like incredible cherrypicking
Make it secure first then.
Trust me you may forget until its too late
As someone who has worked with Google to build AI's, I doubt yours is better than "All other alternatives"
also why dont you use fstring
Security first
cause my brain is stupid
Its ain't but on discord yes. Like look at mee6 yagpdb auto mod
Like if it manages to some load of the admin
Its worth it
Its not meant to be perfect
depends on how many false positives 
they dont use AI they use defaulto is word in x
no idea how though 
That the whole point
using AI is risky tho
I mean does your AI respond correctly to CJK languages?
ok so what are you trying to do?
I keep getting ignored lmao
Word in x is even more false positive.
Plus you can be super toxic with using any of the bad words this can detect kt
roles.members is undefined
im making a command that searches for the desired guild name that a user wants to search for but it returns me with https://i.imgur.com/HyIgcNC.png when i want to search for the hmm guild
It doesn't do anything it stays netrap
You need user id
so hmm is the member or the guild name?
guild name
Does that mean is the bot cant find the role or what?
basically
since im formatting it with json files like that
But im actually using an args, then im pinging the role :/
Are you pining the user when using the command
you should really be using at least a database like sqlite
json will just give you problems in the future
i think it is just for school project
are those "guilds" actually discord guilds? or something external like an mmorpg?
dont use json as a database 
okay @earnest mural so you want to search the name through the same guild command, correct?
unless it doesn't understand nuance in conversations in which case it creates even more work for the admin
also different communities have different definitions of what toxicity is
some might say it's swearing, some might say our city our ciiiittyy
You can modify the ai using different tags
And thresholds
but it's not a linear scale
yes
I'm curious if this is even possible to automate even theoretically
cuz there are just so many factors. Language, culture, strictness, subtext, memes
mmorpg
the error pops cuz u use hmm not in the right field
how the hell does anyone automate that even with the most brilliant researchers out there

it is assigned to member instead of message
Its impossible
thats why the error tells you "Member 'hmm' not found"
ohhh
so yeah I guess the goal is minimizing false positives and not maximizing detection
how companies like https://twohat.com/ do it is beyond me
cause im thinking about either pinging a user or searching the guild's name would be able to find the information of the guild being searched
Exactly
They must have massive models
they probably train them with decades old books, texts, movies and conversations
because everything is offensive today

you have to go back in time to actually listen to proper gentleman-like speech
lmao
....
there's just too much context involved
humans do a terrible job already for something that we should be better at than machines with what we know about ML today
and yet
True
thats the beauty of language, its basically turing complete, you can say anything and make it mean anything with words, intonation, context, etc
It did never work
The ai did be confused.
The ai needs to have the latest data
buffalo buffalo buffalo buffalo buffalo buffalo buffalo buffalo
So your AI is useless to anyone who doesnt use whitepsace separated languages?
Well yes but if I wanted to support other one I will need to make a sperate ai
Its better for many reasons like less soze
Size etc
but that does mean I can just be toxic in some other language and the bot wont notice
also you shouldn't really need to have an entirely separate model for each language, you need a good set of data and a good tokenizer sure. But generally.
Then the size of the ai grows exponentially to compensate
yes
but you get that regardless
the additional downside you get from splitting them up is then that they cant understand compound sentences which contain diffrent languages
and that defeats the purpose of your entire ai
because ultimately you're trying to detect sentiment
you are banned for toxicity
is there any example code for like voting in d.js v13
noooooo
you said everything is offensive? how dare you that is offensive \s
depends on what you want it to do
If you want to receive votes, you're in luck, because that doesn't involve Discord.js.
See https://docs.top.gg/libraries/javascript/#webhooks for more info
const express = require('express')
const Topgg = require('@top-gg/sdk')
const fetch = require('node-fetch')
const app = express()
const webhook = new Topgg.Webhook('me password')
app.post('/vote', webhook.listener(vote => {
console.log("User with id - " + vote.user + " Voted!")
let value = JSON.stringify({
embeds: [
{
title: "Voted!",
description: `<@${vote.user}> (${vote.user}) Just Voted For \`Disminer!\`!!`,
color: "8388736"
}
]
})
fetch("https://discord.com/api/webhooks/me webhook", {
method: 'POST',
headers: {
'Content-type': 'application/json',
},
body: value
}).catch(e => console.log('Error occured while posting webhook : ' + e))
}))
app.listen(3000)``` is what im using rn, it was a template and isnt working
are you sure that webhook sould be correct
formatting doesn't seem right
does console.log("User with id - " + vote.user + " Voted!") log anything?
the link is correct, im using the auth path in the first one
nope
yes
oh
where is your bot hosted?
then thats probably the problem, one sec
witherhosting
so url would be http://myip:3000
yes, assuming your hosting doesnt do any kind of routing or proxying
const express = require('express')
const Topgg = require('@top-gg/sdk')
const fetch = require('node-fetch')
const app = express()
const webhook = new Topgg.Webhook('me password')
app.post('/vote', webhook.listener(vote => {
console.log("User with id - " + vote.user + " Voted!")
let value = JSON.stringify({
embeds: [
{
title: "Voted!",
description: `<@${vote.user}> (${vote.user}) Just Voted For \`Disminer!\`!!`,
color: "8388736"
}
]
})
fetch("https://discord.com/api/webhooks/me webhook", {
method: 'POST',
headers: {
'Content-type': 'application/json',
},
body: value
}).catch(e => console.log('Error occured while posting webhook : ' + e))
}))
app.listen(pterodactyl assigned port)```
then http://myip:pterodactyl assigned port
ou yeah
i had same issue yesterday
yeah
still nothing
could it be a code problem posivly?
ima try the official example
what is your ptero ip and port?
gonna see if its publicly accessible
feel free to delete after
wait let me try smth
kk
did that do anything
nope
let me try smth first
alr
Repost. Please ping 🙂
the webhook discord url supposed to go here right
ah
works now ty!
Hey, i want to make a music bot but like i don't want to use youtube cause of the issues and etc
i am not sure if you can stream spotify songs via discord bots or not cause ig i read somewhere that you can't
so i was wondering how do the bots like hydra and etc play songs? like is there a platform that allows us to stream songs without downloading them and etc?
there are other platforms like Soundcloud and Bandcamp that you could use as substitutes for YT
playing from Spotify isn't possible and even if you could get pass the DRM protection it's illegal
most bots use lavalink/lavaplayer
which comes with support for several streaming services built in
Is there like a library I can use in python to stream them? I don't want to download the songs
Oh yeah I read about it somewhere before but I wasn't sure if it was true or not
install lavalink and use a wrapper
Oh sorry for my lack of knowledge but I can use lavalink in python?
the lavalink server is in java, you have to install it on your VPS/dedi
I used to see it connected a lot with JavaScript tbh
there are wrapper in many languages
https://github.com/PythonistaGuild/Wavelink is one of them
Wow thanks lol
Do you use it? So like if I struggled with it may I ask for your advice again?
I am outside rn so I can't really test it
I don't use it, I only used Shoukaku and that was in node.js
Ooh okay tho thanks for responding to me
What about erla
I do use python lol
you haven't provided any code, it's difficult to say what you're doing wrong
this function
this use
console.log(await client.sendFiletoWeb())
this output
function output is before log console.log() when the function is running
because you have a setTimeout that schedules it to be run after 5 seconds
unfortunately there is no other way to find out if the result is out
or i don't know
setTimeout isn't blocking
you can return within the setTimeout if you wish, or you can use a sleep function that uses promises
why do you even need the timeout there?
analyzes and outputs the file after uploading it to the site



I think

