#development
1 messages · Page 1748 of 1
even cleaner approach
Here's what I meant, I have a schema that stores my boolean, I just wanna know how to correctly store the code and wether it was claimed.
for example, you have 10 coins stored, you add another random value to the 10 coins
if(condition) {
...
return;
}
//the code got to this point if the condition didn't pass
you avoid going down an indentation level
which produces cleaner code
I already know this, both ways work, so i'm fine.
👀 whats with the obsession with cleaning up the code.
better choose the cleaner version, trust me
also, that's twice as much boolean comparations as necessary
Your storing a numeric value into a boolean 
const mongo = require("mongoose")
const Schema = new mongo.Schema({
Guild: String,
Code: String,
Claimed: Boolean,
})
module.exports = mongo.model('code', Schema)
ahh
dont think he is worried about user right now
^^^
hes/shes working on the code generation
but he wants to increase whoever uses the code's balance by 1-10 coins
you cant do everything at once
he needs to get code generation working first to do that
well
const data = <mongoClient>.findOne({
guild: message.guild.id
})
if(!data){ /* do something */}
if(data){
if(data.Claimed){
// do whatever you want
}
}
still not helping, hes working on GENERATION
yeah, ik, I'm just addressing the original question
the code generation
If you look at my code I already have this. I don't need this.
well I don't understand what's wrong then, it seems completely fine
I'm asking, how do I CHECK if that code is claimed and store it into my database.
you see if its true or false
inside else, set the Claimed prop to true and store in the database
then get the user's data, increase amount of coins and save to database
I don't think you guys understand. It's not checking anything, because I don't know how to store it in the database.
so you don't want to CHECK, you want to know how to STORE it in first place
I know how to store the guild and code, I just don't know how to store if it's claimed or not.
you do
await data.save()
👀 isnt that what ive been saying.
I know all of that
you were saying about the code generation
confusing
reword your question plz
hes looking for find one and update
I wanna know how to store wether the code is claimed or not.
that's what
👀 if it happens down the line data wont exist will it?
supposed to be done
data.Guild = message.guild.id
data.Code = code
data.Claimed = ???
data.save
My error says missing semicolon for
message.delete()
I don't know what to store in claimed
true
store true in claimed
what lang?
since it is variable type boolean
wouldn't it be false at first, and then if it's claimed I have to set it to true
yeah it would be false at first
ok, now I understand
I'm asking, in what event do I run this code to store this?
what you are tryna do
you store true, check it and then after checks make it false again
Ok let's say someone does >Claim {Code}
How do I let the database know that the code was claimed?
That's all i'm asking
store it in a different array of claimed codes
claimedCodes: [string]
I wouldnt make it an array personally. I would have a different document for each claim code, giving you greater control over each one.
ttl and whatnot
I was thinking
if(message.content.includes(code)) {
data.Claimed = true;
data.save()
}
{
"languages" : ["English", "Spanish"],
"translations" : {
"THE_SUM_IS {
"english" : "The sum is",
"spanish" : "LA suma se"
}
}
}
if the codes are idiosyncratic from one another I don't think it would make a difference depends
bruh
Would this work?
lang as in "programming lang"
until you try it out
JSON
Language?
bruh
Programming language
javascript, java
c#, python, c++, golang, rust
Javascript/discord. Js/discord.js-commando
then it shouldn't cause that error
js doesn't require semicolon
show a bigger snippet of the code
unless eslint 
in php
could u show the error too?
I type the exact copy of the error
No I’m out, Java and php life for me
you write in php??
shit dude that's all you had to say

you had me in the first half ngl
One message removed from a suspended account.
One message removed from a suspended account.

One message removed from a suspended account.
One message removed from a suspended account.
Jokes on me I do Java 90% of the time

One message removed from a suspended account.
people who use glasses
One message removed from a suspended account.
yo so like
wanna make a php irc?

Actual pogging
One message removed from a suspended account.
One message removed from a suspended account.

One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.

