#development
1 messages Β· Page 1651 of 1
const { world } = require(path).greetings```
OR js const { greetings: { world } } = require(path)
The cog code is in test.py, I assume?
Thanks! :)
how much information can we store in 1kb?
1024 bytes*
how much is that? Like what is the max characters I could store in that?
lol
yes
thanks 
help π
Hey
Is it possible to create a discord bot that go online for streaming football in any voicechannel?
bots can't screenshare
:/ sad
ik that
but u cant do with other links
as far as i know
like I use different website for watch football
you have to have the legal rights for the "football game" or you cant stream it
wym with legal rights?
you would get banned by twitch by streaming a game there
itsnt twitch
tldr you can't make a bot for that
i want a bot that can stream in discord voice channels

I'm trying to implement role based access to my website, just like discord roles.
So how does discord roles work under the hood?
discord uses something like bits for role based access. How the bits are resolved, for different type of permissions.
yeah
then let me get the docs
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
can someone help me with this nightmare

case "help":
msg.channel.send(`${config.prefix}help - shows this message\n${config.prefix}ping - view bot ping`);
break;
case "ping":
var latency = Date.now() - msg.createdTimestamp;
msg.channel.send(`pong! bot latency: \`${latency}ms\``)
log("ping command executed");
break;
default:
msg.channel.send(`unknown command! type \`${config.prefix}help\``);
};```
its sending the help command multiple times
but not for others
anyone?
Is that all your code?
Send your entire file
ok
don't share your token tho
const fs = require("fs");
var config = JSON.parse(fs.readFileSync("config.json","utf8"));
var bot = new discord.Client();
bot.login(config.token);
bot.on("ready", () => {
log(`${bot.user.tag}: ready`)
})
bot.on("message", msg => {
if(!msg.content.startsWith(config.prefix)) return;
var args = msg.content.split(" ");
var command = args[0].slice(config.prefix.length);
switch(command) {
case "help":
msg.channel.send(`${config.prefix}help - shows this message\n${config.prefix}ping - view bot ping`);
break;
case "ping":
var latency = Date.now() - msg.createdTimestamp;
msg.channel.send(`pong! bot latency: \`${latency}ms\``)
log("ping command executed");
break;
default:
msg.channel.send(`unknown command! type \`${config.prefix}help\``);
};
})
var log = (m) => { console.log(`[${new Date().toTimeString().split(" ")[0]}] ${m}`)}```
shall i send config file
no need
do you know what i did wrong
You're not ignoring messages from bots
and your help message starts with -help
so the bot triggers itself
You should load the cog with something like path.to.the.cog not just cog alone unless you have it in the same directory. What you were loading was the test standard library which indeed has no setup function.
Sa.
@earnest phoenix take a look https://github.com/dragdev-studios/top.py/blob/master/toppy/models/user.py
A new top.gg API wrapper, written in python. Contribute to dragdev-studios/top.py development by creating an account on GitHub.
Go to #general-int for turkish
Lmao that repr method
Imagine escaping instead of using !r
So, it's just basically higher level of dblpy since dblpy provides raw data
message.guild.members.cache.sort((a, b) => a.joinedTimestamp - b.joinedTimestamp).first(10 - 50)```how would i get the first 10- 50
.slice?
No .slice on collections
Aw
.array().slice(9, 49)?
yes
Maybe there are less members in the cache
That code gets the elements from index 10 to index 50, which is 40 in total, so I don't see what's wrong
oh yh
guys
i still have that problem in node.js
whenever i run node . , It shows cannot find the module
and i have discord.js installed
If you don't have a package json then node won't know which file to start
just do node nameOfFile
@cinder patio Can you send me package.json full code in my dms
Can you show the error
use pastebin or hastebin
npm init -y to generate a package.json
and?
And it'll make it for you
oh
i tried doing npm init but i clicked enter key in everything
never tried npm init -y. I'll try doing it
Maybe the issue is with the code itself and you're trying to require a module which doesn't exist
Well I'll leave it as avoiding being seen on browser side
https://github.com/Y0ursTruly/HideJS.git
This is me giving up as it was called sisyphus's stone
I fixed it but thanks alotπ π π
db.each(`SELECT * FROM users WHERE id='${mentioned.id}'`, (err, row) => {
msg.channel.send({embed:{
title: mentioned.tag,
thumbnail: { url: mentioned.displayAvatarURL({dyanmic: true}) },
description: row.description
}});
});```
how would i check if the row isnt in the table
anyone?
const{ MessageEmbed, Client, Collection } = require('discord.js');
class ModmailClient extends Client {
constructor(){
super();
/*
Dependencies
*/
this.path = require('path')
this.discord = require('discord.js')
this.fs = require('fs')
/*
Collections
*/
this.commands = new Collection();
this.threads = new Collection();
/*
Constants
*/
this.prefix = "m!";
}
commandHandler(path) {
this.fs.readdirSync(this.path.normalize(path)).map((f) => {
const File = require(this.path.join(__dirname, `..`, path, f))
this.commands.set(File.name, File);
});
}
getCommand(cmd) {
return this.commands.has(cmd) ? this.commands.get(cmd) : false;
}
start(token, path){
this.commandHandler(path);
this.login(token);
this.on('ready', () => {
console.log("I'm now online")
});
this.on('message', async(message) => {
if(message.author.bot || !message.guild || !message.content.toLowerCase().startsWith(this.prefix)) return;
const args = message.contect.slice(this.prefix.lenght).time().spilt(/ +/g);
const cmd = args.shift().toLowerCase();
const command = this.getCommand(cmd);
if(command) command.run(this, message, args).catch(console.error);
})
}
}
``` My modmail bot so far. What else should be added
?
whats a modmail bot
A bot that someone can dm and it will go straight to the admins/mods/owners of a server(in a channel)
ohh
ive tried alot of things but nothing works
welp when the bot is online thats possible the only way
?
I check what you send and you ask if if the row isn't in the table
i cant find anything on how to do it
welp what bot ya making
cool
its a bot that counts reputations for users
should firebase-admin only be used on backend?
Well I'm pretty sure no
of course it should be used only in the backend
so when it could be used on frontend (client side)
Ooh. ok
You should have a server, which the client can make HTTP requests to in order to get data stored in the db
But in the case of firebase you can use https://firebase.google.com/docs/web/setup though, you don't need a server
how i can to take top 10 from quick.db?
you have to get all rows, use sort to sort them however you like, and then slice to only get N amount of them
thx
Hi
For Python Developers
I just wanted to introduce a module that you can log colorful in console for making your app better in console..
https://pypi.org/project/betterlog/
advertising much?
Or we could just use the inbuilt logging module 
and stop fantasizing over colors in a terminal you look at for a insignificant amount of time
is there like a max time for setTimeout
int32 max value i guess
ok thanks
@opal plank https://github.com/discord-rose/discord-rose/issues/4 gotta love unreleased libs
im like 99% sure that im still blocked by erwin
yea I am
someone think that they could ping him for me?
erwin definately has expressed he does not want to be pinged here
did anyone have mod mail script
oh
how would i check if a user is less than a month old
something should be by their name when you click them or do ?whois @ on Dyno
Well not name
but when you click them something those pop up saying that they are new to discord(aka less than a mouth)
i mean like by code?
the user object contains the accounts age
oh does it lol
or was it member object
yea
ah that
How can I subtract the one with the largest amount if I need to look for it?
//In mongodb
alm_oro: Array
0: Object
id: 11835
limite: 1200
lleva: 0
nivel: 1
1: Object
id: 15015
limite: 1200
lleva: 600
nivel: 1
//this would be to calculate the total between both objects
let map_alm = <schema>.alm_oro.map(x => x.lleva);
let lleva_lot = map_alm.reduce((a, b) => a + b, 0);
//then I want the larger amount to subtract the value that I specify
lleva_lot - 15
//then I want the larger amount to subtract the value that I specify
so you want to get a map of the object from the array sorted by the amount?
since you use mongodb you could use .sort({key:1})
1 ascending
-1 descending
the money is "lleva_lot", so when doing "lleva_lot - 15", I want you to remove 15 from the largest amount, in my case it would be in "object 1" in "lleva: 600"
dbl.WebhookManager(self.bot).dsl_webhook("/dsl", "yolo").dbl_webhook("/dbl", "haha")
Something about this makes me wonder
no one needs help today?
me
@old cliff
can you elaborate... I cant interpret that code and problem
What is? Keep it please 
have, I map 2 quantities, one is 15 and the other 630, then I add both and subtract 5 from the larger quantity that would be 630 so that there is 15 and 625
...okay?
Your map has 2 values and you want to subtract from the higher value?
const Client = require('../structures/Client');
const { Messege, ReactionUserManager } = require('discord.js');
module.exports = {
name: `ping`
/**
* @param {Client} client
* @param {Message} message
* @param {String[]} args
*/
run: async(client, message, args) => {
const msg = await message.channel.send(`Pinging..`);
await msg.edit(client.embed({
title: `Pong!`,
description: `WebSocket ping is ${client.ws.ping}MS!\nMessage edit ping is ${msg.createdAt}`
}))
}
``` did I go wrong somewhere cause I'm getting an error with run (its underline in red)
What error ?
There is nothing called client.embed
well this
What is this a { Messege discord.js?
Add a comma after name
What's the error?
AFTER
name: 'ping'
hover it
Put a comma
ah
Put a freaking comma before run
Create invitations
CREATE_INVITATIONS ? lmao
?
yes
but for my code
i am dbd developer
CREATE_INSTANT_INVITE
Oh thanks

the bot tell to me he never has the permission
why is this happening?
?
it stops showing suggestions (vs code)
na na look
unless you install extensions
yes, but require doesnt have them
did you change any extension?
see this
do you have eslint or typescript?
if(message.guild.me.hasPermission("CREATE_INSTANT_INVITE")) return message.channel.send(":x: Missing permissions (create_invite)")```π
fresh install
don't you need to check channel overwrites too?
Is that a walk?
fresh vsc install?
hi
yeah
install the intellisense extensions
please lmao
if has permission say missing permissions
he always say missing perm

this is what your code translates to
Negate the condition
if(!message.guild.me.hasPermission("CREATE_INSTANT_INVITE")) return message.channel.send("β Missing permissions (create_invite)")
try it
let big = Math.max(val1,val2)-5;
let small = Math.min(val1,val2);
get max and min feom 2 vals and sub 5 from max
if(!message.guild.me.hasPermission("CREATE_INSTANT_INVITE")) return message.channel.send("β Missing permissions (create_invite)")
Its dont work help me 
message.channel.permissionsFor(message.guild.me).has(['CREATE_INSTANT_INVITE'])
@earnest phoenix
Nah the git repo is private for a reason
Just write a non permissive license, then no one can clone your bot and if they do, money
I had to write one to open source my bot. https://github.com/AmandaDiscord/Amanda/blob/rained-in/LICENSE
have you sued anyone so far?
some just dont have any
how would i get the money

Was going to when I saw someone tried to deploy to Heroku, but they promptly deleted the repo
Some toolboxes are shwon only with the language extension from vscode
@zenith knoll it does, it was bugged out
some come with the module
issue a DMCA, then if they counter claim, you can take them to court
ok..
can i, as a 15 year old, take someone to court
You can so long as you have a lawyer on your behalf
I'm unsure if you're able to speak for yourself, though
depends on the country i would presume
Also your parents must be present most likely
uk
Perhaps. Probably synonymous with what age your country defines as an adult
Japan used to be 14
now it's 18 iirc 
Btw is there an api to get song lyrics?
genius
14 = adult lol
π kinda off topic
If you're trying to get lyrics based off YT videos, you'll have to have a regex to pick apart the author and the song title as genius will not pick that apart for you
What do you think an API is? the npm module is a wrapper for genius' lyrics api
genius ok
oi m8ts
wut
let elixir_big = Math.max(elixir_map)
await data.updateOne({
alm_oro: {
id: elixir_big.id,
limite: elixir_big.limite,
lleva: elixir_big.lleva - itemPrice
}
})
?
No
Math.max takes 2 parameters
2 numbers
You can although Google how to get the largest value in a array
No
"The Math.max() function returns the largest of the zero or more numbers given as input parameters"
spread the array for the params Math.max(...array)
how to upload a link as a attachment in an embed?
what do i do then?
set the image of the embed as the link
but I want it as an attachment , the link is shown
Then you'd have to download the file from the link and then attach
be careful of links that aren't to direct downloads. Discord does processing on their side for embed previews
yes thats way I need it as an attachment lol
its a canva image, which should be send

Look at the Discord library you're using's docs for how to set a field as an attachment you're choosing to upload.
for djs, you'd set the attachment like:
"attachment://file.png" iirc
note that you actually have to set the attachment Buffer first
discord js lol
attachment://link ?
found it
.attachFiles(['../assets/discordjs.png'])
.setImage('attachment://discordjs.png');
Alright. Then if you want lower level than that, this is what your request should look like:
{
method: "POST",
headers: {
"Authorization": "token here",
"User-Agent": "user agent here",
"Content-Type": "multipart/form-data; boundary=boundaryhere",
"Content-Length": bytes
},
body: "Content-Disposition: form-data; name="file"; filename="file.png"\r\nContent-Type: image/png\r\n\r\npngfilecontents"
}
when I send it as attachment, will it use more network as sending it with a link?
Yes, which is why I initially suggested to just set it as a link
but then I cant hide the link?
Why would hiding the link matter to you?
the link is my api, which generates image. The problem is everytime, they click on the image. It sends a request to my api. I want that the image does not change
Big whoop. Discord caches the response for a while and presents the cached result
when I reload discord on browser, the results changes π¦
a attachment wont change?
Correct
okay thx a lot 
it is working sending it as a attachment, but It does not send it in the embed π¦
.attachFiles([`https:myimage...............................`])
.setImage( "attachment://"+ `card.png`)
should I place there my link?
your avatar π
You have to download the file and name it as card.png. This can be done with the MessageAttachment class as you'll download it as a Buffer and then mutate it with the MessageAttachment class
attachFiles does not accept URLs
even though it says it does 
Visual Studio Code
how to make it "Bufferresolavle?"
thats git,which is showing and coloring new files or changes
it's not a marketplace extension. If you have a folder with a .git sub directory, VSCode reads that to determine what's changed as compared to GitHub
Can somebody help me?
BufferResolvable is a place holder to signify that it can be a Buffer, a fs path relative to the cwd or a URL.
Buffer | string
You should manually download the file from your API, then use the MessageAttachment class to name the Buffer from your API and then attach that
is it better when I send the channel request from my api?
can someone hack in? it is using express
You don't need a client instance in order to post to Discord's API, you can use a lib like SnowTransfer to make requests or build the HTTP request yourself
thats just a api request, I will send
I wont login
Depends on how you authorize requests. express is secure out of the box, you might want to disable the x-powered-by header express sets in responses to clients so that people can't reverse engineer the back end of the API
a rule of thumb in web dev is that you should never let the client be an authority. That's how sites, and games for that matter, get hacked. Also, if a client isn't authorized to do something, return 404 so that unauthorized clients don't attempt to reverse engineer your API
more like a rule of thumb for anything
that's how karens are born
whats "can't reverse engineer the back end of the API"?
Does anyone know how I can format a number into it's place value? Example: 100000 = 100k
const {token} = require('./config.json')
const Discord = require('discord.js-light')
let client = new Discord.Client({});
client.token = token;
var express = require("express"); //requiring express module
var app = express(); //creating express instance
const Canvas = require("./package/index.js");
const fs = require("fs");
app.get("/card", async function(req, res) {
}
``` So can they access or hack in?
How can I edit my bots page css?
anyone can access it by literally just going to yourdomain/card
when i try to dm a user (me so ik my dms are open) i get this error:(node:3840) UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Channel
unless you do some authorization or maybe IP checking
but can they hack in? access my client or my token?
what is your code
so its safe when I add a header with a token?
how did you specify the member, how did you use the send method
We cannot help you unless you provide your code.
ive tried js message.author.send("h") and js message.member.send("h")
sure
Just that? That must be Discord.js's fault. Is there any other code?
where do I pass the token? in the query?
message.member.user.send()
I don't see anything wrong
same
No.
query params, url itself, cookies, headers all work
wouldnt .member.user be the same as .author?
message.author.send works. I use it with my own bot.
it will work
thta.....isn't even a method
Agree.
at least in my discord.js
same
Are you on v11? v10??
didnt work on mine
Not sure.
I'm gonna test out the message.member.user.send("") even though it doesnt show up as a method for me
i dont see why it wouldnt work, just seems ineficent
oh god gotta wait for 100 shards to load up
w h y
because I tested it on my big bot
breh
im gonna run it on the testing one LMAO
v12?!
The docs don't show that.
i seriously have no idea why it dont work. should i just use eris.js for this?
you big bot cant have 100 shards, when you do not have 100k guilds
How do you know that? He could have 100k guilds you don't know that.
what is the problem?
how many guilds does your big bot have?
you can, but there is no benefet
its not recommanded to spawn many
that thing actually works even though it isn't a method in my js
I don't have a "big" bot.
@earnest phoenix 
@earnest phoenix they
unknown channel on mine
I FUCKING KNOW. I SAID THERE IS NO BENEFET.
you are abusing the discord api
Are you pointing at the reply or my message.
fuck the api
no
No isn't a valid answer.
ik , I didnt meant you
how come that almost all big bots even below 100k spawn 100+ shards
uh oh
see what happend
I spawn either 50 or 100 depending on the traffic
how may guilds do you have?
that wasnt because sharding...
1 shard per 1000 guilds
Set it to "auto".
you abused the discord api
mhmm
is it just me that dont give 2 fucks?
I don't understand. How many requests did you send out?
Please calm down. Cursing doesn't help anything.
uhh there is like 630 members and i tried to dm all of them... yea...
you mean the "big" one?
WHAT! That's why you're getting rejected. What was the point for that though?
50k but I do not even really own it
uhhhh
why would you even do that
yes
isn't that considered as raiding
really?
because i wanted to get a message out to everyone
I believe so.
50 shards is enough
@earnest phoenix You should really set your sharding to auto. It really helps.
a) yes if you read it says you cant dm any new members
b) mass messaging, i have a server where imma give everyone admin
I know just sometimes our traffic gets too high and shards die so we make more to get the bot back up to as many servers as possible
send me a link of your bot in dms
and you should not do test in your main bot
Uhhh just set it to auto lol
auto doesnt account for traffic does it?
const Discord = require("discord.js");
const ShardManager = new Discord.ShardingManager("./ch1llblox.js", {
token: process.env.token,
totalShards: Number(process.env.TotalShards) || "auto",
shardArgs: typeof v8debug === "object" ? ["--inspect"] : undefined,
execArgv: ["--trace-warnings"]
})
// Shard Handlers //
ShardManager.on("shardCreate", (Shard) => {
console.log(require("chalk").blue(`SUCCESS - SHARD ${Shard.id + 1}/${ShardManager.totalShards} DEPLOYED`))
})
ShardManager.spawn(Number(process.env.TotalShards) || "auto", 8000, -1);
``` This is my some of my sharding script.
correct
I use auto so my bot will ajust.
It's very useful.
I know this is probably not the right place to ask but how would I setup freenom DNSSEC
does it adjust even if some shards die?
not sure but I wouldn't use freenom
I already bought a .com from them
after your domain expires it shows some really inappropriate ads
I believe so.
So no one knows
for how much
My bot runs all day without a problem.
would it help if i did like a 5 second delay inbetween each member?
No.
Indeed.
5.25 hours aprox
why would you wnat to do that
its on an alt account 
but they can ip ban you
fancy thing called a vpn
or release ip in router settings
I run a vpn

i would exept proton free's servers are like always full

okay why when i launch a bot from a bat script does it act diffrently than running the file directly
im like dafuq
what is acting differently
nvm im just dumb
I'm trying to figure out why InviteManager sends me the reply You need to be in a voice channel to use that command!
I'm using the source from here (Line 50 sends me that message above):
https://github.com/SideProjectGuys/invite-manager-bot/blob/master/src/music/commands/music/play.ts#L48
Someone knows eris and can help me out here? It seems like voiceChannelId is false for whatever reason
is the member in a voice channel when this code runs?
looks like it should be voice not voiceState
https://discord.js.org/#/docs/main/stable/class/GuildMember?scrollTo=voice
That's what I thought too, but it's eris.js π
is there a way to fetch the member?
That's the problem, I dont know
I'm hosting that instance as like a "last resort solution" because the official one is down, and maybe someone knows eris.js well and knows a fix
If I dont get it fixed it's not a big deal tbh, there are most likely better music bots out there
maybe the model needs a VoiceState property
VoiceState directly or the whole member object?
public id: string;
public channelId: string;
public guildId: string;
public createdAt: Date;
public updatedAt: Date;
public content: string;
public embeds: any;
}```
yeah, so I'd add public voiceState: any; into it?
Worth a shot, thx alot for your help already π
Still the same message that I'm apparently not in the voice channel
Any one need help dm me!
Ok even hardcoding my current voiceChannelId returns You must be in a voice channel, lel
This is probably related to some permission check I guess?
or something with permissions
const Discord = require('discord.js');
const talkedRecently = new Set();
exports.run = async (client, message) => {
const footer = "(C) 2021 Bumper"
if (!message.guild) return;
// if(!message.channel.permissionsFor(message.guild.me).has(['MANAGE_CHANNELS'])) return message.channel.send(":x: Missing permissions (manage_channel)")
if(message.member.hasPermission("MANAGE_CHANNEL")) {
const waitembed = new Discord.RichEmbed()
.setTitle(client.user.username)
.setColor("RED")
.setDescription(`:x: You can only configure the server every 5 minutes !`)
.setImage("https://media.discordapp.net/attachments/812775174491471926/820208188056928256/standard.gif")
.setFooter(footer)
.setTimestamp();
if (talkedRecently.has(message.author.id)) {
message.channel.send(waitembed);
} else {
message.guild.createChannel('bumper', { reason: `Config command used by ${message.author.username}` })
.then(console.log)
.catch(console.error);
message.reply(`**The #bumper channel has just been created ! **
It wasnβt created? I probably donβt have the right permissions !
(You can edit the bumper channel with this name only: :blue_book:γ»partner)`)
};
talkedRecently.add(message.author.id);
setTimeout(() => {
talkedRecently.delete(message.author.id);
}, 120000);
} else {
message.channel.send(":x: Missing permissions (MANAGE_CHANNEL) ! ")
}
}
```
@nimble kiln π
ooooh im stupid lmao
π
I hope you defined your primary keys correctly
Easiest primary key is an id column with AUTO_INCREMENT and primary key enabled 
column, not row π
lol
Hello, i have a bot in 4000 guilds using shards and written by nodejs.
Every shard a node cmd gets open, is there a way to make them run on the background?
You could use "internal sharding", that way you start one bot which connects X times to discord (X for every shard)
is there a guide for that option ?
wait, that may be outdated actually
yeah it is, umm
You simply give your discord client the shards option like this:
shards: 'auto'
});```
i noticed there is manager#mode, i'll try to set it to "worker" maybe it will solve it
im not talking about this
can someone explain what shards are, i havent used them before
If you already use traditional sharding with a manager and got that working, I'd stick with it tho
yeah cause it actually creates another child process for every bot
i need them to run on the background
so "worker" mode will fix it?
i'll try
To simplify: Your bot gets split up
Every shard handles X amounts of servers where your bot is in
ohhh
It's used for load distribution
So a bot with 100K servers wont hammer one single connection
how many servers does a bot need to be in for it to need shards
Recommended is that you shard between 1000 and 2000 servers
You are required to shard when you reach 2500 servers however
I set my bot to shard: auto
And it started to use 2 shards at around 1500 servers
required as in discord won't let you not shard?
Correct
I dont know what happens when you launch your bot with 1 shards at, lets say, 3000 servers
But I assume they simply deny the connection
ah
Well an unsharded bot uses 1 shard, right?
a command
What's the definition for a database + cache microservice
Idk what name I should give it
Call it Hans. Hans is always a good choice.
hans olo

if message.content.startswith('b.purge ')>0:
ownerPerm = await client.fetch_user(message.guild.owner_id)
counter = 0
async for msg in message.channel.history():
counter+=1
#await message.channel.send(counter)
if message.author == ownerPerm:
arg = message.content.split(' ')[1]
if arg == 'all':
await message.delete()
await message.channel.purge(limit=counter, check=None, before=None)
embedVar.add_field(name='Purged', value=f'`{counter}` messages')
embedVar.set_footer(text = f"requested by {message.author}", icon_url = message.author.avatar_url)
await message.channel.send(embed=embedVar)
else:
number = int(arg)
#channel = message.channel
await message.delete()
await message.channel.purge(limit=number, check=None, before=None)
#author=message.author.mention
embedVar = discord.Embed(color=0x197bd1)
embedVar.add_field(name='Purged', value=f'`{number}` messages')
embedVar.set_footer(text = f"requested by {message.author}", icon_url = message.author.avatar_url)
await message.channel.send(embed=embedVar)
This is a purge command that should purge all the messages in a channel if the argument is all and it did work once a while ago. Instead, it only deletes 1 message. Can someone tell me why this isn't working? thx
@lilac surge are any messages cached in the channel? You could log the value of counter
ah, ill try that, thx
noice
Could someone help me figure out if I need these checked? I only have the users who have used the create account command in my database
so Iβve asked this before but no one seems to know, using mongodb how do I make data with sets of two things in it, then later able to get the data, then find somewhere in the data and get the other info in the sets
make sense?
yes that, thatβs called relational data?
yeah. theres whole databases just for that type of data, mongodb isnt one of them
do you know any? I can do some searching if not
ok thanks
I do not
I just use my pc lol
and probably soon a dedicated pc
Ok thanks
Do anyone know in python how to make bot send message like this? With just await ctx.send my bot returns a text message but is there any way to decorate the message or make the UI look better in text?
What's a good way to test new features for the bot so that other people can still use the working version?
Awesome thanks so much
How to do that? Is it like making the text bold by putting in stars? Do we need to write some syntax in message we send?
how can I get the number of how many guilds my bot is in using shards?
I want to send a request like for example:
guildCount: get_all_guilds_somehow
Ohh alright. Thank you so much
Here's some code from my project that you could look at:
embed = discord.Embed(title='Leaderboard', description=text, color=0xFF5733) await ctx.channel.send(embed=embed)
Thank you so much. That's a great help.
I just need it for posting to the top.gg page and I can't get it working with shards
ty
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
do you think that this should work
client.shard.fetchClientValues('guilds.cache.size')
.then(results => {
topggAPI.postStats({
serverCount: results.reduce((acc, guildCount) => acc + guildCount, 0),
shardCount: client.options.shardCount
})
})
.catch(console.error);
well yea Im just asking about
client.shard.fetchClientValues('guilds.cache.size')
.then(results => {
results.reduce((acc, guildCount) => acc + guildCount, 0)
}
The object you wanna post seems to be correct. Just test it. Thatβs always faster than asking if something works.
okay ty just gotta finish this game LOL
Does anyone know if there are plans to add prefix, shard count and server count as an widget
no idea
imagine using a non-relational database for relational data
huh?
for topgg?
yeah
xetera mentioned stuff regarding to polyfil
you MIGHT be able to use that
that'd be only for your bots page
oh widget
nvm then ignore me
widgets like the owner name, bot status and etc
if you REALLY mean wdiget, like the ones topgg currently has, then i dont think so
if you only mentioned widgets cuz you wanted to add that info on your bots page, then you cn do it
hi Erwin
no problomo

now go bother tim to rate it
@quartz kindleberly
no caching 45 shards
ofc cache will increase it but it's lookin poggir
is there a way to catch the error for the entire code, just so I dont have to put .catch everywhere in the code

if you have to catch so much, then you might not be doing things correctly.
sometimes catch is needed, but probably not so much it becomes an issue typing it out.
many languages do have try catch or something similar, and they can be useful, but its not too common that they are truly needed.
do you have to use arrow pointers in discord js
nice
Uhh can I talk about python script here?
sure
I am now learning pys rn and I need some help when I let the user to type freely Usieng name = input('\n')
I wnat what he type copyed and pasted into print() I mean answering him the same thing that he typed
Iβm having this problem and I donβt know how to solve it
I also haveing that issue
Okay now after you solve his problem can you help me then?
Umm, just pass the variable to the print() function 
In the invite url of the bot its oke to have predefined permissions or?
Yes
It's ok to have permissions encoded to the invite URL if the bot needs those permissions to work
Those who invite the bot can modify the unwanted permissions easily
Yeah ok nice, because for some Reason the permission integer were gone in the url and now i was wondering if its forbidden
You might have passed in an incorrect invite URL or an invalid permissions bitfield, so it would be the default invite URL
Yeah maybe but i saved the new url by now so it should work
You're just missing the redirect_url parameter in the URL you're using to invite the bot, can you show us what URL you're using?
noice
oops
my vad
bad
@earnest phoenix so basically click on your discord bot invite link and go to invite it to a server and before you authorize it, it will say at the bottom what servers its in
where do i find my bot key

?
did you check your bot application
π
No uhhhhhh, i mean top.gg
then idk what ur referring to
the server count key.
still dunno what you are talking about but if you mean this, this is to show if ur bot is in a server you want to show people who visit your bot page i think
dont quote me on that
omfg
dont get angry at me try contacting some actual staff or figure it tf out lmfao
Does discord have a rate limit as to how many times you can make a call to this endpoint?
https://discord.com/api/users/
I can't seem to find the exact place it states the rate limit
If you make a request to it, there will be an x-ratelimit header from the response where you can see the bucket, how many requests are left in the bucket and when it resets.
The docs do not state rate limits as they are subject to change and you should not hard code rate limits
None of the endpoints have a daily reset except for socket identify
it does display the reset after header though
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
Rate Limit Header Examples
X-RateLimit-Limit: 5
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1470173023
X-RateLimit-Bucket: abcd1234
X-RateLimit-Global
Returned only on a HTTP 429 response if the rate limit headers returned are of the global rate limit (not per-route)
X-RateLimit-Limit
The number of requests that can be made
X-RateLimit-Remaining
The number of remaining requests that can be made
X-RateLimit-Reset
Epoch time (seconds since 00:00:00 UTC on January 1, 1970) at which the rate limit resets
X-RateLimit-Reset-After
Total time (in seconds) of when the current rate limit bucket will reset. Can have decimals to match previous millisecond ratelimit precision
X-RateLimit-Bucket
A unique string denoting the rate limit being encountered (non-inclusive of major parameters in the route path)
how do you use the dynamic type paramaters with enums?
trying log (type: ActionType, content: string, data: typeof type extends ActionType.Message ? APIMessage : GatewayMessageReactionAddDispatchData, response: FilterResponse) {
but its always GatewayMessageReactionAddDispatchData so how can i match type to ActionType.Message
in html how ``https://can i add here a (docs).example.com`?
Does anyone know why this after_invoke function isn't being called? It works in the main module but not after I've moved it to a cog
@earnest phoenix I wanna see the server names, so I can also join them. Not the amount of servers itβs in
joining servers because they invited your bot is a privacy concern.
its still not allowed and can get you banned
well, just a heads up, this will likely result in a ban from discord and our platform.
Can I report that?
Can I DM you?
yes, please
in the last few days started having really issue with Discord.py. If I run my bot on a windows machine there are no issues, but if I run the bot (same Python version, same code) on my Ubuntu server suddenly the wait_for stops responding to user inputs after 30 seconds consistently.
Tried a fresh install of python as well but issues persists. Anyone have any insight? There was no code change in the last 2 weeks but this issues only just started occurring in the last few days. My bot has been up and running for a few months now without issue this is really weird.
What are you waiting for exactly?
Reactions?
yes reactions
Try using "raw_reaction_add" and "raw_reaction_remove" instead of "reaction_add" and "reaction_remove"
Reaction_add and reaction_remove only works for cached messages
So after x amount of time it stops working properly
i just ran some test and I think I found the issue but absolutely no idea how to fix it. I think it has to do with the number of servers the bot is in, which sound kind of insane that would be the issue. I created a new bot on the portal and changed my token to connect to that bot instead of my usual one (so the new one is in a single server instead of many). This solved the issue, however the bot is now down for anyone who has it in their server for now and I'm unsure how to resolve this.
It is highly unlikely It's an issue with the amount of servers
How did you setup the check function?
Did u try using raw reaction as i said?
as i said its working 100% fine after switching to a different bot user...this is really weird
i can try raw_reaction though
Actually
It is expected to work with New bots
Say your bot is in, idk, 100 servers with a total of 10k members
Discord.py automatically reads all the messages from text channels it has access to
Therefore, the cached messages will expire quicker, since there are going to be more message in less time and there's a limit for cached messages
Raw reaction should fix it
that makes...a ton of sense
mindblown
@icy skiff question, is this the change you are talking about?
reaction, user = await bot.wait_for('reaction_add', timeout=timeout, check=check)
to
reaction, user = await bot.wait_for('raw_reaction_add', timeout=timeout, check=check)
Yes, but i think u need to change the parameters from the check function iirc
hm, I'm having trouble finding documentation for the check function for this change
Gimme a sec
Nice!
It should look similitar to this
This makes sure the reaction is on the same message, from the same user and is between 2 selected emojis
how do i make a 403 error? in nginx
ok
@fathom tiger if u have any other problem feel free to dm me, im going to bed so i'll answer as soon as i can
dose someone have a auto moderation code in discord.py that i could have
hey i have came 1 message from discord offical like verify your discord bot
100 sever reached
Invite manager is always down lmfao
If you want invites I do have a bot, and there are many other bots that do work
If you want music tho just get a music bot
I didnβt know that invite manager had music bot?
you just hided the real error, but what i can say rn is that it can't find a file.
a .js file.
yes
those both are in the same folder
You know there is this cool thing called a screenshot right
ok
it worked tysmβ€οΈ
@crimson vapor it shows cannot read property 'set' of undefined.
show the error
why they have imported 'firebase-functions' twice??
juys, jai need jelp with java?
exam on 22nd
if ju hab ani gud book or tutorial , ples tel me
thank you juys
ples pinj me ben ju repli
what the fuck are you ok?
is your english exam over 
Invalid regular expression: /+/: Nothing to repeat
it got solved but this error is fucking me up
like wtf
it is in 18th march
?
Oh good luck with that then
:>
no idea tbh
do ju hab a book for java?
i dont even knoq why these indian schools are using java
Theres a bunch of ebook out there for learning java
who said i am india?
nvm
My school uses python
and java > others
my school has mongo db , my sql , html , css
java == others
compiling java < other languages
javascipt is better than java
i think i have somewhere a few EBooks for java
hi
Invalid regular expression: /+/: Nothing to repeat
Invalid regular expression: /+/: Nothing to repeat
Invalid regular expression: /+/: Nothing to repeat
help me π
Β―\_(γ)_/Β―
My instance is online for a few months now, is verified and is being used by a bunch of servers
it worked ffs
theres just an other error
the bot wont reply nothing
const Discord = require(discord.js);
const {prefix , token} = require('./config.json');
const client = new Discord.Client();
const fs = require('fs');
client.command = new Discord.Collection();
const commandFiles = fs.readdirSync(./Commands).filter(file => file.endsWith('.js'));
for(const file of commandFiles){
const command = require(./Commands/${file})
client.command.set(command.name , command);
}
client.once('ready' , () => {
console.log("I am online.");
});
client.on("message" , message => {
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if(message.content === 'ping'){
client.command.get('ping').execute(message , args);
}
});
client.login(token);
in d.js is there a way to get the webhook avartar url
send in a code block
loose codes give me trigger
```const Discord = require(discord.js);
const {prefix , token} = require('./config.json');
const client = new Discord.Client();
const fs = require('fs');
client.command = new Discord.Collection();
const commandFiles = fs.readdirSync(./Commands).filter(file => file.endsWith('.js'));
for(const file of commandFiles){
const command = require(./Commands/${file})
client.command.set(command.name , command);
}
client.once('ready' , () => {
console.log("I am online.");
});
client.on("message" , message => {
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if(message.content === 'ping'){
client.command.get('ping').execute(message , args);
}
});
client.login(token); ```
const Discord = require(`discord.js`);
const {prefix , token} = require('./config.json');
const client = new Discord.Client();
const fs = require('fs');
client.command = new Discord.Collection();
const commandFiles = fs.readdirSync(`./Commands`).filter(file => file.endsWith('.js'));
for(const file of commandFiles){
const command = require(`./Commands/${file}`)
client.command.set(command.name , command);
}
client.on('ready' , () => {
console.log("I am online.");
});
client.on("message" , message => {
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if(message.content === 'ping'){
client.command.get('ping').execute(message , args);
}
});
client.login(token);
now try
... if you have defined a command folder why have the ping command on your main folder
^
Can you show code for ping.js
ah wait
the fuck
make a proper command and event handler
i would have helped you make a command handler and event handler but, i have exams
is there any way to like detect a certain string and run something after?
i know there's like
if (client.keys.indexOf('your string') > -1)
{
alert("input found inside client.keys");
}
but if you're storing data in arrays it hardly works
.includes?
unless you can access the key directly
includes wouldn't work on arrays either
unless you can access the string itself lol
if you just do like
client.keys = database.tag(`key-${message.author.id}`, { type: string }, [ "key ect ect"]);
there's no way to access the content unless you just call it using like list and get it from that
but when i tried it just said null
@slender thistle which is why i kept saying gay
in the server lol
ah nvm
just gonna make a dot notation function for the database ig
Wait what are you trying to do exactly?
anyone know how to run bot script from phone?
throw err;
^
Error: Cannot find module './commands'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/home/matthan/discordbot/bot.js:5:21)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
[nodemon] app crashed - waiting for file changes before starting...```
Idk how to fix it
but
I got the required directory
and it is saying It has trouble finding it
this is unfixable never found a fix
const Discord = require("discord.js")
module.exports = {
name:"test",
run(message){
const embed = new Discord.MessageEmbed()
.setColor('RED')
.setDescription('Text')
.setImage(`https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/socialmedia/apple/271/a-button-blood-type_1f170-fe0f.png`)
.setFooter('page 1')
const embed2 = new Discord.MessageEmbed()
.setColor('RED')
.setDescription('text 2')
.setImage(`https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/socialmedia/apple/271/b-button-blood-type_1f171-fe0f.png`)
.setFooter('page 2')
message.channel.send(embed).then(async msg => {
setTimeout(function () {
msg.react("β")
}, 500)
setTimeout(function () {
msg.react("βΆ")
}, 600)
const collector = msg.createReactionCollector((r, u) => (r.emoji.name === "β", "βΆ"))
collector.on("collect", r => {
r.users.remove(message.author.id)
switch (r.emoji.name) {
case "β":
msg.edit(embed)
break
case "βΆ":
msg.edit(embed2)
}
})
})
}
}``` ok so i made this page command only i dont know d its kinda shitty in a way that when the second reaction gets loaded in the page goes to the next page and i dont know how to add more pages
discord.js is basically one giant beginner hivemind
you have people asking 'how to navigate folder in file explorer'
we have to help brickheads like thise
those*
you have to repeat that
or you could use embed editing
yeah but look at the video how do i fix it that it directly goes to page 2
Don't accept reactions from bots
your own bot reacts to it and triggers the collect event
@dusky lagoon
!eval message.member.hasPermission("ADMINISTRATOR"), is there a way it can return the list of permissions the bot has in a server?
<Guild>.me.permissions.toArray()
Thanks! :)
Wait.
TypeError: Cannot read property 'permissions' of undefined?
Let me check docs.
not guaranteed to be cached
What do you mean?
<Guild>.me is not guaranteed to be in the cache, you should fetch the object
Should you license your closed source discord.py bot?
I want to have as strict license as possible
What's the point of licensing the code if it's private
if its close source there isnt any reason for a license
that would be a privacy and data protection breach
But are never sure
yeah you can sue your host regardless
But is it actually alright?
To have a licence in a bot
Or em
Not
For example if somebody somehow gets the private source code of my bot
There is no license in my project
I mean sure, I guess it doesn't hurt
if you're code is unlicensed it means no one is allowed to use it and re-distribute it
its the same reason why you get massive Open source project on github that are unlicensed
Wait
Is Β© 2021 (E-GIRL) even necessary
For example in license.txt
Then
Like copyright notice is not a license
Itβs just a proof I own this project
But itβs not a license
the license only says what you can and cannot do
Is it necessary to keep copyright then?
by default if a project is unlicensed it's deemed to give no rights
Like I understood about licenses
I wonβt put it in my closed source projects
But what about copyright
you own the copyright regardless
I really want to include atleast copyright in my project
I mean sure
But i would advise you get a lawyer todo it 
My bot is smol
No need to lmao
as soon as you add explicit and not blanket coverage you open loop holes in the world of the law
its the difference between having a legally binding and a un-enforceable license
Btw how itβs possible to know
If my project was private
When for example in case of leaking it
If you don't share your code to anyone, then it's considered private
most of the time you cant
unless it gets big enough to notice it / care about
unless you have the money to spend on crawlers
isn't propiertary the most limited "license"
I'm working on react native, I have make a custom Input component, how do I make it in ts, so that it accepts the same props as TextInput of RN
Go to https://top.gg/newbot
i made bot the play songs non stop 24/7
but when no one in the room
it stops
how can i fix this?
hosted by heroku
full error trace please?
also dont use heroku for Music bots, they need a lot of resources and Herkou is not even ment for normal bots
what the best host for it?
any decent Paid VPS
this is the whole heroku logs
sa
handle errors
like .catch
Hi guys
Can i ask how to makr a custom voice channel that when you join it creates a room for you with your name?
hey guys
Ok so im trying to copy this and what i mean with that is the space between the commands i know it has to do something with startWith but i cant find any pages that explain this
this is called api abuse?
that's ratelimit
if you mean "args" then startsWith won't solve anything
let args = command.split(" ");
then remove the first element of the array
since it'll be the prefix + cmd name
ohw thank you
hey i have a json file that looks like this
i am currently using : const array1 = fs.readFileSync('./keywords1.json', {encoding:'utf8'}); const array1res = array1.slice(1,-1) to read the file
how would i loop through it? To get all the contents?
just look through all the arrays
or if you don't care just flatten the array
btw, why are you removing the first element of it?
because it was a string and had ""
so i am removing the first and last characters
yeah... how?
just...loop?


