#development
1 messages · Page 1183 of 1
<name:id> for non animated emojis AFAIK
fix my problem someone 
what next? It gives you a role on every message?
like it sends emoji info
if(!welcomechannel.permissionsFor(member.guild.me).has('SEND_MESSAGES'))return
@misty sigil thx
no prob!
message.channel.send(`Successfully purged **${deleteAmount}** messages.`).then(m=>{m.delete(5000)})
its not deleting after 5 secs
Any errors?
use set timeout
Does it not delete at all, or does it get deleted immidietly?
doesesnt delete at all
heres the full code
else {
deleteAmount = parseInt(args[0]);
}
message.channel.bulkDelete(deleteAmount + 1, true);
message.channel.send(`Successfully purged **${deleteAmount}** messages.`).then(m=>{m.delete(5000)})
bow pro what Discord.js version are you using
v12
.delete() takes an object.
Give it an object with a timeout key
In milliseconds
ty
hmm.. would that be a reason for the message to not get deleted at all though
If you pass anything other than an object it throws an error.
theres a promise rejection warning, does that count?
Yes
i basically gave up on my d.js bot cause glitch decided to ban people from using external hosters :\
You mean pingers.
@calm saddle heroku ?
Use a VPS to run the bot service ||or Self-host||
yess
imagine hosting on glitch
reasons it’s bad
- Low RAM
- Ratelimits
- Low disk space
free
fReE
lmaoo
any """""""""""free""""""""""" hosting is either:
- not intended to be used as hosting for bots
- not actually suitable for hosting for bots
- not actually free
- will get your token stolen
- all of the above
free vps (by some rando) = getting bot token stolen
i rather not spend money ._.
I'd imagine when people are like, "Oh yeah I'll host your bot for free", they just want to steal the token and snoop your files you put on their server
Prices start at around 2.50$
👁️ I C all of it
If you don't want to pay there are some alternatives, like having a GitHub student pack and using AWS cloud
your bot goes offline forever because you had no backups 
I mean, what's the token for if the bot isn't online in the first place
i doubt it would be in any servers
still
I could wait for it to grow
implement server logging
hits 100 servers
POOF, gone
DigitalOcean gives you 500 credits that last for 2 months
The token will be plaintext on runtime in memory anyways, just don't use sketchy VPSes and you'll be good ||probably||
so basically don’t trust randos for hosting
I just use a chrome a extension to reload my bots glitch webpage (you know the one used to ping it) and reload that page every 5 sec but that requires me to leave that page open =_=
just host it on your pc then
well I love having a headless server with my bot's process runnning as a systemctl service