How would I loop through an array in order 0-inf
language?
For index loop
javascript
Or foreach
What
heres a ton of options, with examples. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration
let i = 0;
while (true) {
...
i++;
}
well, there're infinite values between 0 and inf
why does this code keep setting off discord's ratelimit?
I said inf as an example
for (let i = 0; i < <array>.length; i++) {
...
}
Hi, seeing the pinned messages i just wanted to post that humble bundle have a massive bundle on azure if anyones interested in hosting from that
https://www.humblebundle.com/books/azure-cloud-computing-bundle-springer-books?hmb_source=&hmb_medium=product_tile&hmb_campaign=mosaic_section_1_layout_index_2_layout_type_threes_tile_index_3_c_azurecloudcomputingbundlespringer_bookbundle
when books started costin 1000 dollars
I know, but it's information
who buys coding books nowadays 
when pieces of paper glued together costed 1000 dollars
can I do then on a for loop @lyric mountain
must have 100,000 pages or the book's cringe
yes
how
do you mean like you want to resolve a promise inside the loop?
When the loop is finished I want to log that
^
can just put it under the for loop, unless you do something async inside each loop(afaik)
yeah, iteration will be stuck inside the for loop until it finishes or you break it
anything after the loop will only be ran after it finishes
async function addRow() {
try {
if (!sheet.title == date) return sheet = await doc.addSheet({ title: date, headerValues: Headers }).then(async () => addRow());
for (let i = 0; i < hosts.length; i++) {
ping.sys.probe(hosts[i], async (isAlive) => {
await sheet.addRow({ Time: dateFormat(new Date().now, "h:MM:ss TT"), Price: 'N/A', Item: 'N/A', Site: host, Status: isAlive ? 'Alive' : 'Dead' }, { insert: true });
}, { timeout: true });
}
await sheet.addRow();
console.log("Done");
} catch (e) {console.log(e); }
}
if your looking to do promises, look into promise.all.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all
it will not resolve until all your promises resolve.
may be a bit easier to understand/do
I just did promises
that is what the image was
and it wasnt in order
async function addRow() {
try {
if (!sheet.title == date) return sheet = await doc.addSheet({ title: date, headerValues: Headers }).then(async () => addRow());
await Promise.all(hosts.map(async (host) => {
ping.sys.probe(hosts[i], async (isAlive) => {
await sheet.addRow({ Time: dateFormat(new Date().now, "h:MM:ss TT"), Price: 'N/A', Item: 'N/A', Site: host, Status: isAlive ? 'Alive' : 'Dead' }, { insert: true });
}, { timeout: true });
await sheet.addRow();
console.log("Done");
})).then(() => {
await sheet.addRow();
console.log("Done");
});
} catch (e) { console.log(e); }
}
oh, i see.
are you using a library which has access to inserting multiple rows at once?
google sheets api(what i presume you are using) allows the insertion of many rows at once.
since its just one call, it all happens in order.
👀 okay, then youll need to make your own promise queue.
and why doesnt mapping it work
you are mapping promises, so the actual promises may resolve out of order, even if they all happened in order
thats just the nature of promises
you cant lol
for loops also have this issue iirc.
wait nvm which are we talking about
https://stackoverflow.com/a/42064701
^ an example of a promise queue
so a for loop wouldnt work?
for can work, for each cannot(iirc)
https://stackoverflow.com/a/56713601
this are e-books so you pay for bytes that cost so much
bruh
just a heads up, it will be slower this way. if your doing 30+ rows, it will take longer.
since you have to wait for each api request to complete, your just waiting for awhile.
👀 what library are you using.
Why don't you just use addRows()
thats what i suggested awhile ago 
It's google-spreadsheet
I would still need the loop
For?
and it would still be out of order
It won't
to loop through all the sites and add the messages
the out of order is because of promises, not because of the methods used.
Construct the array with the for loop (since you want it to be async) and pass the array to the addRows() method
One API call
give me a second to find where the hell it is listed in the docs
const moreRows = await sheet.addRows([
{ name: 'Sergey Brin', email: 'sergey@google.com' },
{ name: 'Eric Schmidt', email: 'eric@google.com' },
]);
the example is that simple.
you just pass it as the array of objects
Literally under the addRow() method
yeah the docs are shit on the github you cant find anything
https://img.terano.dev/yR3t4x7B so I have a function typed as boolean | Promise<boolean> yet im not getting an error from returning a string https://img.terano.dev/1yZ1iFcr anyone have any idea why this could be
One message removed from a suspended account.
cc @opal plank #development message
One message removed from a suspended account.
then you know c sharp
I know a touch of c# from years ago.
One message removed from a suspended account.
One message removed from a suspended account.
I really just havent been deving as much as I used to do, so not spending as much time learning new things.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
In python how to make a bot leave a server?
Does someone know how i display the number of servers my bot is in? 
When I try this my bot displays 0
Discord.py btw
thx
it is guilds
👀 nice one star
ez find
thxxx

