#development
1 messages ยท Page 1339 of 1
YouTube videos for Discord bots
@slender thistle Why ?
you didn't import has_permissions directly from discord.ext.commands
Because its just copy and paste for most people
ok
and its in 120p quality
Oop> @untold sand because they are/will be outdated
@slender thistle sorry
learn the basics of the programming language you want to use and read the documentation
@untold sand because they are/will be outdated
@slender thistle Oh k
@slender thistle so if i have this. the commmand will work right? from discord.ext.commands import has_permissions
try it
this import just got me thinking, in JS, does it affect the performance if you require the whole Discord lib instead only, for example, MessageEmbed?
Performance-wise I wouldn't say so
memory-wise probably, but I'm not sure myself
Hmm, interesting. Might do some benchmarks when I get time.
suppose for cloning a channel
would this be correct:
try:
code
except HTTPException:
code
else:
code
```?
this is what I'm looking at rn
would this be correct syntax:
@has_permissions(manage_channels = True)?
@modest smelt no try this @command.has_permissions(manage_channels=True)
nah i got it to work with the @has_permissions
@slender thistle ?
try code, if HTTPException is raised, do code, if no error occurs, do code
Hi i have a Problem in discord.js canvas
When i am sending with x = db.get(msg_{member.guild.id})
if this is null it is not sending can i fix it
if msg is null can i send canvas?
You'd have to use basic Python knowledge to create a proper error handler
you almost got it though
hmm ok ill take a look at it
would this work
try:
code
except HTTPException:
code
except:
code
what's code
do stuffs
Should work
try:
await clone('channel')
except HTTPException:
await ctx.send('could not been made')
except:
await ctx.send('something')
this is not the proper syntax for the code
clone is a method of a voice channel
don't use except twice
Two options, either send the message that says "success" in the try branch
or use the else branch for that
ok
can someone explain how a gate and an if on my subscription event(WHICH ISNT EVEN HOOKED TO THE SHARDS) somehow broke my whole sharding pls? Cuz this shit is making no sense whatsoever, and im the one who made it
try:
await send('yay')
except HTTPException:
await ctx.send('could not been made')
sure


Thanks shivaco!
cuz i broke my whole sharding cuz of something completely unrelated to it
its the equivalent of sneezing and accidently causing a tsunami in japan
how does an event emitter which is hooked to a logger affect sharding?

Help
you have to wait for the moderators to approve your bot
@earnest phoenix Consider improving your description until it gets reviewed.
is there anybody that would help me fix some panel security vulnerabilities? not paying money
smh
o
404 
even though you dont have access to the page cuz its a not verified bot
you can still get meta from it with the content
i was wondering if top.gg meta tags provided that
cuz i was thinking how does @stoic girder found about the description
if its a non approved bot, therefore only the owner should have access to the bot page
probably an oversight in that botlist part tbh
@opal plank hehe this is too big brain
What's the purpose of Request.clone() and Response.clone()?
LMAO
well that explains
i was digging in the source code to find security oversights
function plusMinus(arr) {
let result = [];
let positive = 0;
let negative = 0;
let zero = 0;
for(let i = 0; i < arr.length; i++){
if(arr[i] > 0) {
positive++;
}else if(arr[i] < 0){
negative++;
}else {
zero++;
}
}
result.push(Math.floor((positive / arr.length) * 1000000) / 1000000);
result.push(Math.floor((negative / arr.length) * 1000000) / 1000000);
result.push(Math.floor((zero / arr.length) * 1000000) / 1000000);
return result.join(" ") + "\n";
}
Help me please
uh toFixed()
will work
wonder why u put the result into an array and return it as string?
just return the string which will save 3 lines lel
arr.push() is ordered i assume, right?
new items will always be put at last position

nvm , it does
let divisor = 1000000;
return (Math.floor((positive / arr.length) * divisor) / divisor) + "\n" + (Math.floor((negative / arr.length) * divisor) / divisor) + "\n" + (Math.floor((zero / arr.length) * divisor) / divisor);
at least it doesn't require to create and fill an(other) array
btw. you're calling arr.length 4 times, which makes it faster to define it once and use the var later
function plusMinus(arr)
{
let size = arr.length;
let positive = 0;
let negative = 0;
let zero = 0;
let divisor = 1000000;
for(let i = 0; i < size; i++)
{
if(arr[i] > 0) positive++;
else if(arr[i] < 0) negative++;
else zero++;
}
return (Math.floor((positive / size) * divisor) / divisor) + "\n" + (Math.floor((negative / size) * divisor) / divisor) + "\n" + (Math.floor((zero / size) * divisor) / divisor);
}```
Optimizations are always good
Instead of all that i did this
Wait lemme beautify it real quick
function plusMinus(arr) {
let positive = 0,
negative = 0,
zero = 0;
arr.map(element => {
if (element > 0) {
positive++;
} else if (element < 0) {
negative++;
} else {
zero++;
}
});
let numStream = 1000000;
return [
Math.floor((positive / arr.length) * numStream / numStream),
Math.floor((negative / arr.length) * numStream / numStream),
Math.floor((zero / arr.length) * numStream / numStream)
].join("\n");
}```
function plusMinus(arr) {
let positive = 0, negative = 0, zero = 0;
arr.map(element => element > 0 ? positive++ : element < 0 ? negative++ : zero++);
let numStream = 100000;
return [
Math.floor((positive / arr.length) * numStream / numStream),
Math.floor((negative / arr.length) * numStream / numStream),
Math.floor((zero / arr.length) * numStream / numStream)
].join("\n");
}```
[Wait that was my solution before i got an error right]
Just a little modified
Anyone here fluent in NodeJS? I am a bot developer who is pretty skilled in NodeJS and NEVER in my life have I ever caught Python being able to do something NodeJS couldn't do. Is there a way to make a bot respond to a command with a question, and you answer that question by typing just plain text like this?
Use message collectors with iterations over questions
@pale vessel Ur still calling arr.length 3 times, got ya 