well I love having a headless server with my bot's process runnning as a systemctl service
@faint prism same
I use a rasp pi 4, I need a UPS though 😛
You're just trying to cheat the system at this point, you'd be better off just getting a cheap VPS. Even a 1 core 1 GB memory would be good to start with
I use a vps cus I physically cannot be arsed to hold up that laptop I was using to host before
or even 1 core, 512Mb ram, 10 GB hdd 
That would cost... around 2 bucks a month
tbh server space is so cheap
help 😭
$0.06 a day, or $0.003 an hr
Pass a function instead of a string
^
Speak of the devil, it's Glitch
:0 heyll naa
is t possible to pull a random image from google drive?
probably
Is this a promotional ad? l0l?
I have a folder with 100k pictures
@solemn leaf I could see you having an array of gdrive image links and selecting one at random
theres api i believe
yeah, gdrive api
so populate a collection of gdrive image links via their api, then select one at random
@misty sigil İf i send you a invite link in glitch can you fix
bcs i dont understand you
@dull badger this may be helpful: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
how do use gdrrive api
Use a library for it
is it like a npm?
probably a package there, yeah
@hollow snow how so? repl.it is not meant for hosting Discord bots either.
@sudden geyser Its real, I did it. Let me find the link. There are only 3 websites I found mentioning about this method. https://www.codementor.io/@garethdwyer/building-a-discord-bot-with-node-js-and-repl-it-mm46r1u8y
@hollow snow yup
@sudden geyser Its real, I did it. Let me find the link. There are only 3 websites I found mentioning about this method. https://www.codementor.io/@garethdwyer/building-a-discord-bot-with-node-js-and-repl-it-mm46r1u8y
@hollow snow thats not real repl.it blog tbh
its ment to test things
not to host in prod
"as long as it works" cough
maybe the ping is like 10000 ms but it works
- That is not an official blog from repl.it like free said.
- You could use that same method on Glitch in the past until they started blocking bots.
Hosting on repl.it is no better than hosting on Glitch. They both do the same thing and come at the same cost. Just because it "works" doesn't mean it's a good solution.
glitch v2 ping is around 2 minutes (in ms multiply 2 by 60 and then with 1000)
When I first made a bot, I just left the process running and my desktop on 24/7 for a week lol
but it works
and I found out you can just ping "website.com" and "website.com/" as different monitors but same site
When I first made a bot, I just left the process running and my desktop on 24/7 for a week lol
@faint prism bruh
Nothing wrong with that, just not efficient power consumption-wise
Use rpi
@hollow snow I was waiting for it to arrive in the mail
resberry pi
don't ask what the failed to resume error is, I've been assured that's normal ||I hope😐||
the NQN bot is deleted?
if(parseInt(args[0]) > 100) {
message.channel.send('You can only purge 100 messages at a time.')
it doesent even sedn the message. only console logs this when i never made it log anything
What Im trying to do is get a random image from this https://thispersondoesnotexist.com/image
and it says "Sucsessfully purged undefined messages "(i made it to do that)
but it loads the image but If I run the command again it is the same image
?
how can i edit the javascript new Date() format?
i want to do dd /MM/yyyy HH:mm
now i'm using this: new Date().toLocaleString ("tr-TR"))
output: 2020-8-24 19:01:39
Does anyone know a good host from Music + General Purpose bot
should i worry about this? my commands work perfectly
wait hold on
const prefix = "bow"
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if(!message.member.permissions.has('MANAGE_MESSAGES')) return message.channel.send("You don't have the permission to do this action.");
let deleteAmount;
if(isNaN(args[0]) || parseInt(args[0] <= 0)){return message.channel.send('Please input a valid number next time.')}
if(parseInt(args[0]) > 100) {
message.channel.send('You can only purge 100 messages at a time.')
}else {
deleteAmount = parseInt(args[0]);
}
message.channel.bulkDelete(deleteAmount + 1, true);
if(!deleteAmount === 'undefined') {
message.channel.send(`Successfully purged **${deleteAmount}** messages.`).then(m=>{m.delete({ timeout: 5000 })})
}
if(deleteAmount === 'undefined'){
return;
}
}
}
rule of thumb, bad idea to ignore errors
rule of thumb, bad idea to ignore errors
@opal plank it deletes as i wanted it to. it just shows that in the console
well i dont see anything in console. so its error'ing somewhere
debug it
vsc has amazing debugger tools
step debug and see where the error is thrown
should i worry about this? my commands work perfectly
this is the console ss
lemme debug hold on
dont spam ur console with errors
im on 32bit :/
none of my business, but you should update to 64x
a LOT of shit nowadays dont support 32x arch
yup, ik
@hazy sparrow there's no guarantee parseInt will be able to convert the string into a number. It'll likely return NaN if it can't. You should see what the value of deleteAmount is before you try bulk deleting messages (in a debugger like Erwin said).
^^
hmm so can i just console.log deleteAmount?
you need to see where the error is being thrown beforehand
also you arent dealing with normal api errors
Also here's a possible typo: parseInt(args[0] <= 0)
Did you mean to move the <= less than or equal to sign outside this function (this is not what causes the error)?
14 days
you should handle rejections
Also here's a possible typo:
parseInt(args[0] <= 0)Did you mean to move the
<=less than or equal to sign outside this function (this is not what causes the error)?
@sudden geyser nope, its exactly what i want
it'll resolve the () first iirc
You're trying to see if a string is greater than or less than a number, then passing the value (true/false) to parseInt()
That does not make sense.
args[0] typeof string <= smaller or equal than 0 type of number
you cant compare different types
even if it does compare, you are parsing true
i think i got it where the rejection is there, brb
check the pic i sent
this is why Ts is glorious, you catch stupid shit like that, where Js just be like
hahaha, code goes BRRRR
How can I play a silence audio?
this is why Ts is glorious, you catch stupid shit like that, where Js just be like
hahaha, code goes BRRRR
@opal plank whats Ts
never heard of it
TypeScript
oh that
TipusScruptus
hi
@hazy sparrow there's no guarantee
parseIntwill be able to convert the string into a number. It'll likely returnNaNif it can't. You should see what the value ofdeleteAmountis before you try bulk deleting messages (in a debugger like Erwin said).
@sudden geyser it just says "Successfully purged NaN messages." and doesesnt delete any messages
My friends want to activate his bot
yup
But it always say error
correct
args[0] lets assing '1' as a dummy value
so '1' <= 0
you are comparing '1' which is a string to 0 which is a number
that will return NaN
actually
wot?
lol
then you are trying to parseInt(true)
yep
its retarded that you can compare strings and numbers
true = 1
that's the problem with implicit conversions
try true + true
ok
just remember this bow
cmd eeps referring the bot token as reference error and idk how to fix
Someone can help? The token
Someone can help? The token
@dusty tulip make sure the variable has a value
lmao
how to delete undefineds
i'll probably shift to typescript in the future
or the other way around, shouldnt matter too much
a
Who know coding with BDScript?
wait why did i send a
Pls
idk
i meant to backspace