Get the server and use .leave()
Can I do it outside of server?
?
use client.get_guild then use await (serverthing).leave()
const Discord = require("discord.js");
const config = require("../../botconfig/config.json");
const ee = require("../../botconfig/embed.json");
module.exports = {
name: 'meow',
category: "Games",
aliases: ["cat"],
cooldown: 2,
usage: "meow",
description: 'random kitty',
run(message, args){
message.channel.send(randomMessage);
}
}
const messages = [
"meow",
"kittie's",
"Lucky Meow 777",
];
const randomMessage = messages[Math.floor(Math.random() * messages.length)];
this looks right
console.log the message and see if it's actually a message or something else
also
How do I fix my error
This is the error I got
randomMessage will always be the same
the ID you provide might not be correct, or the bot is not in the guild
oh yeah
(ctx, id: int)
^
Thx solved the problem
Thank you. That works.
Yup that's what I did and it works now.
hey! How do i attach a variable to a message.attachment to eventually send that variable to a channel?
i want to save a user's sent image, to immediately redirect to another channel
re-upload or just send the link
heh?
do you want to re-upload the image or just send the link to the image
nvm, i already got the solution. Message.attachments is an object with a url property.
so i will just use that to send. Thanks
it's a collection
a message can have multiple attachments
ironically the only platforms that support it are mobile lmfao
Hi i am new here like development
hello new here like development, i'm dad
what is there to be good at
have you tried reading the docs?
Yea
All
Do you want to convert a callback into an async function?
const isAlive = await util.promisify(ping.sys.probe)(Hosts[i], { timeout: true });
What's wrong with the statement?
Its null
isAlive
The use of util.promisify looks correct, but the context in the expression is ambiguous. We don't know what ping, ping.sys.probe, Hosts[i], etc. is
Do you have the link to the documentation for .probe
hey! I am trying to get a due date in djs, but it is returning me numbers: Due date: 1621065462601 Code: ```js
const currentday = new Date();
const test = currentday.valueOf() + msseconds; // which was set to 12h
new Date(test)
owh what really?
There's an asynchronous alternative built into the package.
var ping = require('ping');
var hosts = ['192.168.1.1', 'google.com', 'yahoo.com'];
for(let host of hosts){
let res = await ping.promise.probe(host);
console.log(res);
}
Your current answer is incorrect because util.promisify acts on the callback as if it's the last parameter of the function, but probe uses the second argument (preceding options) instead.
How do I make a topgg stats command?
Depends on what you want to do with the stats
If you want to display details on a bot, you'll need an API key (generating for each bot) and hit the API to receive bot details.
See https://docs.top.gg/api/@reference/ for more information.
The solution is built right into the library—asynchronously process the probe by returning a promise instead of passing a callback.
You don't need util.promisify
Sum it up i dont understand
lol
TL;DR - Learn to read the documentation.
That doesnt return if the site is up actually
wat
Test it
res should be a boolean.
You're the one using the library. You should be the one to try it out.
Our answer was about using the library asynchronously—not if the ping actually worked.
which like
ah
you really don't need the library anyways
you can use node-fetch and chances are that one of your deps already uses it
you dont...
So it would loop and unshift the array
Hey guys! I'm trying to set up a dm command with a preset message, does anyone know how to do it?
just await it
why do you wanna dm 🤔
Before it added to the speeed
???
you generally shouldn't interact with users unless they started the interaction first
Basically, a preset message that states "Your inactivity request has been accepted.", it's for a private server that involves inactivity requests from users.
I figured it out. @vivid fulcrum
what is the opposite of array.push?
pop
but that removes everything except the last element
no it doesn't
i need to remove one specific element
otherwise it wouldn't be called pop
Development
``const plants = ['broccoli', 'cauliflower', 'cabbage', 'kale', 'tomato'];
console.log(plants.pop());
// expected output: "tomato"``
yes
because pop returns the popped element
read further than the first two lines
but if you're looking to remove a specific element and you're unsure of its position
you can use findIndex and then throw whatever findIndex returned into splice
findIndex can return -1 if the element isn't found though, keep an eye out for that if you're going to use it
is it possible to connect two webhooks to a topgg server page, a faucet that checks who's voted and a vote reminder that checks who's voted
im fairly certain you can only use one
but why would you use two anyways
make it a monolith
a single listener that does both things
because the vote reminder has already been made and the faucet hasn't
why topgg no allow multiple webhook??

thats pretty standard for webhooks(one per application)
is there a specific reason
you can mirror-cast it tho
I can count in my hand services that allow multiple webhooks
generally its up to you to handle everything after the webhook. afaik thats pretty standard with api's and webhooks.
interesting info
Dang Woo ur a moderator now? congrats
like vote for x server, get rewards for another?
like we just want to reward server voters
vote for our server get rewards for our server
thats not external, so thats fine.
so vote for x server get rewards for y server is not allowed
thats not ok, yeah.
thanks
I'm having trouble at making this
It is basically to make the bot disconnect if the server song queue is empty
.dispatcher is null, so you may want to look up the type of .connection
thanks
g!help
Jokes the problem is that when the bot is playing music it randomly stops and the commands won't work anymore
My code is this
if (error) {
message.channel.send(`I got an error. Bruh. How are you even getting these?! \n Error: **${e}**`)
}```
says error undefined..
😐
you should consider using try except
like this?
try
{
//code
}
catch(Exception ex)
{
//code
}
//this is optional...
finally
{
}
When you do this it is cached, so I usually tend to stay away from it unless a user has input, because people will try to break anything.
except he's using python
I'm guessing actually
wait actually not
but that's d.
py syntax
anyway
I am not sure what he was using, he should kinda look it up for himself though. They aren't hard to learn, but useful for user input etc...
@earnest phoenixfirst, python comments are # not //
second, thats js syntax
py is try/except
js is try/catch/finally
didnt look further, but either you or that other guy legit did an oopsie
and a big one at that
this is 100% js code
@earnest phoenix so, yeah, you tripping hard mate
Yea Js looks a lot like C# syntax wise
give more context as to how that error is coming
cuz it may be an object
js considers an empty object truthy
module.exports = {
name: 'poll',
execute: async (client, message, args) => {
if (!message.member.hasPermission('ADMINISTRATOR')) {
return message.channel.send("You can't use that! You **have** to have **Administrator** prommision.");
};
const Discord = require('discord.js')
const pollchannel = message.mentions.channels.first()
if(!pollchannel) {
return message.channel.send("You didn't provide a channel... \n Bruh")
}
const question = args.join(" ").slice(21)
if(!question) {
return message.channel.send('You did not provide a question.')
};
const polle = new Discord.MessageEmbed()
.setTitle('New Poll')
.setDescription(`**${question}**`)
.addFields(
{ name:'Author', value:`${message.author}`, inline:false},
)
.setColor('RANDOM')
let msg = await pollchannel.send(polle)
await msg.react(':thumbsup:')
await msg.react(':thumbsdown:')
message.channel.send(`New poll had been created in ${pollchannel} by ${message.author}`)
//////////////////////////////////////////////////////////////////////////////////////////////////////
//ERROR
if (error) {
message.channel.send(`I got an error. Bruh. How are you even getting these?! \n Error: **${e}**`)
}
//ERROR
//////////////////////////////////////////////////////////////////////////////////////////////////////
console.log("Poll command had been ran..")
}
}
wait- wait wait wait
I should not require in there
I am confused, where do you set 'error' at?
you should NOT require there, but regardless
yeah you need to properly catch stuff
in a try/catch block
actually
it'd be bad to do that. properly catch each individual promise
Hi Airwin
<promise>.catch((e) => {console.log(e); error=e});
log ur errors and set it to a variable in the code
then run that messgae.channel.send() thing
Hi Liion
Hi
o
thanks
still doesnt know what error is.. when I put error on promis..
wait
how do you make it a variable?
Uh i have an error in vote
@drifting shell so wanna join me with the IRC project? 👀
i don't mind collabing 👉🏻👈🏻
making an IRC
Ah