yo i need help ive made a bot but i used botghost but i want to make currencies on different website for currencies any ideas/help
function plusMinus(arr){
arr.forEach((a,i)=>{arr[i]=Math.pow(Math.abs(a*1),-1)})
return(arr.join` `)
}
cuz the problem just wanted to show the inverse of the positive form of a number
yo i need help ive made a bot but i used botghost but i want to make currencies on different website for currencies any ideas/help
@late knot If you use NodeJS, use Fs or mongo.db. I personally use Fs as there is more possibilities, but search NodeJS Fs + economy bot and you will find an answer.
okay thank you
Np
fs 
i cud make it even shorter, like a
function plusMinus(arr){
arr.forEach((a,i)=>{arr[i]=1/Math.abs(a*1)})
return(arr.join` `)
}
and.. im still bored ๐ฟ
@viscid gale Is that Python?
no
JS?
I am fluent in JS and I don't recongnize anything but "function" and "return" there.
arr.forEach((a,i)=>{arr[i]=1/Math.abs(a*1)}) threw me off except for the "ForEach".
it's modifying the array based on the index
LET ME EXPLAIN
XD I used that system to make a leaderboard for my economy system.
no
:{
but still ;]
js is a prototyping language, and one of the prototypes in the Array class is forEach
OMG GUYS
ignored
who
The good ol' ConcurrentModificationException days
arr.forEach((a,i)=>{arr[i]=1/Math.abs(a*1)})threw me off except for the "ForEach".
as i was saying,forEachexecutes the function you give as its parameter. in that function u give, it gives ur function some parameters
- data
- index
- i can't remember
also can't remember if there r more params
u said ur fluent in js... so ur perfect to ask this..
im making a web game in which the main purpose is to "outcode" your enemies
all the game gives you is a simulated processor that takes in about 12 commands(im not finished making so im not sure if im gonna make more base commands). these commands manipulate the file system, attempt connections to other victims users, buying programs people put to sale (or selling your own).. basically a code game
for sunglases
its the least performant loop
in terms of speed?
so basically coding wars
forEach in general is poor
meh... i just think u don't like it ;]
you should look at this
im feelin makin a bot
hby
im a bit of an annoying prick when it comes to performance recently due to webscaling
^ lol
xD
small things overall dont affect your code much
i realised
but once you scale it DOES impact
i wanna make a bot that spams
so u would make a class to return an object instead of a normal function
interesting
ima foreach my foreaches of those foreaches @opal plank
i wanna make a bot that spams
@fervent sparrow
all for that extra 0.02 ms per object
bruh
honestly i cant say my style is made off any full principle
like i said, in scale it DOES affect performance with all those small nuicenses since they stack
so ur better off than me
hi i have an error but dont know how to fix it
at least i didnt make a tag
const Discord = require('discord.js')
const api = require('imageapi.js')
const client = new Discord.Client
client.once('ready', () => {
console.log('Ready!')
})
client.on('message', message => {
console.log(message.content)
})
client.on('message', message => {
if (message.content === 'pepeping'){
message.channel.send('pong!! hehe')
}
client.on('message', async message => {
if (message.content === 'pepememe'){
let subreddits = [
'memes',
'dankmemes',
'therewasanattempt',
'woooosh',
]
let subreddit = subreddits[math.floor(math.random()*(subreddits.length))]
let img = await api(subreddit)
const Embed = new Discord.MessageEmbed()
.setTitle('here ya go')
.setURL('https://www.reddit.com/r/memes')
.setColor('RANDOM')
.setImage(img)
message.channel.send(Embed)
}
client.login('secret')
^
what did i do wrong?
erwin u help cuz i gonna bounce
this confueses me
i gotta eat
lemme read the question again rq
aaahh big code scares me
hi @quiet arch please tell us the error
@earnest phoenix This is how it's done
syntax error
ig
just fix your syntax
how do i fix it?
function plusMinus(arr) {
let output = '';
for(let e of arr) output+= `${Math.pow(Math.abs(e*1),-1)}`
return output;
}```
const = constant, immutable, fixed
const is constant, can't be changed, let isn't available outside its scope (e.g. if statement)
let is for things that change
@restive furnace so you mean to tell me some one can make a bot that knows you location to a point but i cant make a bot to spam my own server
Wotdefok
@restive furnace so you mean to tell me some one can make a bot that knows you location to a point but i cant make a bot to spam my own server
@fervent sparrow you can't neither

i saw a bot on the list that uses you location to tell the weather
discord doesnt provide your location
A bot can't detect your location that's Impossible
you probably set it yourself or input the town where you want the weather from
bruh lemme see
if you provide the bot with your location, its on you
brb
again, discord does NOT provide your location
ik
when u try some thing but it goes another way
if the bot gets that info, you are the one who provide it
Only if you provide your location for the bot to recognize
Did we mention discord never provides location data? ๐
when u try some thing but it goes another way
help meh
discord ip leak when?
im done with this hackerrank

maybe it did a big brain move and stole your ip via a redirect site once you clicked upvote
imagine accounting for vpns
This guy was told to make a lake kind of thing with hashtag and he made a rainbow


This? @willow mirage
WHAT THE FUCK IS THE DIFFRENT
smh
yey but i didn't use ur method
i used only for loops
let k, j, i;
for (k = 1; k <= n; k++)
{
let string = "";
let spaces = "";
for(j = 0; j <= n-k-1; j++)
spaces = spaces + " ";
for (i = 0; i <= k-1; i++)
string = string + "#";
console.log(spaces + string)
}
Anyone has a good drop distribution algorithm?
What I was previously doing was:
["Item1", "Item2", "Item3"]
[20, 50, 30]
Then I'd make an array of 20x Item1, 50x Item2, 30x Item3 and take a random one of that but that's pretty inefficient and I also want to make it so u can increase drop chance, etc
numerical mapping?
0-19 = item1
20-49 = item2
50-79 = item3
then just rng between 0 and 79
and how would I implement that?
define rainbow
i am working on learning opengl, tried making a rainbow, failed
a 1/4 circle
like
a 1/4 circle
#
#
#
#
ye
one line ```console.log(` #
##
######`);```
@proven lantern LoL
if its just a small number of items(3)
you could just do an isbetween check for each one @tulip ledge
oh ok

if its larger, theres very likly a much better method
also, just a note. your numbers are all x10
you could just cut the numbers by /10 and it would be much much more efficient
but sometimes I have 35
there, 3 lines
smh
@willow mirage yo I hated that website in my CIS class
make sure to memoize the results for larger numbers
@willow mirage yo I hated that website in my CIS class
@faint prism what website ?
u mean hackerrank?
ah
Just looks like one of those learning websites my prof used for our class
Super nit-picky
@willow mirage Rainbow moment
i had to write an program that basically did this at work a couple weeks ago
x
x
x
x
x
xx
x x
x x
x x
x x
xx
x x
x x
x x
xx
x x
x x
xx
x x
xx
xxx
x xx
x xx
` ```
is it just me or
(expressjs)
module.exports.load = async function(app, db) {
app.get("/", async (req, res) => {
// stuff
res.send("stuf")
});
}
isnt working when i use
for (let file of apifiles) {
console.log(`./api/${file}`);
let apifile = require(`./api/${file}`);
apifile.load(app, keyv);
}
for 3+ files in the "api" folder
same for this
apifiles.forEach(file => {
console.log(`./api/${file}`);
let apifile = require(`./api/${file}`);
apifile.load(app, keyv);
})
i made a console.log("<file name> has loaded.") for all of the files and it says they loaded but... the app.get()s dont work
i tried to use a module.exports method but it still doesnt like me
try exports.varName
it worked for me at least
well in your case it will legit be exports.load
i alr tried all that
ok it works if i remove all the files but that single one
but then i need the other ones loaded too
wait
oh
OH
is it possible to... actually yes i can
i had a app.get("*", async (req, res) => {
fixed
Is there a way to check if the user is on mobile? Discordjs
From where i could find some good tutorials for javascript?
documentation + experience is the best teacher
You can also try this ig https://www.w3schools.com/js/
@bronze flume JavaScript: The Good Parts
by Douglas Crockford
I posted this before but i keep getting Error : (node:13576) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined.
Ive literally tried everything to fix this.
Code : ```shards.on("shardCreate", shard => {
console.log([${new Date().toString().split(" ", 5).join(" ")}] Launched shard #${shard.id});
let embedt5 = new Discord.MessageEmbed()
.setAuthor(Shard Online | Update!, https://cdn.discordapp.com/avatars/163804470763847680/a_bb43ba59ed24339510d344029ac88d95.gif?format=png)
.setColor("YELLOW")
.setDescription(**I am now available in ${shard.id}.**);
bot.channels.cache.get('768218401466220545').send(embedt5);
});
@unreal token try getting the guild firstbot.guilds.cache.get(guildId).channels.cache.get("768218401466220545")
o ill try that ty
@bronze flume make a leetcode account and do the problems in javascript
start with this one
https://leetcode.com/problems/two-sum/
@tulip ledge Found this https://discord.js.org/#/docs/main/stable/class/Presence?scrollTo=clientStatus
@proven lantern i get this error now (node:8136) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'channels' of undefined
that means your bot doesn't have access to the guild i believe. is it a member of the guild?
Post the line. The property channels doesnโt exist, which means u used a wrong object in front of it
wrong_obj.channels
If thereโs no channels property defined inside wrong_obj it will throw this error
Since u canโt access something that doesnโt exist
add these two logs
console.log(bot.guilds.cache.get(guildId))
console.log(guildId)
weird
i'd double check that your bot is in that guild. make sure the guildId matches
alr ima try it with a different bot and try to figure something out ty for the help
np
In how much servers is the bot currently?
Just console log the whole cache if itโs just in a few servers to see if the cache is accurate
anyone know how to use this?https://codepen.io/alexpivtorak/pen/ByJLoL
lemme check
U think deleting and reposting will grant u more publicity?
yh
@boreal iron 464
@unreal token i use it after i define channel separately and it works for me
try out
channel = bot.channels.cache.get('768218401466220545');
channel.send(embedt5)```
Uuuh I think that would be too much for the console
Sure if so try a different one and take a look at the cache
And btw. if you just wanna get a channel, you donโt have to get its guild, since channel IDs are unique
make sure you have the right channel id
o ok
bot.channels.cache ... should be good
Hello im kinda new to discord. How do I get a bot?
Is ur djs even up to date? Thought I read that cache shit came in in the latest version
djs 12 requires the cache
im sure i was using v12
I donโt see any error ๐
Of undefined
change it to shards.channels
Uhh
bot.guilds.cache.get(guildId).channels
how long can a discord id be?
Is object bot defined correctly?
yes
Just show the line please to make sure
have you tried shards.channels.cache.get('768218401466220545').send(embedt5);?
i dont see bot anywhere in your code
const bot = new Client({
disableMentions: "all"
});
just making sure
@compact briar didnt work still
Err whatโs the const for the discordjs
@compact briar when i do that i get TypeError: Cannot read property 'cache' of undefined
@boreal iron const Discord = require("discord.js");
but it wasnt used in that file
I used const { Client } = require("discord.js");
for bot
Isnโt it const bot = new Discord.Client
that was if you had bot defined as shard instead.
was talking to them
Didnโt know that, donโt know ur code
@boreal iron that does the same
@compact briar yes
but no. you can do bot = new client if you have it set to { client } = require("discord.js")
@unreal token try using the fetch method
guild.channels.cache.get().send()
Just console log the object bot please
o ok
Obtains a guild from Discord, or the guild cache if it's already available
https://discord.js.org/#/docs/main/stable/class/GuildManager?scrollTo=fetch
@proven lantern it still didnt work :v i got the same 'send' error
@boreal iron i got a big answer
send error this time and not channels error?
maybe just need to use the fetch method for the channel too
I know does the object contain an object called channels?
@proven lantern it went back to the (node:10720) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined
Or cache
guilds: GuildManager {
cacheType: [Function: Collection],
cache: Collection(0) [Map] {}
},
channels: ChannelManager {
cacheType: [Function: Collection],
cache: Collection(0) [Map] {}
},
await bot.channels.fetch('channelId')
@proven lantern if i take await bot.channels.fetch('channelId') as is it doesnt give me any errors it just goes on
but if i add .send beside it it goes bot.channels.fetch(...).send is not a function
channel.send()```
@boreal iron o thank u btw
Np I tried at least
@proven lantern im getting TypeError: Cannot read property 'send' of null
hello
it changed from undefined to null
can i confess to something stupid that i did?
does fetch return null if it doesn't find anything?
@faint prism yes
i dual booted kali linux and windows and turned out i wasn't dual booting but was installing a new system so that's nice
if your bot has access then fetch should get it. even if it's not in the cache. Obtains a channel from Discord, or the channel cache if it's already available
@proven lantern i tried it elsewhere for await and it gave me this idk why
i dual booted kali linux and windows and turned out i wasn't dual booting but was installing a new system so that's nice
@sharp thicket did you format over your windows partition?
wow, that sucks
i forgot i split that too
kali linux ended up erroring
and i had to restore windows to where i had saved it in a usb
Do you ever backup?
i used a package called prettier or some shit and it made all ' to ", is there any way to revert this? it changed it in every file ๐ญ
@earnest phoenix ez just use git reset HEAD~1 if you use source control and committed
Otherwise git reset --hard
text channel
no send function for a category channel
https://discord.js.org/#/docs/main/stable/class/CategoryChannel
text channel has one
How can I see the number of servers my bot is active on?
what library/lang
@unreal token if you log channel.type does it throw an error saying channel is null?
How can I see the number of servers my bot is active on?
How can I see the number of servers my bot is active on?
@rich stone #development message
||$5 it's d.js||
@proven lantern it wont let me log that
nvm im dumb
@proven lantern it said undefined
$5 it's d.js
@faint prism what
@faint prism what
@rich stone dude, what programming language are you using?
we cant tell you how to do anything since we dont know what language/library your using
@rich stone dude, what programming language are you using?
@faint prism Google Translate
@proven lantern bruh I tried it in a completely different file like this ```const Discord = require('discord.js');
const client = new Discord.Client();
const token = '-'
const Discord = require("discord.js");
client.on('ready', () => {
console.log('Ready!');
client.channels.cache.get('768218401466220545').send('0')
});
client.login(token);```
and it worked
i think it's the const {Client} = require
the destructor
it can break class objects in javascript
I always translate your language, don't you translate Turkish at once?
@proven lantern even when I changed that it still gives me this error idk why it gives me this error all of a sudden
Botumun Ne Kadar Sunucuda Aktif Olduฤunu Nasil Gรถrebilirim
@proven lantern welp i gtg tysm for the help
ty!
-noru @royal slate
@royal slate
ะั ะผะพะถะตัะต ะณะพะฒะพัะธัั ะฟะพ-ััััะบะธ ะฒ #general-int.
ะัะปะธ ะะฐะผ ะฝัะถะฝะฐ ะฟะพะผะพัั ั top.gg, ะั ะผะพะถะตัะต ะพะฑัะฐัะธัััั ะทะฐ ะฟะพะผะพััั ะฒ #support.
@gilded plank i was messing around, im dont speak russian
but you want me to go to general 2
okay
Someone have a command to see the number of people connected in a voice room on their server?
depends on the library
I am wondering how I can make my bot upload an embedded image to a Discord channel. I know how to make it send embeds, but how do I upload an embedded image? Is it even possible with discord.py?
Ke...
It's not that hard to search it up before asking here lol
I am aware that in discord.py, you can make the set_image of an embed a url of an image. But, I want to use a local file on my computer for the set_image instead of a url of an image.
embed = dis...
i found this
but i did look it up
Are you..just proving my point?
i had to go to google page 2
Library? Sorry I'm French so I'm using google translate
djs, eris, dpy, discordnet
i had to go to google page 2
@drifting wedge usually stackoverflow answers are at the top for me
What did you search?
add image file as embed dpy
js
google page 2, explains why you didnt find it
js has two libraries for discord(primarily)
eris and discordjs
discordjs
Emitted when the stats have been posted successfully by the autoposter
console.log('Server count posted!');
});```
what is the autoposter?
ty
np, you'll get much better results from that
I created an order but I have an error that I never got.
@solemn latch
whats the structure of voiceChannels
client.on('message', message => {
if(message.content.startsWith('!voice')) {
var Count;
for(Count in client.users.array()){
var User = client.users.array()[Count];
console.log(User.username);
}
const voiceChannels = message.guild.channels.forEach(c => c.type === 'voice');
let count = 0;
for (const [id, voiceChannel] of voiceChannels) count += voiceChannel.members.size;
message.channel.send(count);
};
});
I feel like voiceChannels is undefined
i think you want to filter rather than foreach
Yes woo
const voiceChannels = message.guild.channels.forEach(c => c.type === 'voice');
Thatโs ur issue
yes
Youโre checking each channel if itโs and voice channel, thatโs it, ur not doing anything if the statement is true
which is why i suggested filter
const vcs = guild?.channels.cache.filter((channel) => channel.type === 'voice');
I tested this ^ and it works
Does filter return the objects in this case?
ye it just returns another collection
Ah ok makes sense then
Huh imma not working with djs, so donโt nail me down on it
order user's roles in a descending order by the role position
that you need to get the user roles and order/sort them in a descending order by the role position
That should be how it is returned automatically
the api returns it unordered
What lib
Not py
dpy probably internally sorts them
the roles can get reordered again depending on the storage because of the role id
Wdym script, you mean code?
its kindof a script isnt it? technically
like javascript itself is just a scripting language isnt it ๐ค
ye
Anyway you need to code that by yourself or copy and paste shit which isnโt recommended
Just watch the docs and examples
Iโm sure somewhere around the net is an example of how to get the roles of a guild in program language xyz...
@faint prism Google Translate
@rich stone not a spoken language. A computer programming language
^ lol
console.log(e);
msg.reply(`There was an issue during your search.\n${e}`);
}```
is there a good way to check if the error was a permission error and find the permission that is missing?
if(e.includes("Missing Permissions")){
// ur code
}
if that's wrong someone correct me
what about finding the type of permission missing?
i see there is a path property
yeah a stacktrace like object
so
I don't think Discord tells you which permission you're missing, so you'd need to calculate it yourself. Though, that can only be done if you know what permissions you were trying to use as well.
I also recommend you check the code property rather than checking if the message of the error message includes "Missing Permissions" as its constant.
It's just the endpoint you hit.
So if missing permissions is there, maybe you don't have permission to view invites, or would it be to create invites, delete invites, etc.
maybe theres something in docs?
i was thinking something like if(e.path.includes("channels")){// missing channel permissions}
const audio = connection.receiver.createStream(bot.users.cache("372511780494114818"), { mode: 'pcm' });
audio.pipe(fs.createWriteStream('user_audio'));
Why is the file empty? I was speaking the entire time. Discord.js v12
uh what are you hosting on @tired nimbus ?
This is a test project
so on ur local pc?
no on a free server
the one promoted?
all dependencies with opus has been installed
ticket is still open
What is guild Limit without verification
none
100
100 can be online forever without verify, 101 will need verification
const audio = await connection.receiver.createStream("372511780494114818", { mode: 'pcm' , end: "manual"});
console.log("test")
How would you end the stream? I didnt see it in the docs?
ngl, i forget what you wanted help with its been so long @earnest phoenix
Discord.js v12

i
no that would be faster code smh
meh..
@tired nimbus do you want .close?
https://nodejs.org/dist/latest/docs/api/stream.html#stream_class_stream_readable
why not have an object... with each badge name as a key... and just loop through userBadges....
100
100 right
oh yes thank you
||People literally already answered that in 2 different channels
||
Lol
why not have an object... with each badge name as a key... and just loop through userBadges....
@tame kestrel cuz... I didnt think of it?


u wrote so much code 

enums my dude

At least
does anyone know how to set a sub-domain with cloudflare? I have an A record in my DNS pointed to my VPS IP address which I have my apache web server on. But when I search up the subdomain, I get this:
Anyone know how to get promises to work with loops in javascript?
I've tried but I just don't understand them. It doesn't seem to make the loop wait for its completion.
Oh hey Tim.
Yeah, it's the same loop as last time. A for loop as opposed to a forEach.
what is your code?
I tried a lot of different things to get promises to work but this is what my code is now:

@viral plover resolve() should be inside the visit callback, you only want it to resolve once the callback finishes
the promise itself still needs to be awaited
Where in the promise declaration do I stick the await?
Okay, thanks.
I'll try those.
generally this is how you promisify a callback:```js
let data = await new Promise((resolve,reject) => {
someFunction((data, error) => {
if(error) reject(error)
else resolve(data)
})
}).catch(console.error)
const audio = await connection.receiver.createStream(bot.users.cache.get("372511780494114818"), {end: "manual"});
setTimeout(async function () {
connection.play(audio, { type: 'opus' });
}, 5000);
Does anyone know why the play doesnt play the stream?
Im trying to record audio and play it back.
#development message can someone please help me?
What language?
Are you having trouble showing it how you want or getting the highest role?
hi
help pls Error: ENOENT: no such file or directory, open '././jsonlar/hereEngelle.json'
Is there something against doing a naming feature in my bot and people use slur stuff in the name?
I am making a command with discord.js. The idea is that whenever I do .dc <user> it will disconnect them from a voice channel. However when I use the command it just tells me the user is not in a vc. No error messages. cant figure out what is wrong
i get this error when i start my bot
For help, see: https://nodejs.org/en/docs/inspector
internal/modules/cjs/loader.js:490
throw new ERR_PACKAGE_PATH_NOT_EXPORTED(basePath, mappingKey);
^
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/rest/RequestHandler' is not defined by "exports" in /home/container/node_modules/eris/package.json
at applyExports (internal/modules/cjs/loader.js:490:9)
at resolveExports (internal/modules/cjs/loader.js:506:23)
at Function.Module._findPath (internal/modules/cjs/loader.js:634:31)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:952:27)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/home/container/bin/framework/RequestHandler.js:5:24)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}```
Can you show your /home/container/bin/framework/RequestHandler.js file
Just from searching around, it has something to do with requiring.
@arctic delta member.voiceChannel doesn't exist
member.voice.channel
ty
it worked but only for the mention, not the ID
Is that the proper way to have the ID as an alternative
looks right to me
Hey, how can I program an Avatar command?
What library are you using
See the <User>.avatarURL method: https://discord.js.org/#/docs/main/stable/class/User?scrollTo=avatarURL.
It returns the image URL of the user's avatar.
Thanks
Hello, has anyone here ever worked with time-based events? I want my bot to post a message of my choice on a new day (00:00) each time. (I'll settle for any other time at first too, can be every 10 seconds).
I'm aware that this has to be done with a @task.loop function, but all documents on the internet don't help me, because most of the time you work with @bot.event or the client, but meanwhile I only use the commands functions.
Right now I have this as an example of how I would start:
@tasks.loop(hours=24)
async def msg1():
message_channel = bot.get_channel(705524214270132367)
await message_channel.send("test 1")
but after that I'm at a loss, because get_channel is not found as a referrence in bot.py either.
Can someone help me here?
because get_channel is not found as a referrence in bot.py either.
What do you mean? Was the channel not found? Did you get an error?
i kind new and anyone can help me for java script? i wnat make this bot better as possbile
java is not javascript
- repl.it is not a good site if you want to run a Java bot.
- Java =/= JavaScript
- Do you have a good understanding of Java, because those are a lot of errors which most can be solved easily.
java is not javascript
@sonic lodge oh..... then what i use?
If I have a user id, how do i find their name?
in dpy
whichever language you want
It'll show you their nickname as a ping.
i don't want to ping them @wicked sapphire
i want to find their name
like MisterBlob
like that
MisterBlob
i have many diffrent kind lanuage
@modest smelt use bot.get_user(id) to get the user, which you can find the username from: https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.get_user
how would i do that?
i use chromebook so... only that way i can doing code or i have to use discord bot and ghostbot togther
personal or school chromebook?
personal
then download an IDE
you can install linux on it
You could install Windows or linux on it.
windows on a chromebook?
If I have a json file, with bunch of items in a dictionary in the order like this: "id number": int(number of points), how can i order them and send it to the user?
chromebook not have windows lol
You can install it lol
..... really?
you might as well get a windows laptop
bruh
oh
I built my PC
If I have a json file, with bunch of items in a dictionary in the order like this: "id number": int(number of points), how can i order them and send it to the user?
i dunno
dont answer if you dunnno
What are the rate limit on messages?
iirc, 5 messages per 5 seconds per server
ok
@modest smelt If you want to sort the values of the dictionary, you need to use sorted, get all items (keys & values), and judge from there. It's easier to explain how to do it with source code: https://stackoverflow.com/a/2258273
ok thanks
ill take a look
@sudden geyser so when you do sorted(d.values()) what does the list contain?
ok i see that
You sort the items (both keys and values). You'll get an array of tuples where the first item is the key and the second one is the value.
The link I gave you shows you how.
ah ok
is it possible to loop through every variable on an object that isnt an array
for example
{
"foo": "bar",
"variable": "value"
}
and it would output to
[
{
"name": "foo",
"value": "bar"
},
{
"name": "variable",
"variable": "value"
}
]
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries ๐ค
you can loop through the object's keys using for in, and then pushing each key / value pair to an array
yah i found
tbh I think Object.entries is a better choice unless you explicitly need it in that format you showed
yo we're not your slaves where you can just send a code and we fix it
tell us the problem
Make sure you defined what 'db' is near the top of your code. I think database?
Hi! Is there a better way of doing this in typescript?
In example:
// Currently what I'm doing is initializing a variable that is either a desired object or undefined
const guild: Guild | undefined = <Message>.guild;
// Then right after I am just doing this:
if (!guild) return;
I could force it using the ? i.e msg.guild?.id but I don't know if that's the best option or if it works the way I have it above.
is there a better way to check the permission type that is missing?
catch (error) {
if (error.path.match(/\/guilds\/\d*\/channels/)) {
msg.reply(`The bot is missing **Manage Channels** permissions. \n`).catch(console.log);
} else if (error.path.match(/\/channels\/\d*\/permissions\/\d*/)) {
msg.reply(`The bot is missing **Manage Roles** permissions. \n`).catch(console.log);
} else if (error.path.match(/\/channels\/\d*\/invites/)) {
msg.reply(`The bot is missing **Create Invite** permissions. \n`).catch(console.log);
}
}
@tame kestrel im not a ts user, but i'd say const guild: Guild? = <Message>.guild
Are you relying on an error to check permissions? I would take the time to check for permissions before you try doing anything rather than feeling the error after @proven lantern
@tame kestrel im not a ts user, but i'd say
const guild: Guild? = <Message>.guild
@quartz kindle No that isn't a typescript feature. At least the compiler doesn't like that LOL
I think asking here may be a little futile, maybe I'll whip out the ts docs and do some research
i forgot the syntax
basically make it nullable instead of oring an undefined
nevermind, i think im confusing it with type declarations
maybe, from what I see online, I think I'll just stick with what I have
ty for the help @quartz kindle @blissful coral ,
for some stuff like if I don't need to return instantly if it doesn't work, I can use something like this:
let prefix = serverCache.get(guild.id)?.config?.prefix || ';';```
where if `serverCache` has `config`, or even `prefix` `undefined`, it will set `prefix` as `;`.
I think I'll keep looking for an even more elegant solution but it seems like the docs don't have anything at the moment
does my bot need to be big to apply for higher / no ratelimits?
or is it on the bases on need?
like we have a feature that uses a ton of the ratelimit
if your bot isn't as big as dyno or mee6, then you i doubt you can apply for it
like we have a feature that uses a ton of the ratelimit
@drifting wedge then don't make such feature
it's risky
ik we want to apply for it
but like is it on the basis of bot being big
or just as needed?
they'll want u to try to do everything u can to use as little as possible
@tame kestrel o ok
how much is ratelimits usually?
ik its not specified
but like on avg?
like we have a feature that uses a ton of the ratelimit
@drifting wedge they'll probably just tell you to optimize your bot. Big bots is like 100k+
@drifting wedge they'll probably just tell you to optimize your bot. Big bots is like 100k+
@sudden geyser its not optimization
its like cuz we need to
its something we cant talk about yet
but like 100k?
ehh
thats acheivable
usually if it goes against the ratelimit then they'd probably not want something like it on their platform
well we can def make it slower
stuff like dynamic role colors, etc
oh
yea
not that but i get it
discord i think would love it tho
its really "their style"
If your bot is where it needs to hit the API a ton and want higher rate limits as a result, it may be in your favor to try refactoring how you use it. I don't think you'll need to worry about it soon, especially since the max limit right now is 10,000 requests per 10 minutes.
const guildCounts = client.guilds.cache.map((guild) => guild.memberCount);
console.log(Math.max(...guildCounts.values()));```
I tried it on my test bot... dunno if it works since it's in like 2 guilds
client is the Discord.Client object
mine would be a bit bigger tbh
wait crap that only returns the largest count huh
close enough
wait maybe u can make it smaller let me try poking it a bit more
let biggest;
let count = 0;
for(let g of client.guilds.cache)
if(g.memberCount > count) { biggest = g; count = g.memberCount}
biggest will now be your guild
reduce might've been a better call tbh
i just like to use for loops
wtf does ... do?
spread operator
actualy yeah i think i can use vars for this
really the answers here are how efficient can you make this in Big O notation
but both methods work
@tame kestrel no problem
i made this: client.guilds.cache.reduce((x, y) => x = y.memberCount > x ? y.memberCount : x, 0);
damn, good shit flaze
@pale vessel the x = y.memberCount isn't needed
client.guilds.cache.reduce((acc, guild) => guild.memberCount > acc ? guild.memberCount : acc, 0);
nice
could get even shorter: js client.guilds.cache.reduce((max, guild) => { x = Math.max(x, guild.memberCount); }, 0);
and yeah what ben said
@sudden geyser combined
client.guilds.cache.reduce((acc, guild) => Math.max(guild.memberCount, acc), 0);
yes
reduce is underrated ngl
I hardly if ever use it
i never use the let keyword in javascript
only use const
how do you only use const
i failed if i use let
dicname = {"1": 1, "2": 2, "3", 3}
for item in sorted(dicname.items(), key = lambda p: p[1]):
print("{0}: {1}".format(*item))
How can I order this so that it prints from greatest to highest
That just confused me.
Uhhhh
Uhhh
Dictionaries and sets aren't sorted
from greatest to highest
wha
@client.command()
async def leaderboard(ctx):
with open('pointspotd.json', 'r') as json_file:
lead = json.load(json_file)
embed = discord.Embed(title = "Leaderboard", description = "This the leaderboard in The Calt Server.")
for item in sorted(lead.items(), reverse=True, key = lambda p: p[1]):
idofuser = int("{0}".format(*item))
points = int("{1}".format(*item))
user = client.get_user(idofuser)
embed.add_field(name = f"{user.mention}", value = f"Points: {points}", inline = False)
await ctx.send(embed = embed)
```Do you know what is wrong with this?
Nothing is sending.
How do you even want to sort the dictionary
What does the dictionary consist of
?
You could use thumbnail
It kind puts it to the top right
But otherwise no I don't think you can
you could use the author property, but the image is rather small.
just a little haha
yea just like a litttle bit.... ...
its not like u barely see it or anything /shrug
BRUHH
what I might do is upload the image as an attachment with the embed right below but in the same msg
or yiu could use canvas nad make the entire thing an image
and then you can put the image on top of text
however its a pretty bad way and embeds are better all the time
yes I agree
sup ppl
way i cant add my bot
cause its in more than 75 servers and u have not verified it
no you are wrong @tribal dove
The bot uses gateway intents that it hasn't been verified for, but the bot is verified
so you need to re-verify it
I dislike the guy that runs it
I mean any reviews on their hosting?
Some original views not some paid ones or something
Also wtf is unlimited ram service lmao
hey how can i store a message to use after 3 messages
stupid question
How much memory do you think is enough for a bot in 100 servers ?
many factors, there isn't an accurate answer
depends on your code, if you're using crazy memory for whatever reasons then you might need more
but generally 1GB is more than enough
Then my raspberry can handle it thanks
1gb is more than enough if you have a good memory management
K
Im running 4 bots at the same VPS and the use 1.5GB 













