#development
1 messages · Page 917 of 1
implement .delete on base collection and then just call .cache.delete in it?
I love github lol, reverse changes easily throughout days
Hmm makes sense
Ill see tomorrow after work
Thanks for explaining the stuff lol
np
damn i hate typescript
but whoever did this looks like a genius, if i understand correctly they even managed to implement zlib-stream using the native zlib module
which took me a lot of shenanigans to implement
no one knows the api better than cake
what does zlib do
he’s constantly breaking it
he managed to break voice so that he could speak in it while muted and deafened, the madlad
the fact that the lib is in typescript means that the typings are actually correct
caching is rlly good, completely under your control
you can disable and enable every part of it independently
memory usage as a whole could be better tho
my bot uses like no cache except messages and uses about 50mb rss
i guess im gonna give up on my lib then
just be weary that there is no stable branch rlly
all changes are just pushed straight to master
is the lib usable without ts? or does it require your whole bot to be ts?
but there are no breaking changes ever, just small changes based on what changes in the api
no you can use js
it looks like a good start but I'm not sure if I'm ready to give up Klasa
all I would say is the docs suck, if you want to know how to do something your best bet is to read the source or ask in the support server
the command client is super hot also
I use it for my bot
it’s very hackable and uses callbacks in a lot of places for a lot of different things
if you have a big bot then the cluster client is also very interesting
I'm using Kurasuta & Discord.js + Klasa
managing groups of shards
I’ve never seen something like this implemented into a lib before
the only reason i started my own lib was to do something that i thought didnt exist, a barebones setup with no management whatsoever, but if this lib can do that, then i dont know why im even doing this
wdym no management
no caching and handling of data, 1:1 discord-api
Kurasuta handles clusters as well (groups of shards)
what you see in the discord api docs is what you get
so same thing as teh ClusterManager more or less
yeah the rest client especially follows that
all functions just take options how the api accepts them
no abstraction
You don't want a helping hand which makes sense. Especially at scale.
you can also completely disable caching
by setting client option cache to false
but yeah you have to be patient with the docs, reading source is usually easier
since everything is typed
I'll have to bookmark detritus and wait for v1
discord libs shouldnt have stable versions anyway, since discord api is always changing
yeah all changes are pushed to master
but since there’s no abstraction there can be no breaking changes unless the api has a breaking change
well, no abstraction beyond basic stuff like ratelimiting
Hmm. He probably isn't following semver then?
@quartz kindle if you want to go really low level there is also a client socket
@half bluff not rlly
yeah i was reading its source, trying to figure out how he implemented zlib-stream
client socket will probably be more useful
I wonder how the performance compares to Discord.js. Granted I don't run into performance issues that aren't caused by Discord
i hate when code is excessively split all over the place lmao, pain in the ass to read and understand
he doesn’t use third party deps for any of this btw
he even wrote his own rest module
@half bluff djs performance is terrible
this lib exceeds djs by miles but it’s slightly behind eris
why would it be behind eris?
because the shard client is slightly more abstracted than eris client
idk exactly why
Eris doesn't really have good strong typescript support does it?
well, can you disable caching in eris?
i think so? not sure
no idea, I can ask
i dont think you can
if ur too lazy
you can sweep them, but not disable them
that was my problem with both djs and eris
thats why i wrote an anti-caching framework for djs
that's where trial and error comes in handy
tias
Does Detritus have any third party projects based around it yet?
uhh some small bots use it
notsobot is being rewritten in it using the cluster client
which is an example of it being used at scale
is the cluster client designed for multi-machine?
whats so great about it?
it’s hackable and modifiable easily
uhh I don’t use it
it can be used on single machine
I think multi machine as well?
there are no good multi-machine systems, thats why i ask
how do i remove a percentage from an int? like i wanna remove a 10% from a number. How?
Like your number is 5.10 and you want to remove the .10?
Oh. You've got a string you want to convert to an int
same thing just change the syntax
@quartz kindle For multi-machine kurasuta handles it?
i am making an economy system and i added this command called transfer that lets you transfer an amount from your bank/credit into another persons bank/credit and i wanted to add a fee system for example 10% fee for every transaction so how would i do that?
no...
100 * .1 = 10% of 100 = 10
So in your transfer logic you do amount * .9 as the transferred amount
and if you're moving the 10% somewhere you can do amount * .1
but if you're just evaporating it you only have to worry about the * .9
remamt = int(amount) - (100 * .1)
like that?
i am a bit confuzed bc i never did something like this before tbh..
yeah that should work
Yes.
not make my amount to a float number
so if you're removing 10% you do .9 instead of .1
and if you don't want a float you'll have to round it
so
remamt = int(amount) * .9
will remove 10% from
my amount
?
thats just multiplying tho... where the removing part?
i really confuzed.. 😅
owhhh
then my amount will be a float and i'll have to round it so i get the results that i need right?
alr lemme try it
I googled it. Apparently int() in python rounds
so
amount = '100'
remamt = int((int(amount) * .9))
print(remamt)
if you remove 10% from 100 you get 90
it'll print 90
as an int
dude
What's the best practice for listening to reactions on uncashed messages?
const Canvas = require("canvas");
if (message.content.startsWith(prefix + "triggered")) {
const canvas = Canvas.createCanvas(200,200);
const ctx = canvas.getContext('2d');
const background = await Canvas.loadImage('https://cdn.glitch.com/32b593a8-b636-49b1-8f62-c50f49f186fe%2F200.gif?v=1588981925859');
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
ctx.strokeStyle = '#74037b';
ctx.strokeRect(0, 0, canvas.width, canvas.height);
// Wait for Canvas to load the image
const avatar = await Canvas.loadImage(message.author.displayAvatarURL);
// Draw a shape onto the main canvas
ctx.drawImage(avatar, 0, 0, 250, 160);
const attachment = new Discord.Attachment(canvas.toBuffer(), 'welcome-image.png');
message.channel.send(`**triggered**`, attachment);
}```
how could i make it so the image is a gif?
canvas doesnt support animated gifs
amount = '100'
remamt = int((int(amount) * .9))
print(remamt)
after alot of fixing
and testing around
turns out as i thought
this just multiplies
and not removes...
anyone got a better silution?
(python:
)
Sounds like you need to further clarify what exactly you mean.
i just need to remove 10% from an amount.
At this point with the language barrier(?) perhaps some examples of what you're trying to accomplish?
Is your goal to have remamt be the 10% value of the remainder (the 90%) value?
i just need to remove 10% from an amount for example 20000 and thats it.
So what's 20000 after you remove 10%?
20,000 - 10% is 18,000
So your goal is to get the 18,000 number right
so you can save it to your database
yes
That's exactly what my code I sent you does.
So I'm not quite sure what issue you're running into
Something must be screwed up in the logic somewhere then
i just did
add it to the bank of the given user
so there is something else going wrong. Do you have a bigger code example?
lemme show u
addamt = int(pbank) + int(amount)
addamtwithfee = int((int(addamt) * .9))
remamt = int(amount) - int(bank)
db.child(ctx.guild.id).child(member.id).update({"wallet": pwallet, "bank": addamtwithfee})
db.child(ctx.guild.id).child(ctx.author.id).update({"wallet": wallet, "bank": remamt})
if your wondering what the hell is that database then.. its firebase 😆
prob the first person u see using it
lol
So to break it down - I assume "pbank" is the current value in the players bank?
And "amount" is the amount argument passed to the command, in string form (considering you're converting to int)
yes
if(message.content.startsWith(prefix + 't')){
const GIFEncoder = require('gifencoder');
const { createCanvas } = require('canvas');
const fs = require('fs');
const encoder = new GIFEncoder(320, 240);
// stream the results as they are available into myanimated.gif
let ad = encoder.createReadStream().pipe(fs.createWriteStream('myanimated.gif'));
encoder.start();
encoder.setRepeat(0); // 0 for repeat, -1 for no-repeat
encoder.setDelay(500); // frame delay in ms
encoder.setQuality(10); // image quality. 10 is default.
// use node-canvas
const canvas = createCanvas(320, 240);
const ctx = canvas.getContext('2d');
// red rectangle
ctx.fillStyle = '#ff0000';
ctx.fillRect(0, 0, 320, 240);
encoder.addFrame(ctx);
// green rectangle
ctx.fillStyle = '#00ff00';
ctx.fillRect(0, 0, 320, 240);
encoder.addFrame(ctx);
// blue rectangle
ctx.fillStyle = '#0000ff';
ctx.fillRect(0, 0, 320, 240);
encoder.addFrame(ctx);
encoder.finish();
}``` so im trying to use gif encoder but i cant figure out how to send it
"wallet" is the author's wallet value and
"bank" is the author's bank value and
"pwallet" is the member's wallet value and
"pbank" is the member's bank value.
so we aren't changing wallet or pwallet correct?
@queen needle you can send the stream directly to discord
the goal is to take amount from bank and deposit it in pbank, minus a 10% fee?
exactly
so say pbank = 100K
and bank = 100K
and amount = 20K
after the transfer bank should have 80K and pbank should have 118K
exactly
How
@queen needle js let stream = encoder.createReadStream(); message.channel.send({files:[{attachment:stream,name:"myfile.gif"}]})
so say pbank = 100K
and bank = 100K
and amount = 20Kafter the transfer bank should have 80K and pbank should have 118K
@half bluff so do you know how to make that happen?
# amount being transacted
amount = '20000'
# author (giver) bank
bank = '100000'
# receiver bank
pbank = '100000'
fee = int(int(amount) * .1)
bank = int(bank) - int(amount)
pbank = int(pbank) + (int(amount) - int(fee))
print("author bank", bank)
print("receiver bank", pbank)
print("author paid",fee,"fee")
This is how I would do it @wise quartz
fee = int(int(amount) * .1)
bank = int(bank) - int(amount)
pbank = int(pbank) + (int(amount) - int(fee))
@quartz kindle do you know how i could set the background to a image i already have
fee = int(int(amount) * .1)
bank = int(bank) - int(amount)
pbank = int(pbank) + (int(amount) - int(fee))
^^^ alr i will try this ^^^
@half bluff i tried to transfer 20k and thats the results
if (message.content.startsWith(prefix + "t")) {
const GIFEncoder = require('gif-encoder-2')
const { createCanvas } = require('canvas')
const { writeFile } = require('fs')
const path = require('path')
const size = 200
const half = size / 2
const canvas = createCanvas(size, size)
const ctx = canvas.getContext('2d')
function drawBackground() {
ctx.fillStyle = '#ffffff'
ctx.fillRect(0, 0, size, size)
}
const encoder = new GIFEncoder(size, size)
encoder.setDelay(500)
encoder.start()
drawBackground()
ctx.fillStyle = '#ff0000'
ctx.fillRect(0, 0, half, half)
encoder.addFrame(ctx)
drawBackground()
ctx.fillStyle = '#00ff00'
ctx.fillRect(half, 0, half, half)
encoder.addFrame(ctx)
drawBackground()
ctx.fillStyle = '#0000ff'
ctx.fillRect(half, half, half, half)
encoder.addFrame(ctx)
drawBackground()
ctx.fillStyle = '#ffff00'
ctx.fillRect(0, half, half, half)
encoder.addFrame(ctx)
encoder.finish()
const buffer = encoder.out.getData()
let ad = writeFile(path.join(__dirname, 'output', 'beginner.gif'), buffer, error => {
message.channel.send(ad)
})
}``` it says cant swnd empty message
@wise quartz If you transferred 20K an the guy originally had 20K wouldn't that be the expected result?
So something is screwed up in the logic again. The code I sent you worked. I even sent you the online IDE showing it working as well.
Can you DM me the full command so I can try to wrack through the logic?
or post it here idc
It shouldn't be this complicated I'm not quite sure what is being done wrong.
Alr i'll dm you it
But just saying if you try it on ur end
It wont work
Cuz the database i am using
Requite some private stuff
That i cant share
I know it won't. I'm just trying to go over the logic
Alr lemme send u it
I'll make it a pastebin
Cuz rn i am on my phone
Uhm listen i cant rlly send it to u now cuz i turned off my laptop and accessing github from my phone is a bit laggy so tmr alr.@half bluff gn
gn
discord.js v12: What exactly does guild.fetch() accomplish?
probably fetch and cache a guild
I'm curious what it caches
Question friends, I think I'm missing something. I can get a role by it's ID no problem. But, how do I get it by name?
idk
I found an easier way to do it other than looping through roles 😄
message.guild.roles.cache.find(role => role.name === "Role Name")
if (message.content === "=buy computer") {
let user = message.mentions.users.first() || message.author;
let items = await db.fetch(`items_${user.id}`)
items.push(`items_${user.id}`, 'computer')
}
if (message.content === "=inventory") {
let user = message.mentions.users.first() || message.author;
let items = await db.fetch(`items_${user.id}`)
let embed = new Discord.MessageEmbed()
.setColor("BLURPLE")
.addField("items", items)
message.channel.send(embed)
}```
when i use buy commadn this happens
(node:16219) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'push' of null
at Client.<anonymous> (/Users/sadashivappakenchannavar/Desktop/Rusty Beta/bot.js:112:11)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:16219) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:16219) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
can someone help me
do you have a file named bot.js?
yes
Go to line 112 copy it and send that
items.add(items_${user.id}, 'computer')
Why are you trying to push an item?
cos its part of the buy command?
yea i did lol
await db.fetch(`items_${user.id}`) is returning null for whatever reason
Idk what db you use, and even if I did, I wouldn't know how it worked, but that may help others assist you
What
i sent my code above
Anyone know the gist of using emote reactions for pagination in JDA?
Specifically just how to handle the event/callback
JDA = bad
How can I know a user has voted my bot or not?
sql is easy
if (message.content.startsWith(prefix + "blur")) {
const canvas = Canvas.createCanvas(200, 200);
const ctx = canvas.getContext("2d");
const background = await Canvas.loadImage();
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
ctx.fillStyle = "#ffffff";
ctx.filleRect(0, 0, canvas.width, canvas.height);
ctx.filter = "blur(5px)";
const avatar = await Canvas.loadImage(message.author.displayAvatarURL);
// Move the image downwards vertically and constrain its height to 200, so it's a square
ctx.drawImage(avatar, 25, 25, 200, 200);
const attachment = new Discord.Attachment(
canvas.toBuffer(),
"welcome-image.png"
);
// Wait for Canvas to load the image
message.channel.send(attachment);
}``` im trying to create a command to blur a persons profile picture but its not sending anything
and theres no errors
i got it to send the image but its not blurrying it
nvm
@queen needle t fr?
what
my bot got whitelisted in discord now waiting for Top.gg to approve my bot but soon
i worked so hard
if (message.content.startsWith(prefix + "blur")) {
let jimp = require("jimp")
const user = message.mentions.users.first() || message.author;
let welcome = await jimp.read(message.user.displayAvatarURL) //We load the image from that link
welcome.gaussian(2.5);
welcome.write('Welcome2.png') //We create a png file called Welcome2
message.channel.send(``, { files: ["Welcome2.png"] }) //We sent the file to the channel
}``` cant read properpty of displayAvatarURL
Discordjs version?
wait
11.5.3
jimp.read(user.displayAvatarURL)
See if it works
U should upgrade to v12
my bot got whitelisted in discord now waiting for Top.gg to approve my bot but soon
@weak tree
Whitelisted?
yes
Verified Bot Developer
dwb
@earnest phoenix it works but it doesnt blur the person i mention
Cool
how is that cool it doesnt work?
welcome.gaussian(increase it)
try this ^
can we use express and dbl webhook at the same time?
welcome.gaussian(5) @queen needle
If not blurred increase it
When we submit our bot for review its being tested using permissions=0 how would they be able to test admin only commands?
Umm
Admins can use admin only commands
i think permissions=0 will give no role on joining
Im making a captcha verification bot with no external packages XD
way out of my league lol
What's the best way of detecting that a websocket client has refreshed the page / reconnected very quickly
@earnest phoenix i did that once
ok
someone would have an example of a "chartjs-node-canvas" code
Why did my bot turn off for no reason? :C
sorry i broke my crystal magic ball so unfortunately you will have to tell us that
@distant plank see logs
There must be any error
fix that error and restart bot
@earnest phoenix nop, in the console there are no errors
Bot will go offline after 5 mins if its inactive
use uptimerobot to keep it online
brb
@earnest phoenix ready.
Now do I have to wait?
Hey, I am super new to discord bots and coding in general, should I start writing my base code in index.js or another file?
doesn't really matter how you name your file so
so just any file will work?
okay, thanks!
hello I want to make a system of "rank", problem I think that I did something wrong somewhere because it does not work
const canvas = createCanvas(1000, 333);
const ctx = canvas.getContext('2d');
const xp = "600"
const lvl = "1000"
let image = await loadImage("https://cdn.discordapp.com/attachments/412414337848967185/708564854096789535/fond-couleur-noir-dim33x23cm.jpg")
ctx.drawImage(image, 0, 0, canvas.width, canvas.height)
ctx.beginPath()
ctx.lineWidth = 4
ctx.strokeStyle = "#ffffff"
ctx.globalAlpha = 0.2
ctx.fillstyle = "#000000"
ctx.fillRect(180, 216, 770, 65)
ctx.fill()
ctx.globalAlpha = 1
ctx.strokeRect(180, 216, 770, 65)
ctx.stroke()
ctx.fillstyle = "#000000"
ctx.globalAlpha = 0.6
ctx.fillRect(180, 216, ((100 / (lvl) * xp) * 7.7, 65))
ctx.fill()
ctx.globalAlpha = 1
ctx.font = "30xp Arial"
ctx.textAlign = "center"
ctx.fillStyle = "#ffffff"
ctx.fillText(`${xp} / ${lvl}`, 600, 255)
ctx.textAlign = "left"
ctx.font = "50px Arial"
ctx.fillStyle = "#000000"
ctx.fillText(message.author.tag, 300, 180)
ctx.arc(170, 160, 120, 0, Math.PI * 2, true)
ctx.lineWidth = 6
ctx.strokeStyle = "#ffffff"
ctx.stroke()
ctx.closePath()
ctx.clip()
const avatar = await loadImage(message.author.displayAvatarURL)
ctx.drawImage(avatar, 40, 40, 250, 250)```
hm
@distant plank
Done with uptimerobot?
Since I shard I have this error here: await client.channels.cache.get (" 620548901258133515 ").send
cannot read proprety send but the channel exist..
@wicked pivot Increase size of text its very small
client.channels.cache.get("id").send
this is not the problem, in the "rectangle" it is supposed to have the progression of the user
client.broadcastEval(client.channels.get(...))
uh yeah thx
add cache after channels if its v12
client.broadcastEval(client.channels.cache.get("id").send)
ye or client.shards.broadcastEval, im not sure try both
ye
i found this on stackoverflow: await shardingManager.broadcastEval(`this.guilds.get('352896116812939264').roles`);
@earnest phoenix yes
client.shard.broadcastEval(`this.guilds.size`) @earnest phoenix try this does this return array of guild sizes in different shards?
ye is good this
await client.shard.broadcastEval(client.channels.cache.get("620548901258133515")).send
Cannot read proprety send
@earnest phoenix but the bot is still off
kk
try then let a = await client.shard.broadcastEval(`client.channels.get("id")`) and then try to send like a.send("smh") @earnest phoenix
ok
(node:2747) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'filter' of undefined
(u = message.mentions.users.first() || message.author;)
u.roles.filter(r => r.name != @everyone).join(",")
Discord js 11.6.3
u.roles doesnt exists
and its message.mentions.first
and it needs to be member, like user.member to get member object of it
\n
i dont know 'NQN' bot
My Message: message Link
NQN Bot's Message:
idk what it is called
I want to add this feature in my bot
that just takes message data and puts some properties in an embed
and then sends it off via a webhook
How to do this
in which library
Discordjs
https://discord.js.org/#/docs/main/stable/class/TextChannel?scrollTo=messages
https://discord.js.org/#/docs/main/stable/class/MessageManager?scrollTo=fetch
https://discord.js.org/#/docs/main/stable/class/TextChannel?scrollTo=createWebhook
https://discord.js.org/#/docs/main/stable/class/Webhook?scrollTo=send
this is everything you need in order
same error @restive furnace
try then
let a = await client.shard.broadcastEval(`client.channels.get("id")`)and then try to send like a.send("smh") @earnest phoenix
@restive furnace
This and client is not defined
give your full code (in dms with removed token if u are scared someone steals ur code)
is in the guildCreate.js file
np
does anyone know how to remove a guildId from all the tables in MYSQL ?
if(fetchedMsg <= "5000"){
var lvl = "5000"
var grade = message.guild.roles.get('703581177755467856').name
}else if(fetchedMsg >= "15000"){
var lvl = "15000"
var grade = message.guild.roles.get('703583285854601276').name
}else if(fetchedMsg >= "30000"){
var lvl = "30000"
var grade = message.guild.roles.get('703583233031274548').name
}else if(fetchedMsg >= "50000"){
var lvl = "50000"
var grade = message.guild.roles.get('707659936859029544').name
}else if(fetchedMsg >= "100000"){
var lvl = "100000"
var grade = message.guild.roles.get('708027073905819669').name
}else if(fetchedMsg >= "1000000"){
var lvl = "1000000"
var grade = "Tu n'a plus aucun grade à débloquer maintenant c'est que du fun mon ami"
}```
with eris the command to edit the bot status is https://cdn.lumap.me/kcsl7q5l.png , but the bot just doesnt hav any status wtf
its beeen 5 minutes
wait lemme look how i did it on my old eris bot
bot.editStatus('idle', {
name:"hi",
type: 2,
url: 'https://twitch.tv/ninja'})
from my old bot
can someone help me ?
is there a way to delete guildId from all the tables in MYSQL ?
hmm
can someone plzz help mw
3|Lavalink | 2020-05-09 00:05:23.143 INFO 5936 --- [ parallel-1] s.n.m.impl.connections.AudioWebSocket : Closing```
seems to have worked
@quartz kindle i looked into cluster client and yeah you can just specify shard range for each machine you want to run the bot on so it’s super easy (https://github.com/detritusjs/client/blob/master/src/clustermanager.ts#L18)
but whats the point using different machines per cluster?
load balancing
you can have multiple clusters on one machine as well lol
it’s the exact same thing
i need some help with leveling system
just ask
@fossil ice explain
at what point are you having difficulties?
point out your language/library so others can help
Ah yes sure
just leave
we can definitely help you when you leave
god damn it
Using discord.js v12 is it possible to get the number of servers the user owns - From the servers the bot is on. The bot has been sharded
i need help
In Discord.py
I have the leveling system
and it works
but i need the level command
to check what level i am
can anyone help me
Wait patiently
Okay Sure
message.channel.updateOverwrite(channel.guild.roles.everyone, {SEND_MESSAGES: flase});```It says this has error but dont understand what id it
But for what tho @heavy marsh
To get help for your question
ok lol
yes
easy
But I will have to use shardmanger right?
yeah if you're sharding
yep the bot is sharded
just use fetchClientValues
can anyone help
discord.gg/dpy discord.gg/python prob better places to ask
ummm. access the db and look for the level?
What's a db 😅
database
@willow frigate
no random pings 
Ok I am confused on how to filter
message.channel.updateOverwrite(channel.guild.roles.everyone, {SEND_MESSAGES: flase});```It says this has error but dont understand what is it
Help me plz
error is message.channel undefined
const promises = [
bot.shard.fetchClientValues('guilds.cache.size'),
];
Promise.all(promises).then(results => {
const totalOwned = results[0].filter(g => g.ownerID === e.UserID , 0);
message.channel.send(totalOwned)
});```
Is it like this? - @pale vessel
@thorny meteor it is false not flase
Ok
but thats not the err
no french
Then send in the error
#memes-and-media please
where did you get e?
premiumdb.find({}, (err, res) => {
if (err) return resolve([]);
if (!res) return resolve([]);
res.toArray().then(resolve);
});
})).map((e, i) => `${i + 1}. <@${e.UserID}> \`[ ${e.UserID} ]\` | Premium: \`${e.premium}\``);
Ofs
oks*
I got object promise
premiumdb.find({}, (err, res) => {
if (err) return resolve([]);
if (!res) return resolve([]);
res.toArray().then(resolve);
});
})).map((e, i) => `${i + 1}. <@${e.UserID}> \`[ ${e.UserID} ]\` | Premium: \`${e.premium}\` | Servers: \`${Promise.all(promises).then(results => { results[0].filter(g => g.ownerID === e.UserID , 0)})}\``);
@bitter sundial can I ask you a question?"
👀
i've never used this method before so i'm not sure
Is there any other method ?
don't think so
ooh am ok
Nope
fairs just wondered
so im having problems with mine
apprently this is not defined according to someone
as it keeps letting me bump over and over again
const timeDifference = result[0].timeDifference ? result[0].timeDifference : 3600;
const remainingMinutes = Math.floor((cooldown - timeDifference) / 60) const remainingSeconds = timeDifference - remainingMinutes * 60;
fetch("WEBHOOK URL HERE", {
method: "POST",
headers:{
'Content-Type' : "application/json"
},
body: JSON.stringify({
embeds: [
{
title: `${client.emotes.leave} Serveur en moins`,
thumbnail: {url: guild.icon ? guild.iconURL() : `https://dummyimage.com/128/7289DA/FFFFFF/&text=${encodeURIComponent(guild.nameAcronym)}`},
color: "RED",
fields: [
{name: "👑 Propriétaire: ", value: guild.owner.user.username, inline: true},
{name: "📋 Nom du serveur :", value: guild.name, inline: true},
{name: "👤 Nombre de membres :", value: guild.memberCount, inline: true},
{name: "🛠 __Identitiant du shard__ :", value: guild.shard.id, inline: true}
]
}
]
})
})```
This code is in my guildDelete event, the URL is good, node-fetch is installed, but the bot don’t send the webhook embed. There are no one error in the console. how can i do?
There probably is an error in the response
why are you using fetch
discord.js already wraps webhooks
hey all; how would you go about sending an embed to a text channel on a different shard
dispatch(content, channel) {
let e = `
(async () => {
let channel = await this.channels.fetch("${channel}");
if (!channel)
return;
channel.send(${content});
})();
`
console.log(e);
this.client.shard.broadcastEval(e);
}
obviously wont work
how to add unknown message command
I tried this
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
return
raise error
await ctx.send(":replit: Unkown Command.") ```
how i can make bot display the wiget
from top.gg
if(message.content.startsWith(prefix + 'restart')){
resetBot(message.channel)
function resetBot(channel) {
// send channel a message that you're resetting bot [optional]
message.channel.send('Restarting...')
.then(msg => client.destroy())
.then(() => client.login(token))
.then(message.edit("Restarting has finished"))
}
}```
how can i edit the message?
Grab the message on start and edit it.
how to add unknown message command
@earnest phoenix don't do that
why?
why not @earnest phoenix
two line breaks is one in markdown @earnest phoenix
a
it looks the same
@earnest phoenix it's a bad practice and your bot will get muted in every bot list server you're in, it's annoying to your end user and you're wasting a request on the 5/5 ratelimit
@earnest phoenix try adding two spaces and then a line break; https://gist.github.com/shaunlebron/746476e6e7a4d698b373
how could i add a await in a .then
because that's not how async works?
@earnest phoenix oh, worked now, thanks
you either use await/async or promise design
how i can make bot display image from a link (http://example.com/image.png) ??
what
Hey, just gonna bump this message -> https://discordapp.com/channels/264445053596991498/272764566411149314/708627929139249152
it's been a couple hours of struggle and I could use the help
i would help if i could but i dont even know what a shard is
@late plank broadcastEval can only send primitive data, so you either need to stringify the embed, or build the embed inside the eval
if (message.content.startsWith(prefix + "ninjakill")) {
if (message.author.id == "408080307603111936")
return message.reply("lol no your blacklisted");
if (message.author.bot) return;
if (message.mentions.users.first().id === message.author.id)
return message.reply("You cant kill yourself");
message.delete()
message.channel.send(args[0] + " was killed");
}```
it doesnt delete my message?
because you returned
maybe your bots has no perm?
learn how to use return
it should be the last thing you use
you don't even need it
i thought it was a replace for else?
nope
i do for the message.author part
that's fine
but you have more script after the reply
so you can't return message.reply
if (message.content.startsWith(prefix + "ninjakill")) {
if (message.author.id == "408080307603111936")
message.reply("lol no your blacklisted");
if (message.author.bot) return;
if (message.mentions.users.first().id === message.author.id)
message.reply("You cant kill yourself");
message.delete();
message.channel.send(args[0] + " was killed");
}
so like that
yeah but do i need to?
okay thank you
by the way, you should put message.author.bot outside commands so that you don't need to repeat it
must be in the message event though
lol I just saw I changed a href markdown on my top.gg page for all href's there are 😂 (please don't look at it)
How to solve it? Can I just use another word/character?
what do you mean
oh right, I don't explain it correctly. So I added some a href things to my section of the bot page and gave it some style (the a element), but now other standard buttons like Join support server are also with that markdown.
oh why don't I just try and see
no it doesn't work
you need to make it specific to that link only
can't I use something live <div> and give it an id and I can give style to that id?
okay thanks will try
<a href="" id="unique">hi</a>
#unique {
}
oh yes it works (but without #)
a class would work too
There can be multiple elements with the same class
well, id too
id is unique so you can only have one element with a certain- oh?
oh so if I want to use that style more often I should/you recommend using class?
yes
so if you're styling a button, you would need class and if you're styling a logo, you would need id, something like that
oh okay thnx 👍
because you'd typically have many buttons but one logo
yes but I don't have many now as I'm a noob 😁
but when you need more, you can apply the same class
okay right
I have a question
my bot was rejected because of safe search
however I have enabled that
Your bot was likely declined because it broke one of the "bot rules" listed in #rules-and-info.
To find out why your bot was declined and by who, use the search feature in #mod-logs:
but does urban dictionary count as nsfw
yes
Yes
oh
And that's a question not for #development
where can I sak that?
how can I even set the background for the window I can edit of my bot's page? body doesn't work, section doesn't work (when I do all my html in between <section></section>) and just background-color does not work
I white this in my index.js but my bot not divided into several shards. Do I have to add something in my bot.js?
const { ShardingManager } = require('discord.js');
const manager = new ShardingManager('./bot.js', { token: 'token' });
manager.spawn();
manager.on('shardCreate', shard => console.log(`Launched shard ${shard.id}`));```
how can I even set the background for the window I can edit of my bot's page? body doesn't work, section doesn't work (when I do all my html in between <section></section>) and just background-color does not work
I tried ctrl shift C and I and I found the long description has class "longdescription" and/or "content"
@restive night manager.spawn([number of shards])
Menno try putting !important
@cinder patio oh yes it's working, hero
Hey quick question
If you want your bot to use custom emojis, it points to a dedicated url to a custom server right
is there something more permanent than that type of url?
@maiden mauve do you see that id in the url you sent? If you type your bot types :emojiname: it will send the emoji
really Discord? 🤦
wait
lol
:emojiname:
So every custom png gets a snowflake?
no
the bot has to be in the server
what?
Error [SHARDING_READY_TIMEOUT]: Shard 0's Client took too long to become ready.
how to fix this? I use djs v12
oh I see what your saying
the bot has to be in the emoji discord
and anywhere else
☑️
thanks
np
@restive night any err?
can i edit json file
like prefix: "/" and i will change it to prefix: "!"
yes
but please don't use a json file as database, I did that and then spent even more time to convert it to a proper database
LoL
i have a quuestion
why tf my bot gets declined by having nsfw commands and theres a lot of bots that are nsfw on the page?
!help
Cuz the A lot of bot can use only in nsfw channel
Please don't ask that in #development, but I think you mentioned NSFW, and might have nsfw command working in none nsfw channels. @leaden flare
Hey! Bots aren't given permissions to send responses in this channel. Please use #commands or #265156322012561408 to run commands. In addition, bots with commonly used prefixes cannot read or send messages in any channel. This is done to prevent spam and bot abuse.
Oh they left.
all my nsfw commands are only avaliable on nsfw channels
Well you mentioned nsfw in the bot description.
Please move that conversation to #general
For all those people who find it more convenient to bother you with their question rather than search it for themselves.
idk what "a counting thing" is
https://oliy.is-just-a.dev/88vtwr_3876.png the first result on it has all this info
if it would embed
man just google coronavirus api
you send http requests
you can use any http api in python
just send an http request
@bot.command()
async def corona(ctx):
await ctx.message.delete()
headers = {"Accept": "application/json"}
async with aiohttp.ClientSession() as session:
async with session.get("https://api.covid19api.com/summary", headers=headers) as req:
r = await req.json()
await ctx.send(r["TotalConfirmed"])
await ctx.send(r["TotalDeaths"])
await ctx.send(r["TotalRecovered"])
will this work?
Is this a bad cooldown system for a big discord bot? https://discordjs.guide/command-handling/adding-features.html#cooldowns
is it free?
what's the syntax error in this mysql call?
code: 'ER_PARSE_ERROR',
errno: 1064,
sqlMessage: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1",
sqlState: '42000',
index: 0,
sql: 'SELECT * FROM timezones WHERE user_id = 165937223554826241)'
}
isn't this correct syntax?
I mean you have a random ) at the end
seañToday at 14:41
@bot.command()
async def corona(ctx):
await ctx.message.delete()
headers = {"Accept": "application/json"}
async with aiohttp.ClientSession() as session:
async with session.get("https://api.covid19api.com/summary", headers=headers) as req:
r = await req.json()
await ctx.send(r["TotalConfirmed"])
await ctx.send(r["TotalDeaths"])
await ctx.send(r["TotalRecovered"])
can someone
confirm this will work?
or am i dumb
sean I don't know much python but the scope of r doesn't look like it's accessible
Is this a bad cooldown system for a big discord bot? https://discordjs.guide/command-handling/adding-features.html#cooldowns
anyone knows?
Define big
Well... what are the errors?

hey
i used bot.destroy() but not working
is there any way to check if the message author has voted in the past 12 hours ?
@hasty lotus if u console.log u can loook at log
or u have to make ur bot dm you
maybe not
or if anyone vote
:/
i tried this :
dbl.hasVoted(message.author.id).then(voted => {
if (voted) {
//command script
}
});```
it's the example on the dbl api doc
but it runs anyway
even if you haven't voted
😐
check this
when someone vote it will write to json file, and then you can simple with one command to read json file
Now pls help
How i can restart the bot
i tried bot.destroy() but not working
you can use client.destroy() function
yes but not working
but it will stop the bot
it will just stop it
not restart it
there isn't any way of making a command that stops the process and restarts your index
and thank you i know what is json
You could use a process manager to restart the bot automatically when it's shut down
with process.exit(1) ??
forever start index.js
oof
so how i can change the prefix
cuz when i changed the prefix but bot still running with old prefix
with ?
idk
process.exit(1) ??
yes but i am testing on my local
aha
but i saw someone try it ?
then it's not a full restart
to stop the process you have to stop running your index
but if your index stops
then it can't run anything
so it can't run a command to restart itself
ok
the index is a bit like the heart of your code
if you remove the heart
it dies
and i can't make anything to save himself
how to load command to all shard?
no
i wanted to change bot prefix with command
@flat pelican 
but it still with old prefix
so i need to reload the bot
@earnest phoenix
you can do something
like that reads a json file
like do a config file
and at every message var { prefix } = require("./config.json")
i have done same thing
so i saved prefix data to json file
and then i use comamnd to edit the prefix value
ok send your index
but i need to restart the bot
send your index
do you have a cmd handler ?
and send your prefix changer command too
yes
#credits
Typo in "Corna Virus"
oh wait
How do I learn JavaScript
umm.. google?
I thought there were websites
there are
lol
Do You have to pay for them
nope
I don't know, why don't you check them out by clicking them.
imagine having to pay for javascript lesson
xdd
Can someone help on my db = mongooes
Using discord.js v12
//Conneting To Voice Channels
manager.on("shardCreate", shard => {
shard.on("ready", async() => {
if(shard.id === manager.totalShards - 1) {
const db = mongoose.connection.collection('server');
db.find({ voiceID: { $ne: undefined }}, (err, doc) => {
if (err) return console.error(err);
doc.toArray((err, docs) => {
if (err) return console.error(err);
docs.map(d => shard.channels.cache.get(`${d.voiceID}`)).filter(Boolean).forEach(c => {
c.join();
});
});
console.log(`[ Bot Joined Voice Channels ] Bot joined ${doc.voiceID.length}`);
});
};
});
});
The bot doesnt connected to the voice channel
imagine having to pay for javascript lesson
sounds like java
@heavy marsh are you sure shard.channels is a property.
I dont get any errors
Hey, I'm about to change my code a bit so I will do con.connect() and con.disconnect() with every query I'm executing on my mysql database, as some here said that's preferable. Is that right?
yeah
what version of discord.js
this is kinda off-topic: but wheres cold flazepe?
gone
r.i.p
yeah
@pale vessel I guess you said that too the other time, but I believe you xd
what version of discord.js
v12.2.0
like kinolite said, are you sure shard.channels is a thing?
Shard !== Client
Then how can we get the channels?
What I am trying to do is make the bot join the voice channels as all the shards are connected
you'll have to use https://discord.js.org/#/docs/main/stable/class/Shard?scrollTo=eval
@limber flume are you using js or py?
shard.eval()
How i send a message in java?

^
For all those people who find it more convenient to bother you with their question rather than search it for themselves.
python
ahh, idk any python so i cant really help you with that
damn
does this look nice or should i add links
to like support server
scltxnToday at 17:58
guys im wanting to add premium commands to my bot what should i give it
i think
maybie
you caught me
ofc
I'm searching a js api that triggers a event if a google forms gets a new response, but I cant find anything. do u guys know smth to do that?
console.log("Channel with ID: " + channel.id + " was just created");
});```
So I want to send this to my channel ID, how can I do that?
my channel ID
wdym
So I want it to send to the specific channel
client.channels.cache.get("channelID").send('...')
Is that for v11?
for v11 remove .cache
Alright, thanks again :)
np
//Conneting To Voice Channels
manager.on('shardCreate', (shard) => {
shard.on('ready', async () => {
if (shard.id === manager.totalShards - 1) {
const db = mongoose.connection.collection('server');
db.find({ voiceID: { $ne: undefined } }, (err, doc) => {
if (err) return console.error(err);
doc.toArray((err, docs) => {
if (err) return console.error(err);
console.log(docs);
docs
.filter((d) => d.voiceID)
.map((d) => {
shard.eval(
`let channel = this.channels.cache.get('${d.voiceID}');
if (channel) channel.join().catch(() => {})`
);
console.log(
`[ Bot Joined Voice Channels ] Bot joined ${d.voiceID}`
);
});
});
});
}
});
});
Can anyone help me out - PLease
I am trying to connect my bot to stored voice channels after all shards are online
error?
no error
Cause my bot is a music bot and I want the bot to reconnect to the voice channels after the bot goes offline & back online
if the bot gets offline it doesnt disconnect to the vc until discord automaticly does it after ~5-10 min
except if you write some script to do that
But it will stop playing music
Yep but I am trying my best to keep the bot on the vc
it stays on the vc
...
even if it stops playing music
No I mean I am trying to make the bot stay & play the music it was playing
u cant
https://canary.discordapp.com/channels/264445053596991498/272764566411149314/708731231394594926 google developers docs didnt helped...
For() is running one time and stop
request(options, function (error, response) {
if (error) throw message.channel.send(err);
let data = JSON.parse(response.body);
for(var i = 0 ;i < 200 ; i++)
{
if(data.Countries[i].CountryCode == code)
{
let embed = new Discord.RichEmbed()
.setColor(color.orange)
.setTitle(**${data.Countries[i].Country}**)
.addField("Country Code", data.Countries[i].CountryCode, true)
.addField("Slug", data.Countries[i].Slug, true)
.addField("New Confirmed", data.Countries[i].NewConfirmed, true)
.addField("Total Confirmed", data.Countries[i].TotalConfirmed, true)
.addField("NewDeaths", data.Countries[i].TotalDeaths, true)
.addField("NewRecovered", data.Countries[i].NewRecovered, true)
.addField("Total Recovered", data.Countries[i].TotalRecovered, true)
.addField("Last Update", data.Countries[i].Date, true)
message.channel.send(embed);
break;
}
}
});
break
?
break stops the for loop smh
oh
and excuse me but why you want to send 200 messages?
oh
cuz i am using Corona Virus api
am blind