@pale vessel do you have much experience with slash commands?
aah mb for ping but i got this error
Traceback (most recent call last):
File "C:\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Python39\lib\site-packages\discord\ext\commands\core.py", line 1348, in invoke
await ctx.invoked_subcommand.invoke(ctx)
File "C:\Python39\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Python39\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ValueError: parameters are of unsupported type
wrong parameter type
can't help much more than that
hm ye, i just saw something related to this on stack and said to add a , without the space
:\
class Square {
isEmpty = true
piece: Piece | null
constructor() {
this.piece = null
}
}
const square = new Square()
if (!square.isEmpty) {
const piece = square.piece
// Here, piece is of type Piece | null
// How do I make sure that it always return a Piece when the square is not empty
} else {
// Here square.piece must always be null
}
why not just omit isEmpty entirely
and just check if the piece is null
if it's null it means it's empty
yeah, but I want it to be a little bit easier to read and understand
if you really wanna be verbose and go with the isEmpty route, make isEmpty return a boolean based on the value of the piece
I could make it a getter, but still the same problem
it wouldn't be
because isEmpty is directly coming from the comparison on the piece
yeah
you're now sure that it's going to have a value
the compiler isn't smart enough to understand that
square.piece is still a nullable value in the if block. which I dont want
which is why i suggested this
why
you're overcomplicating
you can let typescript know it has a value by using !
but again just omit isEmpty if you want clean code
if the square is not empty, than there must a Piece not still Piece | null, in the if block
i understand lol
the intellisense isn't smart enough to understand that piece has a value inside of that block because you're using isEmpty
however
if you omit isEmpty and just check the piece directly
type problems will get fixed
then intellisense will understand that it has a value inside of the if block
but there is a way, which some react library do.
Like if we add prop to an JSX.Element it may or may not require other props as well, depending on the initial prop we provided.
the required props, changes dynamically
So how can I use that, here
^
i don't understand why you're being so stubborn about not checking piece directly
it's a cleaner and a more "proper" way
alternatively use the assertion operator
TypeScript 2.0 Release Notes
this produces ugly code though
but it's exactly for your use case
Does C++, C# also has this problem?
they don't
Unless you plan on adding more rules for what counts as "empty" for your square class, you should be directly checking if piece is null as cry has said.
You're making your program more complicated for trivial benefits.
c langs are typed at their core, null isn't its own type, it's a value
you'll just get an exception if trying to access something on a null object
I want to know, if dart can solve this problem.
Have u used dart, to compile down to js?
Dart has implicit and forced nullable casting.
Forced is the same idea as the ! assertion.
Implicit is being able to do something like: ```dart
int? maybeFive = 5;
if (maybeFive is! null) {
// ... => maybeFive is int; not int?
}
Though you probably don't need Dart.
Just use the solution cry suggested
or force cast it
hmmm, ok thanks
Nope
which method is more efficient and recommended to populate an array, with some values?
function populateMethod1(size) {
const arr = [];
for (let i = 0; i < size; i++) {
arr.push(/* Some value of choice */);
}
return arr;
}
function populateMethod2(size) {
return Array.from(Array(size), (_, i) => {
return /* Some value of choice */
})
}
Well, loop is the fastest
:)
down
is this good enough
Looks good
cool
How would I make it so my bot can single out a mention in a series of mention.
Like for the bot to add a role to every user that I mention in a single message
Discord.js^
@errant hornet args.split(/[, ]+/);
Yes but how would I split the mentions?
how can i change the font color in my bot panel?
css is love,css is life
Yeah
Better to learn yourself, nothing better than doing it yourself, you feel so much better :)
@runic gyro https://www.w3schools.com/css/css_text.asp
Then you’re doing something wrong
How would I remove a character from a response, like if I wanted to have just H from inside [H]
use string.replace() with regex and the global modifier or string.replaceAll()
sort your guilds by member count and map the sorted collection
the command itself is a privacy breach of some sort, you probably want to make it a opt in
What must I change so the command can be run in guilds and dm's?
! I'd hope you know what a ! would mean in that line of text.
!!!!!!!!
if (!!!!!!!!message.guild)

I will keep it an owner only command
and will only run in private admin only channels
don't worry bout that
No I dont😭
İt means not
I do suggest you learn the basics of javascript before attempting a bot (My opinion) but ! = not in Javascript.
So with that little bit of knowledge, it should assist with what you're trying to do.
do you have strict checks enabled?
oh you asked this 200 years ago
200 years? damn I'm old now
Woah
ur now ancient
the message.channel.send part got me
but yeah I blame it being 1am of my time since it clearly all js starting from string format to code block itself
I want my bot's website to automatically change the number of servers and number of users by itself using the discord api, although the code for the site is written in html css and js, any way possible to do it?
the site is https://oxyy.me
it can be done in many different ways
the easiest way is probably to have a small server inside the bot that responds with the data when you send a request to it, and have the website send a request every 5-10 seconds
Or you can send a post request to your website from the bot with the new guild count every time that changes
Or yeah every delta time
Whatever you want, if it becomes larger do it delta time
soo i created another bot and somehow the command wont work
is there problems?
the prefix is this
first of all, you're not doing anything with the prefix
that code literally checks if the content of the message is ping
kk got it
tysm for the help
oh
ok i got it working now
Can a bot use animated emojis?
yes
Yeah
Nice
But that emoji you need to add your server then copy the id
Yes ik

For a memebot (discord.js) is it possible to filter videos and only send photos and gifs from the subreddit?
what does this do?
yes
Umm How?
you could try apis that can filter searches on https://npmjs.com
wait how do i do this
Programming language.
no lol, programming language
discord.js?
yea
client.user.setActivity('anything u want to type', { type: 'WATCHING' })
y hatos a text editor lmfao
ah
if you want it to stream
<Client>.user.setActivity("something",{type:"STREAMING", url:"twitch.tv/pewdiepie"})
how can you not know what programming language you're using lol
i just started tho 
its fine, I mean although you could learn a bit of js or nodejs before attempting discord.js
Yea
saying it like that makes discord js sound like a programming language, when it's just a library
got it working after an hour
How can i sort %all% to the end
My array of Object
[
{trigger:"!hi"},
{trigger:"%all%"},
{trigger:"!help"},
...
]
array.sort(x => x.trigger === "%all" ? 1 : -1);
1 would bring the element to the back and -1 would do the opposite
i made a def in a cog file, but when using it it is givivg an error that Unresolved Reference
My code:
with open("about.json", 'r') as f:
users = json.load(f)
return users
@commands.command(aliases=['Aboutme', 'ABOUTME', 'AboutMe'])
async def aboutme(self, ctx, *, information):
users = await get_about_data()
user = ctx.author```
error on second last line users = await get_about_data()
i got to know about case-insensitive later 🥲
let me try doing it async
No reason for it to be async
its still the same
Might wanna wait for a pythonista to help you bro
okh
;
or a pythoneer
isn't that a class method? needs to be self.get_about_data()
ohhhh, let me try
Thank you mam, the error is gone...
self
oh wait I didn't see xetera's reply smh
I love how this would've worked in c++
ye c languages have an implicit this inside class methods but not every language does
yeah
https://github.com/google/zx this is actually a pretty clever use for string literals
is this good?
yeah but no