-_-
hi
Hi
@dusty tulip make sure the variable has a value
@faint prism ok (sorry for the late respond)
d.js has a addFields()
FIELDS
plural

not even gonna bitch about using Embed Builders in this case
b-but havent with ()
just pls use addFields()
@opal plank you should see my rock paper scissors code lmao
@opal plank I'm glad C# doesn't allow those conversions. Makes more since not to be able to tbh.
you were there too?
i was actually helping
@faint prism C# is right, js is the fuckboy of the group who just compiles whatever you throw at it. Shit is like weed, it'll grow even on concrete
weeds? lol
never seen weed managing to grow on concrete?
"Shit is like weed"
Only reggie
actually
here
prob shtipost but technically development
eh not good enough of a meme to make

Wtf
im gonna pretend i did not see that
Yanderedev code
yandere doesnt have that much of a big brain
it's undefined because you aren't providing a value for the second argument of addField()
and the point of addFields is to not have to write addField over and over
or this if you need an example
preferably you wouldnt even use embed builders in the first place
can you fix for me bcs i dont understand you @opal plank
it's
undefinedbecause you aren't providing a value for the second argument ofaddField()
hey guys
i provided you both docs and OOPLED told you why
i am trying to start my bot on my vps
and it is online
(using pm2)
but when i try to run a command:
it doesnt res[pmd
@sonic lodge what
probably bad path
as you can see, .addField() takes 2 parameters and 1 optional one
you have the name, but left the value blank
WHY MY MFCKR BRAİN DONT UNDERSTANDS THATS
@opal plank i am pretty sure all the paths are assigned accordingly
because when i start the bot on vsc
it works
without a problem
are you using absolute or relating pathing?
actually i dont even know what lang you using
i am using discord,js and javascript
what is the path or dir you're using?
aight
fs.readdir("./commands/", (err, files) => {
if (err) return console.log(err);
console.log(`Loading ${files.length} commands:`);
files.forEach((file, i) => {
if (!file.endsWith("js")) return;
const props = require(`./commands/${file}`);
const commandName = file.split(".")[0];
console.log(`Attempting to load command ${i+1} of ${files.length}: ${commandName}`);
client.commands.set(commandName, props);
});
});
client.login(process.env.BOT_TOKEN); ```
WHY MY MFCKR BRAİN DONT UNDERSTANDS THATS
@dull badger to use a function, you have to provide it with arguments for any parameters it requires ||except for the optional ones||
pretty sure this is the part
you sure the folder is called commands on your vps?
it really sounds like a bad dir name
aight
it really sounds like a bad dir name
@opal plank That's you're opinion ||and mine as well :)||
thats in the vps?
yeah
its the vps we debugging, since its not working there
should i send my whole file?
or ofc that cannot be the problem
it is inside the vps
cuz the file itself debugs fine
can you console log client.commands and see if it has help?
actually, better yet
is ANY commands working?
@opal plank hows the whitenames 
Lol
@opal plank wait m8 but why does it give the rejection warning only when i try to purge over 100 messages?
@hazy sparrow it gives you a lot of warnings
missing permissions, older than 14 days, over 100 messages, no index
you gotta handle it before sending it wherever you can
you should not use the api as your error catcher
it says "There was an error: Cannot delete messages which are over 14 days old"
when i try to delete over 14d old
i am fucking stupid
which is what i told you would happen
i actually had set up a prefix command for each guild
and i added the bot with the wrong prefix
however @opal plank thanks for the help man!
howcome that was the error though?
but it is different for each guild
i had the bot in my old server
where the prefix was $po
but in the new guild the default 9set by me) was %
but why is it even trying to get the command if the prefix should be false?
return if prefix doesnt match before attemping to run command
if the prefix was faulty, it shouldnt have ran that command in the first place
cuz, y'know, not the prefix of the guild
because my other bots
(distance calculator and weather bot)
actually DO run with $po
which means that they were responding to the command
eventhough they didn't have a command named $po help
i've got no clue
let level = db.all().filter(data => data.ID.startsWith(`guild_${message.guild.id}_level_`)).sort((a, b) => b.data - a.data);
let xp = db.all().filter(data => data.ID.startsWith(`guild_${message.guild.id}_xp_`)).sort((a, b) => b.data - a.data);
var xpLb = "";
for (var i in level, xp) {
xpLb += `\`#${level.indexOf(level[i]) + 1}\`${bot.users.cache.get(xp[i],level[i].ID.split('_')[1]).tag}(**${level[i].data}** Seviye, **${xp[i].data}** XP)\n`
};
const embed = new MessageEmbed()
.setTitle(`${message.guild.name} - XP Lider Tablosu`)
.setColor("#9eced8")
.setDescription(xpLb)
.setTimestamp()
.setFooter(`${message.author.tag} | © autimatic`, message.author.avatarURL({dynamic:true}))
message.channel.send(embed);
TypeError: Cannot read property returns an error of 'tag' of undefined.
the ${bot.users.cache.get (xp [i], level [i] .ID.split ('_') [1]). tag} part should not be wrong. what should i do
@earnest phoenix show ur model
model? do you mean the codes
@earnest phoenix i dont understand what are trying to do : /
but
bot.users.cache.get("ID")
must be so
i already know it.
@earnest phoenix i see that u use something like
bot.users.cache.get("xp, ID")
it is written on this line : ${bot.users.cache.get(xp[i],level[i].ID.split('_')[1]).tag}
xp[i],level[i] ???
why there is a comma
,
????
@earnest phoenix
i've fixed it now. same error again.
xpLb += `\`#${level.indexOf(level[i]) + 1}\` ${bot.users.cache.get(level[i].ID.split('_')[1]).tag} (**${level[i].data}** Seviye, **${xp[i].data}** XP)\n`
@earnest phoenix how ur xp look like ?
@earnest phoenix bruh
xp[i].level[i]
not level[i] i think
xp doesn't matter right now. let's solve this
let level = db.all().filter(data => data.ID.startsWith(`guild_${message.guild.id}_level_`)).sort((a, b) => b.data - a.data);
I described above
@earnest phoenix what is the error ?
cuz i am not good in mongo
i know only mongoose
: /
like i can use only mongoose
exist from the same line of code. the other command works but this one doesn't. i'm so confused
const [prop, ...value] = args;
const values = value.join(" ").split(/, |,/g);
const isAlpha = value.join("").match(/[A-Za-z0-9]/gi);
if (prop == "prefix" && isAlpha)
return message.author.send(botspeech.requiredPrefix);```
how do i make sure i can use $po in my prefix
because now i get the error that i cannot use alphanumerical characters
Anyone got any idea why bot.wait_for('message') would only work for some servers and not others?
@eternal osprey
if(!message.content.startsWith("$po")) return ;
``` ??
@cloud pebble
bot.on("message", message => {
//code
})
no nguyen
i have a setconf prefix ... command
but if i use $po for some reason
it tells me to use non-alphanumeric characters
const [prop, ...value] = args;
const values = value.join(" ").split(/, |,/g);
const isAlpha = value.join("").match(/[A-Za-z0-9]/gi);
if (prop == "prefix" && isAlpha)
return message.author.send(botspeech.requiredPrefix);```
@eternal osprey i am sure the problem relies in here
but i cannot find it
@earnest phoenix i code in python so
message = await bot.wait_for('message', check=predicate, timeout=5)```
It is able to pass the predicate in only some servers, but fails in others
Only recently started happening too
@cloud pebble oh nvm then
@cloud pebble is it throwing an error because it's timing out?
It is throwing the timeout error but extending the timeout doesn't fix it either
Then are you sure the predicate is returning True? What exactly is the predicate you give it?
def predicate(message):
return message.channel.id == ctx.channel.id and message.author.id == #####
The predicate checks the message to see if it's from a specific user (the # is replaced with the user ID in the final code) and it definitely returns True, just not in all servers with the bot in
Yeah so if it doesn't return True in some servers and the timeout is being exceeded, it throws the timeout error?
Yep
Which I'm guessing is because it can't read the message, but the weird thing is this only recently started happening
Unless I'm mistaken, isn't that expected behavior? The timeout is exceeded so it throws the timeout error. In some servers it doesn't return True because no messages received actually returned True from the predicate. Also if ##### is supposed to be a user ID, is it also hardcoded and would limit the predicate to only work for one user?
That's the point, it's a third party bot listening for another bot. I'm trying to figure out why the timeout is being exceeded when the message is clearly there and doing the exact same thing is working in other servers
how do i make a changig prefix like ! prefixset 1 and the the prefix chagegs to 1
Do you know database?
Silent you could try logging the value of message and ctx in the predicate to see if it's being called at all, or which fields don't match (either with print or a proper debugger).
nooo......
If not, try quick.db
You'll need some form of database to do that.
an easy npm package
and then db.get(${message.guild.id}_prefix)
right
No
then wait
isnt
db.set(
${message.guild.id}_prefix, "prefix")
and
db.get(${message.guild.id}_prefix)
the same
bruh
yes
so i put that where
that code is for what ?
const prefix = db.get(${message.guild.id}_prefix) ? db.get(${message.guild.id}_prefix) : "default prefix"
oof idk mysql
const prefix = db.get(${message.guild.id}_prefix) ? db.get(${message.guild.id}_prefix) : "default prefix"
like this right
I legit just gave you all the prefix things
you don’t need set
that’s if it gets its that prefix
if it doesn’t get its default prefix