the file name tho
wdym
I'm talking about the variable
oh
that has nothing to do with any file
try to run it
it's gonna throw a reference error
the bot?
I'm having a problem, my bot plays music and suddently it stops and music commands won't work anymore, anyone that might know the problem?
he's right

ah
node. isn't a thing on your pc, probs node <filename> or .
node .
to start it
yeah i typed it
have u downloaded the node.js?
there should be a space, node .
s p a c e
that's not the part of the error you should be reading
excacly
you still gotta learn to read errors
I literally told you
I literally told you lmao
Yes, you did
now does anybody there have experience with music bots? i'm having troubles with mine
like that?
Give you errors?
that should work now
nop
just stops playing music and the music commands wont work anymore
kinda disappointed
What module you use?
Sorry, i mean what npm
yeye
Ok
search and core
What error?
can't open the bot rn but i remember it says that "end is null"
withouth this line it wont disconnect on stop or skip command
What npm you use to define server_queue?
i've downloaded like ytdl-core ytdl-search and ytdl-core opusscript
i've made a const for server_queu
And what define the queue?
ytdl-core i think
have also a const for queue
not totally sure
problem is also that i can't connect to the bot console rn, i can try it on my pc tho
it runs smootly on my pc, i think it's due the server it's being hosted on
Maybe, the server must have a good connection to play music
like it freeze and won't play music anymore, if i try to stop to make it leave the error to "end being null"
So I wanted to make a command so they can check if they have voted and i dont this but says topgg.hasVoted isnt a function what would i use otherwise
code for it below:
module.exports = {
name: "test",
description: "test command for top.gg vote checker",
async execute(client, message){
let voted = await topgg.hasVoted(message.author.id);
if(!voted) {
return message.channel.send(`You havent voted yet!`)
} else {
return message.channel.send(`Voted`)
}
}
}```
I believe the hasVoted function is under the Api class in the top-level export.
And since it's a class, you need to initialize it before you can use it.
ahh yea i forgot to put the topgg client part in
I know how to make a say command but now I want to make my say command so that if I type "helll world" it types hello world
Yeah, but I hope you're using that variable as a single source of truth across all areas of your projects involving top.gg components.
wdym single source of truth
aka having one instance of that variable and sharing it across areas like commands
as opposed to making a bunch of separate instances of topgg.Api
I think they want to make it so when they run something like !say "Hello world" it responds with Hello world
i think i could do something like put it in the config file and then checks there for the instance each time maybe
Lmao, yes I do have strict checks on. I’m pretty sure when I created another function, not in the command, it didn’t want to return anything except the return type
Yes
Which sounds like a need for regular expressions
Though accepting an arbitrary number of arguments after would be easier
and more elegant
umm
.split('"')[1] should do
That assumes the user doesn't use " anywhere in their message
Yes definitely
🤦♂️you dont know what I'm talking about nvm its fine
He wants to create a say command.
And add support for quotations.
But the issue has already been solved (it seems)
nice i guess
@near stratus can you explain me about authorization instead of there
Where are the 3 pings ?
i provided worng
Well go to Edit bot in the bot page
set a Random string in the webhook box and set your http://IP:PORT in the webhook location field
Are you using NodeJS ?
Then run the sample code from their docs
const Express = require('express')
const Topgg = require('@top-gg/sdk')
const app = new Express()
const webhook = new Topgg.Webhook('The_auth_Token')
app.post('/vote', webhook.listener(vote => {
console.log(vote);
}))
app.listen(3000)
(Definitely not spoonfeeding)
Then click on the Test webhook from the bot page
wait a few seconds (maybe minutes) and you should have your demo vote on console
@near stratus whats auth token
@near stratus and same in like const webhook = new Topgg.Webhook('topggauth123')
yes
ok thanks a lot
^°^
@near stratus is this ok
ok
I think you can use google scripts no?
Discord Webhook !== Topgg Webhook
?
this to add
Topgg Webhook will send a request to your server / VPS / wherever you're hosting a bot
Discord and Top.gg webhooks have the same logic behind them (https://en.wikipedia.org/wiki/Webhook). How you interact with the two is different.
So the webhook URL should be
https://69.69.69.69:4200 Here 69.69.69.69 is your IP and 4200 is your PORT
Hi, Im a new bot developer that had a very general question about making my bot public:
Is there a limit to how many servers my bot can be in? I've heard rumors about this but can't find official documentation. How do you avoid this?
ok
I used !== not != so they have to be exactly same
2.500 guilds then if you want more you need to implement sharding
use your IP address
ok
thanks for help
amd your post is 3000
It's a big, multilingual world out there.
I have seen 250 server limit in places on top.gg. Is it actually 2500?
there is no limit wym
how can i find my ip
There's no "limit", but there are times where you may be restricted.
Bots must be verified to grow past 100 servers. When a bot reaches 2500 servers, they must begin sharding (else Discord won't allow them to function)
Bot limit in Discord
A bot can be present in a maximum of 2,500 guilds per WebSocket connection. In order to allow a bot to be present in more guilds, the bot must implement sharding and open several separate WebSocket connections to Discord.
for someone that has gone through the process before: should i be trying to verify my bot now before i hit 100 servers?
@near stratus
You can verify your bot once it reaches 75 servers.
Which takes a few days I think.
they changed it?
Did they?
o
its 76
So you can verify your bot when u get to 76 servers, You have to verify before 100 or 250, then to pass 2500 u need to do another update for sharding?
are there any other restrictions a new bot owner should know about? I would like to share my bot beyond 3000 servers, ofc thats the dream if its well liked
The second update is to make your bot conform to the requirements of sharding. It doesn't require a verification process.
I don't think there are any other restrictions you should be wary of.
how do i get ip?
thank you very much for the info @wispy glen @sudden geyser @earnest phoenix , im very much looking for guidance as a bot developer! if anyone would like to teach me more or just chat with a fellow bot owner that has big dreams of making an impact on discord, then please add me as a friend, i would love to chat more with people doing similar stuff as me:) have a good day
It's not possible to get anyones IP address through Discord's API.
so how
He wants to get his VPS's IP
yes
There are ways, but it's a TOS violation to discuss them so best not to talk about it on Discord.
@latent heron No legal documented legit way 😛 There is always a way
That's correct then 😂
https://i.callumdev.xyz/tthe7.png
How can I change "11 minutes ago" to "11m", same with seconds, hours etc
Using moment
@snow urchin Look into the momentum diff function. It allows you to compare two datetimes and get the difference in time. You would then have to create your own logic to show it to the user the way you want it to.
wait
if i download ffmpeg
which one will i pick?
the source code or pgp key?
or both
I think you mean ffmpeg?
Are you using humanize?
yes
I don't think they support precision
@earnest phoenix I guess it depends on what you are trying to do?
you probably need to use ms or something, something that allows you to format the string
oh
What are you trying to do roughly?
music bot
Using node.js?
On a linux machine?
windows
So when you go to the website of ffmpeg you can download the executable you need for Windows on the bottom left.
oh
Then you can use an NPM package like https://www.npmjs.com/package/ffmpeg to make it easier for yourself to interact with FFMPEG
thing is I can only format that to EITHER sseconds, minutes, or days etc. But I want it so if the time is greater than a minute, it uses m, if greater than hour, use h, etc
ight
otherwise ill have https://i.callumdev.xyz/8au83.png
and instead of seconds, if less than a minute, https://i.callumdev.xyz/rxizj.png
Lavalink works good but I am not sure about it on discord.js
@snow urchin I think that would require some custom logic. You would have to do something like:
var now = "04/09/2013 15:00:00";
var then = "02/09/2013 14:20:30";
const timeDifference = moment(now,"DD/MM/YYYY HH:mm:ss").diff(moment(then,"DD/MM/YYYY HH:mm:ss"));
if (timeDifference <= 60000) {
// Display in seconds since it is less then one minute
} else if (timeDifference <= 60000 * 60) {
// Display in minutes since it is less then one hour
} else if (timeDifference <= 60000 * 60 * 24) {
// Display in hours since it is less then one day
} else {
// Display in days since it is more then one day
}
Not sure if the above code is exactly right, but it would roughly look like this.
its possible, but music bots overall are a pain in the ass to manage
will that account for leap seconds
Leap seconds?
is this good to empty an js array? arr.splice(0, Infinity)
Sure I guess lol. Would have to look at how momentum handles things.
why
just array = []?
it will create another array, (I mean new reference)
I hv a habit, to declare const vars as much as I can
So you want to empty an array you have defined as a constant?
I would say you should not make that a constant then since you are changing it.
yup, another method I got was this, arr.length = 0
Are you removing all elements from the array to get some deallocation behavior?
Yea I see the StackOverflow page you find these solutions at. I would just make it a var or a let and empty the thing by creating another instance.
I don't see why you would want to make it a constant if you are changing things inside the thing.
Making the array const and using methods to mutate the array is not a bad habit
It's just not as useful as const could really be to mean immutability.
hmmm, to achieve immutability, I freeze the array
You can do that too
I couldnt resist myself from making code, as memory and performance efficient as possible.
I sometimes, make the code very complex and difficult to understand to achieve that.
How do I help myself. I waste alot of time too, even weeks on a single function
do i need node.js for the music bot or no?
You can use other languages for it as well
Using a different programming language can help you achieve that.
e.g. Rust
i already have node.js installed
By nature, JavaScript's exotic, dynamic nature does not put it on par with performance efficiency, proof, and memory (though it's "memory safe" to some degree)
@earnest phoenix If you want to interact with the Discord API through a library like discord.js like you said you wanted to use, then yes you do need NodeJS.
rule of thumb: never prematurely optimize
ight

show more
guys help I'm getting some errors
😐
Show whole error
How fix ‘err’
bruh
Guys what am I doing wrong at this line of code?
Stop acting like a clown
Show the whole error lol
oof send the whole desktop screenshot
show the whole error
I have seen a terminal before
The terminal may seem scary at first, but you'll get used to it.
There you go!

What was the command you tried to run?
In your thing I Think Your python Version is outdated
Or something
And it Failed To Execute the Installation of whatever package
The error doesn't tell enough at the moment
What were you trying to do? Install NodeJS?
It's just a disarray of 200s and 404s and failed to execute some script
npm install @discordjs/opus ffmpeg-static yt-search ytdl-core
I think he was trying to install a package from the registery
@earnest phoenix Try running the install command for each package separately so you can see what package is failing.
ight
Does <member>.setNickname() change the username locally on the server only? Does the server remember that username after the client/bot left/joined again?
npm install @discordjs/opus
npm install ffmpeg-static
npm install yt-search
npm install ytdl-core
It won't remember
Thats for A music bot