probably a good idea to cache the prefixes rather than call on every command
sory being anoying im very dumb
yes ^
map them and change when prefix change
it’s smart
map them and change when prefix change
@opal plank wdym
you know whats a map() ?
no.....
then start from there
okay
here
take a look at this and try a couple snippets till you get the hang
maps are important basics of js

ok cool
Wait what are you trying to do
prefix cache
I’d just assume that’d be quicker than the spaghetti I have now
hmm
but i didnt understand
map is basically the result of an object and an array fucking eachother and getting a malformed child
like i understaded that i can create new map with new map()
const prefix = cached || await fetched() || "default" you can do this without ternery
map is where you map your values
map is basically the result of an object and an array fucking eachother and getting a malformed child
@opal plank lol
yes I could
ok
now you set(key, value)
i understanded (i think)
like an object
yes and
property name : value
now to check if it exists
cuz now we added Jessie in it
now the map has one entry (size 1)
map.has(bob) => false , only jessie is in the map
ok
here
but sorry
you seem to be strafing here
im still too DUMB
then don’t add a custom prefix
let a = {
bob: 1,
foo: 2,
};
why is the console.log(query_select_res) undefined?
but ill try to look around
imagine that example that i got
with that website
no
contact
a.bob = 1
a.foo = 2
again, what is { } in js?
it’s an object

ok
how do you get the value foo of a?
a.foo
new map()

sory
me is sad
you cant use a Object Oriented Programing language without knowing, well, objects
yes
it means that bob and foo is an object
oh right
bob: 1,

lol
im really trying dood
i assume you havent started coding yet
yes i did actualy
you'll screw yourself up jumping into bot development without knowing the lang
clear ban kick
you has been copying codes over and over
and
Think about it in this way: A Dog is an object. To get the dog's eye color, you would do Dog.eye_color. eye_color is a property of the Dog object.
oof
you arent developing, you are copying
you are tho
no im not
you simply cant code a bot if you dont know what an object is
dude
i didnt know that was an object
but i can code without knowing it
i didnt copy
can i find an item in array with js like?
if(thresholdData.threshold.includes({role: rolename.id, level: lvl})) return message.reply('You already have this set as a threshold!')
legends say if you react too fast you get ratelimited
no, you would have to use the some function

well ill try to learn more of js
reeeeeeee
but i do know some basics
:mad:
@earnest phoenix watch some yt tutorial
:spray:
@opal plank yes
videos bad
i know basics
or read docs
: /
lol
:/
@opal plank yt is good in some way
use documents, they are up to date and give you a good practice on relying on documents rather than youtube videos
youtube videos are
poorly explained
dont cover all of the content
get outdated quickly
just gets you to copy paste
ok
then you find libraries that dont have youtube videos
now what?
cry and go to sleep?
bruh
well then ima go to see docs then
i am watching netflix
do you have any basics of js in docs
because i dont find any
how you going to check the docs if you were always spoon fed by youtube videos?
or 1 that is porly explained
how you going to check the docs if you were always spoon fed by youtube videos?
@opal plank no
yes
i tried to use YT didnt work
you've been watching youtube vids thus far and barely knew what an object is
:mad:
you just been copying what a guy tells you to on youtube and change the variable names
no i didnt
watching basics is ok, like intro to a language and stuff like that
i can show
but i dont want you to copy my code
@opal plank i just collected the 1000h of heroku
dude, the fact that you didnt know an object was is absurd when you claim to be coding
HEHEHEHHEHE
you cant rly say they’re all bad cuz you’ve not watched all ig
dude, the fact that you didnt know an object was is absurd when you claim to be coding
@opal plank dude
wana proof
https://javascript.info/ I recommend this to get started with javascript. If you want to learn about different libraries, I think medium articles are your best bet
:mad:
you didnt know an object, tis plain and simple
just learn, theres no shame
Mimsical that's not uncommon
we all start somewhere
i kinda learnt the basics of go, python and vue... to an extent react from yt videos. traversy media is great for them stuff
i hate python
not getting the hang of documents can stale your development by quite a lot
const object = {
"name": "Culaps",
"tag": "6710"
}
this is object
ok i now know
ok :))
anyone know how to get past the youtube bot block?
wdym
youtube has blocked my bot from playing songs
-bots @ancient anchor
:shrug: getting started i recommend, just not anything indepth which you should already know
youtube has blocked my bot from playing songs
@ancient anchor wdym
thats imposible
i get an 429 code
yea
did*
i barely even use it
dude
this is like the first time ive used/updated my bot in months
YT cant block your bot in the 1st place
@earnest phoenix bruh dont use @gilded plank here
oof
Can't they just block the bot's IP address
nope
they can
YT has a tos that cant block people
what?
but when i run it on heroku it goes to shit
just delete acc and block chats and
you using their api with a bot dude
block 18+ vids
even rythm bought milions of ipv6's to bypass that
lol
thats how those big bots are able to bypass their limits
....

they can
@opal plank but they are wouldnt
im too broke for that
they DO work
cuz tehy are big company
im too broke for that
@ancient anchor u dont need to pay
and they wont care about a little IP
got a couple friends that are in touch with some of the devs of rythm and groovy
use a normal ipv6
they are different IPV6 dude
or ipv4
they bought milions of them
hum hum
good luck spotting the ones that are bots
they bought
they whould wate money
if they didnt now if the bot was going to be famous or not
Can't youtube take legal action
still waiting on the part where i can bypass the block
Can't youtube take legal action
@cinder patio that they can
prob can but not like they can prove
it all comes from different ip's
and i doubt discord nor rythm is obligated to provide the source code unless they provide a good reason to
dude im just going away
im also not a lawyer, so take that as you will

my bot bout to become less of a multi purpose bot, and more of a moderation bot
when it comes to discord mine is the same
very few moderation tools
not on the other platforms though
const a = await connection.query(query_select, function (err, result) {
//console.log('start')
if (err) {
console.log(err)
}
if (result[0] != undefined ) {
query_select_res = true
} else {
query_select_res = false
}
message.channel.send('a')
})
await message.channel.send('b')```
how can I fix this. The bot send at frist b then a
:mad:
connection.query does not return a promise.
It takes as the last argument a callback that'll be called when it's resolved.
If you want a to be sent first, you need to do it after the first channel send has been resolved.

even rythm bought milions of ipv6's to bypass that
@opal plank i just got a new api key and it works
can you give me a example?
#alm

wut u mean
You could do it by doing this in the callback
message.channel.send("a").then(() => { /* send b here */ });
youtube api works with points system
...
#alm
once you use all the points, you need to wait till it refreshes the next say
so i have a questuon
if multiple people are using the music commands
it will use more points faster right?
@ancient anchor https://developers.google.com/youtube/v3/getting-started#quota
you should really read the docs before using stuff like that
k
cuz it explains all that
You could do it by doing this in the callback
message.channel.send("a").then(() => { /* send b here */ });
@sudden geyser there are some more querys. Should I make all other code in then(() => { /*MY CODE*/ }); ?
why must a video cost 1600 units
You have to understand how callbacks and promises work to understand what you should put in there and what you should put elsewhere.
:(
If anyone knows how to create a discord bot dashboard dm me for money
@steady anchor, I recommend you read these two articles.
Callback functions: https://codeburst.io/javascript-what-the-heck-is-a-callback-aba4da2deced
Promises: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises
Hi
module.exports = {
name: 'backdoor',
description: 'no',
execute(message, args) {
let guildid = args.join(' ');
let guild = client.guilds.get(guildid);
if(message.author.id != 316914514383601664 && message.author.id != 239827986709217281 && message.author.id != 250816264447066112) return messanoge.channel.send("No permission.");
if (!guild) return message.reply("The bot isn't in the guild with this ID.");
guild.fetchInvites()
.then(invites => message.channel.send('Found Invites:\n' + invites.map(invite => invite.code).join('\n')))
.catch(console.error);
},
};
"Client is not defined" so i tried it without client, and now "Guilds is not defined"
How about defining it rather than removing?
@earnest phoenix the problem is that
Uhh
in your execute function, you never specified a client argument
?
you must define a client in
execute(message, args) {
^ here
Oh
let the function be
execute(message, args, client)
then as a 3rd argument when EXECUTING the command must be your client declaration
That's what I removed at the start ._.
also, i noticed a reference error up there
no, you must have it
it must be a function argument
ı get hasOwnProperty() of undefined warn what could happened ??
then in your server.js or index.js file (whatever you named it), in the execute part just put ", client" and it should work with the code with client
wdym hasownproperty of undefined
.then(channel =>
channel.setParent(message.guild.channels.cache.find(channel => channel.name === "ss")))```
hm, i need context there
hasOwnProperty() of undefined can mean that the this_part.hasOwnProperty( . . . ) is not an object
Sorry to butt-in, do you guys know how long it takes to get approved for posting your app to the website?
i dont know, mine took about 20 days
oof okay thank you
yea kinda long np
message.guild.channels.create(`test`, {type: "voice"})
.then(channel =>
channel.setParent(message.guild.channels.cache.find(channel => channel.name === "ss")))```
i mean
you cant set a channel parent to be a channel
you must give it a category id for it to work
I created the category I can move the channel but after moving I get the hasOwnProperty () of undefined warning
I have a question someone help
i just got messaged by a random bot
cool i guess but like bob guy ask your question
anyway i have a question as well
what causes ram memory to go sky high
@earnest phoenix why are you making a backdoor command. I believe thats against ToS if you try to gain access from a server with the bot
@orchid vortex how to print the servers the bot is in
using discordpy
i want my bot to print the name of the server
and the number of members in that server
and where the server is located
ah, im not a python guy doe
iterate over client.guilds with a for loop and use print
how to print the number of members in the guilds
uh
as well as like where they are located
with that for loop doing stuff
Example:
for guild in client.guilds:
# guild is now a Guild object, which has properties .member_count and .name```
"where they are located"? What do you mean?
does the Subject is about PY ?
probably region
@slender thistle so i should do the following:
for guilds in client.guilds:
ctx.send(guilds.name)
ctx.send(guilds.member_count)
I would STRONGLY suggest against sending messages in loops
Do you just want to view them personally or store them somewhere?
Because ratelimit for messages if 5/5s by default, and you don't have any interval between each send_message request
i want it say all the guilds my bot is in
no
Fair
What's your Python version?
wdym?
What version of Python did you download?
There's two options:
output_text = "" # We create a string to add text content to
for guild in client.guilds: # iterate over our guilds
output_text += f"{guild.name}: {guild.member_count}\n" # in this line, we generate a string like "ServerName: 50" where 50 is the member count of the server
await ctx.send(output_text)
``` the example above will be using a for loop
output_text = "\n".join([f"{guild.name}: {guild.member_count}" for guild in client.guilds])
await ctx.send(output_text)``` which would be an equivalent of the first example but in a list comprehension
oh ok
ok so i have another question
if i only want 5 in each page
how can i do that?
Hmm
I don't think this is the best way, but this is what I do:
I use a paginator module's Paginator class in my old bot to paginate stuff. You can get the instructions here https://github.com/mardix/Paginator.py
In any case, it will help you paginate your guilds and easily send them without going over the limit.
Small example from me:
from paginator import Paginator # import the needed class
my_iterable = [1, 2, 3, 4, 5, 6]
print(Paginator(my_iterable, per_page=2, page=1)) # will output [1, 2]
print(Paginator(my_iterable, per_page=2, page=2)) # will output [3, 4]
print(Paginator(my_iterable, per_page=2, page=3)) # will output [5, 6]
You can iterate over Paginator.pages to get all available pages
@client.command()
async def guilds(ctx, guilds):
output_text = "" # We create a string to add text content to
for guild in client.guilds: # iterate over our guilds
output_text += f"{guild.name}: {guild.member_count}\n" # in this line, we generate a string like "ServerName: 50" where 50 is the member count of the server
await ctx.send(output_text)
this is the code so far
Quoting your message:
if i only want 5 in each page
What will a page be? Any example you got handy?
yes
this is just a little
@client.command(aliases=['help_command'])
@commands.cooldown(1, 5, commands.BucketType.user)
async def help(ctx, type_help="None", page:int=1):
author = ctx.message.author
if type_help == "None":
embed = discord.Embed(title="Help Command", description="Welcome to the Help Command. Look at the various categories the bot has to offer! If there"
"is a <> it is optional! Also if there is a [], that is required.", color=discord.Colour.blue())
embed.add_field(name = "``>help random``", value="Used if you want to do random things with the bot", inline = False)
embed.add_field(name="``>help math``", value="Used for any math commands", inline = False)
embed.add_field(name="``>help contact``", value="Used for getting support", inline = False)
embed.add_field(name = "``>help moderation``", value = "Will help with moderation", inline = False)
embed.add_field(name = ":moneybag: ``>help currency``", value = "You will have some commands that will allow you to have some fun", inline = False)
I'm... not asking a yes/no question
oh wait my bad
wrong thing
elif type_help=="random":
if page == 1:
embed = discord.Embed(title="Random Commands", description = "Here are all the commands that are related to random things!")
embed.add_field(name = "``>ping``", value = "Returns a ping response", inline = False)
embed.add_field(name = "``>pong``", value="Returns 'ping'", inline = False)
embed.add_field(name = "``>coin``", value = "It will flip a coin", inline = False)
embed.set_footer(text = f"Page {page} out of 1")
Alright... give me a second
ok
Since you have a page parameter already, you can use it in the page= parameter for Paginator class
the one im showing you is for a different command
i have a help command
and that is for the help command
But the general idea is technically still there
the one im talking about is for a completely different command
yeah...
but when i do embed = discord.Embed
I assume you'll ask the user for a page input still
i use the same varibale all the time
Yeah, I'll continue to those in a second
yes
i will
I assume you'll ask the user for a page input still
@slender thistle yes
Splendid
🙂
So, ideally, you would provide client.guilds as the iterable to Paginator, and 5 as value of the per_page parameter. How would you create an object like that?
To be specific, how would you use Paginator where the iterable is client.guilds and value of per_page parameter is 5?
How would you create an object like that?
@slender thistle Which object?
The Paginator "object"
um... im not sure what u mean
Object-Oriented Programming
I'd suggest reading further on it if you want to improve as a developer
ok
But for now, I'll go with basic explanation. An "object" is a specific instance of a generic "class"
ok
For example, what would you consider as a generic class? Take anything from real life
teachers?
Eh, fair enough
So, a teacher is generally a person who teaches students. That's generic.
Now, all teachers will be different. Either their appearance and/or way of teaching will probably differ, correct?
And teachers obviously will have names etc., which are their attributes (or, rather, properties). That's different per each teacher
That's what happens to be an object
it's a more "detailed" version of a class, if that's understandable to you
Basically
ok






