#development
1 messages · Page 919 of 1
and some things are missing
TypeError: Discord.Util.CleanCodeBlockContent is not a function 🤦
lowercase
@heavy marsh try process.uptime() I forgot it was a function lol
Thank you but I already fixed it 🙂 - @delicate zephyr
Okie
How do I check if my bot has higher permissions than another? So if it's able to change permissions of another bot
how can i add shards to my bot? (python)
shards?
How do I check if my bot has higher permissions than another? So if it's able to change permissions of another bot
@opaque seal Depends what you class as a "higher permissions".
Pls weekly
@opaque seal Depends what you class as a "higher permissions".
@frail ocean In the list of roles of a server, my bot has to be above the bot of which I want to edit permissions in order to be able to do that.
get the highest role of both users and compare their positions
^
nice thank you
client.user.setActivity(Games[random], type: 'DND' ); @earnest phoenix
Games[random]'dan kastım buydu
özelden anlatsana
why does it log null ?
Data.findOne({
userID: userid,
serverID: message.guild.id,
name: user.user.username,
language: args[2],
email: args[1],
lb: "all",
}, (err, data) => {
//catching errors
if (err) return console.log(err);
console.log(data)
})
setInterval(function() {
var oynuyor = ["mrb ben bot", "mrb mrb"]
var random = Math.floor(Math.random()*(oynuyor.length-0+1)+0);
client.user.setActivity(Games[random], { type: 'DND' });
}, 15000) ```
@earnest phoenix
DND küçük olcak
english only
Turksh only
Cringe
beyler şunu nasıl yapıcam invite botum var bi türlü olmuyo
{user} Sunucuya Katıldı. Davet Eden {ınvıterName}. Davet Sayısı{numInvites}
Bilen varmı
What's the best practice for removing send messages permissions from a guild member?
english only @bleak jewel
hello @tepid nimbus
@earnest phoenix throw ur own error
Hey @limber flume
so I have a server with different channels, in one of these I need a daily reminder on a specific time that send a 2 word message
Like a reset reminder
reset? can you explain more
bot.on('ready', () => {
setInterval(() => {
dbl.postStats(bot.guilds.cache.size, bot.shards.Id, bot.shards.total);
}, 1800000);
});
``` - Tells me ```js
dbl.postStats(bot.guilds.cache.size, bot.shards.Id, bot.shards.total);
^
TypeError: Cannot read property 'Id' of undefined
Server reset, basically this channel@is connected to a game we play and at a specific time the game reset changing all the info we know, so I want to set a reminder that when the bot send the message we know that the previous info are no longer valid. Basically something simple saying ‘new day’ and such
Director, id should be lowercase
What's the best practice for removing send messages permissions from a guild member?
anyone knows?
IOh thank you
a game?
Giu, it depends, do you want to change them for a specific channel, or the whole server
Whole server yeah
Using a role
Does member.permissions.remove('SEND_MESSAGES') do it?
Using a role
this would be quite inconvinitent
No such thing as member.permissions
It's read-only
but wait, there is a remove method in them
@limber flume is it’s a group that play a videogame but there are different time zones involved and a reminder makes the situation a little bit easier
You'll have to either update every channel's permissions or make a role, and disable it's permission to send messages and give it to the member
but if the user has another role which is able to send messages, it will take could of the position of the two roles to see which one to listen to right?
so I also have to create the role in an higher position than the highest role the user has?
u liuke python @tepid nimbus
How can I remove a certain permission from a role though?
Seems like I have to use bitfields, isn't there an easiest way?
help please
can't use empty text
hmm
? : ''
i how to fix this empty text error
if its empty just don't continue the code and tell the user they need to give an argument
const queue = client.queue;
var searchString = args.slice(0).join(' ');
var url = args[0] ? args[0].replace(/<(.+)>/g, '$1') : '';
var serverQueue = queue.get(message.guild.id);//böyle amk
var voiceChannel = message.member.voiceChannel;//tüm thisleri message yap
const embed = new RichEmbed()
.setColor("RANDOM")
.setDescription("**Dinlemek istediğin şarkıyı yazmalısın!** (Şarkı ismi veya Youtube URLsi)")
if (!args[0]) return message.channel.send(embed);
const voiceChannelAdd = new RichEmbed()
.setColor("RANDOM")
.setDescription(`**Lütfen herhangi bir sesli kanala katılınız.**`)
if (!voiceChannel) return message.channel.send(voiceChannelAdd);
var permissions = voiceChannel.permissionsFor(client.user);
if (!permissions.has('CONNECT')) {
const warningErr = new RichEmbed()
.setColor("RANDOM")
.setDescription(`**Herhangi bir sesli kanala katılabilmek için yeterli iznim yok.**\n*Çözüm:* Sunucu ayarlarına girip Roller kısmındaki Cortex rolüne tıklayıp YÖNETİCİ yetkisi verin.`)
return message.channel.send(warningErr);
}
if (!permissions.has('SPEAK')) {
const musicErr = new RichEmbed()
.setColor("RANDOM")
.setDescription(`**Müzik açamıyorum/şarkı çalamıyorum çünkü kanalda konuşma iznim yok veya mikrofonum kapalı.**\n*Çözüm:* Sunucu ayarlarına girip Roller kısmındaki Cortex rolüne tıklayıp YÖNETİCİ yetkisi verin.`)
return message.channel.send(musicErr);
}
if (!permissions.has('EMBED_LINKS')) {
const musicErr = new RichEmbed()
.setColor("RANDOM")
.setDescription(`**EMBED'li URL eklemek için yeterli iznim yok!**\n*Çözüm:* Sunucu ayarlarına girip Roller kısmındaki Cortex rolüne tıklayıp YÖNETİCİ yetkisi verin.`)
return message.channel.send(musicErr);
}
its my code
if (url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/)) {
var playlist = await youtube.getPlaylist(url);
var videos = await playlist.getVideos();
for (const video of Object.values(videos)) {
var video2 = await youtube.getVideoByID(video.id);
await handleVideo(video2, message.message, voiceChannel, true);
}
const PlayingListAdd = new RichEmbed()
.setColor("RANDOM")
.setDescription(`[**${playlist.title}**](https://www.youtube.com/watch?v=${playlist.id}) adlı şarkı oynatma listesine Eklendi!`)
return message.channel.send(PlayingListAdd);
} else {
try {
var video = await youtube.getVideo(url);
} catch (error) {
try {
var videos = await youtube.searchVideos(searchString, 10);
var r = 1
var video = await youtube.getVideoByID(videos[r - 1].id);
} catch (err) {
console.error(err);
const songNope = new RichEmbed()
.setColor("RANDOM")
.setDescription(`Aradığınız isimde bir şarkı bulunamadı!`)
return message.channel.send(songNope);
}
}
return handleVideo(video, message, voiceChannel);
}
and
this
Oof
if its empty just don't continue the code and tell the user they need to give an argument
already have
@vivid crescent
args[0].replace can lead to an empty string ^^ You aren't checking the modified string in your if statement below that
@toxic jolt if (!args[0]) uyarısını üste koy
How i can highlight code ??
highlight?
you left click and hover over the code you want to highlight if that's what you mean?
that's syntax highlighting
you do that by adding the the language tag to the beginning of the code block
flavours 
oh
for(var i = 0 ;i < data.Countries.length ; 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);
}
else
{
message.channel.send("No country found")
}
i have this but the else is looping
if i break; the else it will stop the if
Hey @limber flume my skill set on coding languages are really limited and really basic
i can teach u
xD
or you can look at docs
with?
is the IF valid?
IF = ??
if(data.Countries[i].CountryCode == code) is code valid? otherwise it will use else
hmm
mhm
is you country code exactly code or is it a value you set on a other point?
its possible that you need to run this async bcs the country code is not valid at execution
my coding knowledge is not the best but i think you need to run it async
corona api
there could be the issue
let options = {
method: "GET",
url: "https://api.covid19api.com/summary",
headers: {},
};
request(options, function (error, response) {
if (error) throw message.channel.send(err);
let data = JSON.parse(response.body);
for(var i = 0 ;i < data.Countries.length ; 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);
}
else
{
message.channel.send("No country found")
}
}
});
this all of the code
api calls can be slower than your code execute. i think you need to run your api call asyncrouse
no
no i added this let msg = await message.channel.send("Working....");
will it work ??
this will await that the message got send
try to run your request with await -> asyncrouse
then it should wait until the API answered
@turbid bough hey, you here?
kind of
Remember our conversation the other day about grabbing the user Id and passing it on a Query String @turbid bough ?
I had a super simple idea... how come it didn't occur before
Just grab the user ID on Discord, and generate a link that is given to the user
How come this didn't occur before? lol, just had this idea and had to share
yeah you can do that. if you just want to use querystring
hey so i have a custom prefixes system and i want my users to still be able to use the bots default prefixes which are 'm!' and 'M!' so how can i do that? (Python:
)
@turbid bough the else() is loopping
just the else?
yes
like, how exactly?
no country found
no country found
no country found
no country found
like that
well, does data.Countries[i].CountryCode == code equal false? yes
what
well, if you have a for loop
aha
and you use an if statement
yes
and if that if statement is false, then it goes to else
yes
But if its something unintentional, you would have to check what data you are comparing
by using console.log() or debugging
nono thats fine
im talking about this data: Countries[i].CountryCode
and your code
i will try to console.log(Countries[i].CountryCode)
btw, it seems also like you are trying to use like it .find
@turbid bough guess what, the # character breaks the query string
idk
data.Countries.find(x => x.CountryCode == code)
console.loged it and the output are the country codes
is it a list of country codes?
yes
with the [i] part?
thats not what im asking
ah yes with [i] method
ok, so you know then CountryCode is an array
then you are going to compare it with code
{
"Country": "ALA Aland Islands",
"CountryCode": "AX",
"Slug": "ala-aland-islands",
"NewConfirmed": 0,
"TotalConfirmed": 0,
"NewDeaths": 0,
"TotalDeaths": 0,
"NewRecovered": 0,
"TotalRecovered": 0,
"Date": "2020-04-05T06:37:00Z"
},
this one of the data.Countries
for example
i wanted to find ContryCode and then display all info with the Country Code
yes
so, what is code by then?
for example i type in chat "/corona US" so code is "US"
can you double check by printing out code?
.toLowerCase()
yeah, you don't want to do message.send in a for loop with an else
also
are the objects linked to keys in your json?
(its called pressing F5)
breakpoints 
man its fun not checking what data values you are comparing
X-RateLimit
no i tested so many time so now . . .
yes, maby thats why lol
How df do u even hit the ratelimits lmao
LoL
he used message.send in a for loop
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
message.reply ?
ik xD
you dont want to reply 100 times
store an empty variable before the for loop
before the for loop
then assign it in the for loop
then compare it after the for loop
how to make bot display how many servers its in discord.py?
display where
u mean
for{
else
{
trueFalse = true;
}
}
if(trueFalse == true)
{
message.send("Error");
}
https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.guilds count method on this
@earnest phoenix something else, inside the if statement
P.S Python's built-in len function
discord.bot.guilds?
discord.Client being an instance of your client/bot
f(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);
}
embed
so instead of assinging "i found nothing", you are assigning "i found something"
wut
i dont understand
oh btw
i console.loged the code
and the output is : US 100 times (maybe more)
😐
so ?
you are also sending 100s of "not found"
no
rate limiting the embed
what ?
im not quite sure
about ?
Hmm
hmm
did u found the hosting
@earnest phoenix ??
No
why
i suggested
Rn Im Working On Economy System But....
Its Not Working
Hey, when my bot redirects to js https://discord.com/api/oauth2/authorize?client_id=660818351638970370&redirect_uri=http%3A%2F%2Fvps.cxllm.me%2Fcallback&response_type=code&scope=guilds
(on the dashboard) it gives me this https://prnt.sc/se75j4 any idea why?
Should be careful
no it console.log "US" cuz the loop
you may be banned if you continue spamming the api
who
you don't use authorize with query
server.js
const Coins = require('./mongodb/coins.js')
Client.on("message", async message => {
if (message.channel.type === 'dm') return;
let chance = Math.floor(Math.random() * 100) + 1;
if (chance > 50) {
let coinstoadd = Math.ceil(Math.random() * 10) + 5;
Coins.findOne({
userID: message.author.id
}, (err, res) => {
if(err) console.log(err);
if(!res){
const newDoc = new Coins({
userID: message.author.id,
username: message.author.username,
coins: coinstoadd
})
newDoc.save().catch(err => console.log(err));
}else{
res.coins = res.coins + coinstoadd;
res.save().catch(err => console.log(err))
}
})
}
})```
coins.js
const mongoose = require('mongoose');
const coinSchema = mongoose.Schema({
userID: String,
username: String,
coins: String
})
module.exports = mongoose.model('Balance', coinSchema);```
bal.js
const discord = require('discord.js');
const blue_color = "0x00ffff"
const config = require("../config.json")
const functions = require('../functions.js')
module.exports.run = async (client, message, args, prefix) => {
var Coins = require('../mongodb/coins.js');
let member = message.author
Coins.findOne({userID: message.author.id, username: message.author.username}, (err, res) => {
if (err) console.log(err);
if (!res) {
message.channel.send('0 Balance')
}else{
message.channel.send(res.username, res.coins + " coins.")
}
})
};```
BRUH
STOP
When i do /bal it just shows my name
Wheres Error?
All 3 are different files
@turbid bough ??
server.js is main file
bal.js is command
coins.js is schema
pls stop
I mean if you're sending 100 message requests to discord, they won't like that >.>
@turbid bough wdym "you dont use authorize with query"
you are getting 100 in if statement, you are using message.send in the if statement
what
Were you talking about my question or his? lol
i thought you said in if
when -_-
still sending 100 in else though
yes
thats rate limiting
dont use message.send in there
so how i can send msg to user that there Country Code is not found ??
Store if the code has been found outside of the loop
If its found break the loop as well, you don't need to continue searching for something that has already been found
smart
you store the found item in a variable before the for loop
omg it took me 3hour
just bacause i am stupid
Well
@turbid bough ik that is smart
but NOT WORKING
if() is not work
idk why
for(var i = 0 ;i < data.Countries.length ; 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);
}
else{
notFound = true;
}
}
if(notFound == true)
{
message.channel.send("Can not found Country with code " + code);
}
look
You are still sending the message
is not sending embed
bruh
i need [i] to send info
if its found notFound should be set to true and the loop should terminate, not the other way around
console.log both data values
@turbid bough he is setting it to false on each iteration
ik
but which item
in the if
the item you are sending
let foundIndex = -1;
for (....) {
if (mything[i] === otherthing) {
foundIndex = i;
break;
}
}
if (foundIndex < 0) {
// was not found
return;
}
// Your index exists```
but i need [ i ] to see which array the info in
I left out syntax so you don't just copy and paste
cuz there are many
Which is why you are storing the index
"Countries": [
{
"Country": "ALA Aland Islands",
"CountryCode": "AX",
"Slug": "ala-aland-islands",
"NewConfirmed": 0,
"TotalConfirmed": 0,
"NewDeaths": 0,
"TotalDeaths": 0,
"NewRecovered": 0,
"TotalRecovered": 0,
"Date": "2020-04-05T06:37:00Z"
},
{
"Country": "Afghanistan",
"CountryCode": "AF",
"Slug": "afghanistan",
"NewConfirmed": 18,
"TotalConfirmed": 299,
"NewDeaths": 1,
"TotalDeaths": 7,
"NewRecovered": 0,
"TotalRecovered": 10,
"Date": "2020-04-05T06:37:00Z"
},
{
"Country": "Albania",
"CountryCode": "AL",
"Slug": "albania",
"NewConfirmed": 29,
"TotalConfirmed": 333,
"NewDeaths": 3,
"TotalDeaths": 20,
"NewRecovered": 10,
"TotalRecovered": 99,
"Date": "2020-04-05T06:37:00Z"
},
look
If you don't understand what you're doing wrong atm then I really don't think we can help you.
Read your code
Understand its flow
I gave you a very simple resolution to a basic iteration problem
imagine checking if a boolean is true
could also simply use array.find()
😳
rip
let data = array.Countries.find(country => country.CountryCode === code);
if(!data) { return "country not found" }
console.log(data.NewDeaths)
console.log(data.TotalDeaths)
omg
i am done
coins.js
const mongoose = require('mongoose'); const coinSchema = mongoose.Schema({ userID: String, username: String, coins: String }) module.exports = mongoose.model('Balance', coinSchema);```
@earnest phoenix
whtf
How many servers can a free heroku host can handle for a music bot?
it cant
at least two
evt.bind is not a function https://srcb.in/ef6f1cf1cd
how can i create a reaction collector with eris?
try eris-additions
where r the docs for that?
oh
then how can i do it then?
no, it shows the cached users @wispy fox
because thats what ur bot caches
no
no, its however much ur bot caches
cache all users
i dont recommend ^
i do lol
i don't use djs
yes
How to fix it problem?
run enable pnpm in your glitch console
I am currently creating a command handler for my discord.js bot using this article (https://discordjs.guide/command-handling/#dynamically-reading-command-files) and when i run the bot it returns this error
index.js : The term 'index.js' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:1
+ index.js
+ ~~~~~~~~
+ CategoryInfo : ObjectNotFound: (index.js:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Suggestion [3,General]: The command index.js was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type: ".\index.js". See "get-help about_Command_Precedence" for more details.
Here is my code, with both my index.js and ping.js (the only command i am testing at the moment)
https://pastebin.com/R2VjFiCc
so this happens when u try running it?
yes
u need to do node .
ok thank you
np
is there a eris equivalent of message.mentions or I have to hard code it?
run
enable pnpmin your glitch console
@quartz kindle not fix it i will used
@limber flume me?
Okey
🙂
Does anyone know how can I get the onsite-profilepicture of my bot to update?
@earnest phoenix show your package.json
@quartz kindle i will send you wait
@quartz kindle come dm
@quartz kindle sendend dm
you have too many dependencies, delete everything that you're not using
the webhook heroku url
what url
is this correct ?
I'm using eris, and I have problems with unban... https://cdn.lumap.me/ivvu7dtk.png
string
@earnest phoenix not correct
YOURPROJECTNAME.herokuapp.com/dblwebhook
oh
Is there any good command handlers online that I can use? A lot of the videos are outdated
make your own
@quartz kindle Do i need to remove the port in const dbl
webhookPort: 5003,
or what ?
Thats the thing is I have no clue how to
@abstract crow which programming language?
so unbanning a member returns literally nothing. interesting...
I'll try that one thx 🙂
You're welcome
@raven urchin where is this (https://cdn.discordapp.com/attachments/272764566411149314/709099877635719310/IMG_20200510_184645_308.JPG) being called
np
In the events folder
example
events/messageDelete.js because that's where the ready.js and message.js are
ye show the code
In the index?
hi
np
lemme check real quick
anyone can help me with my problem
can you help me by asking a question
Can I 😄
you can
Jacher np problem fixed thanks reporting
When I modify a field at mongodb database some of my number fields also turning into string
@raven urchin u arent calling the function to add a snipe anywhere?
No that's all I have but I do have this
@rare tangle idk how to use mongo sorry
@raven urchin ye ur defining it but ur not calling the function to add a snipe
so when someone deletes message u arent adding it to the snipes map
so it wont find it
So i add client.on('messageDelete')?
u just need to call ur function somewhere in ur existing event
So do I add the client.on('messageDelete') in the event?
no u already have that
this is that
u need to import this https://cdn.discordapp.com/attachments/272764566411149314/709100992326664304/IMG_20200510_184645_308.JPG and call it in this function
const addSnipe = require(path to snipe add code)
addSnipe(client, msg)
so const addSnipe = require("snipes")
then execute: addSnipe (client, msg)?
@earnest phoenix yes, remove the port
is the snipes file in the same folder as ur index
ok
and in your dblapi.js config, you use process.env.PORT as the port
or how does the file tree look
How to define number of bots from o server? discord.js 11.5.1
the client.snipes = new Map(); and everything is in index.js
there's is no snipes.js folder
@quartz kindle Well it says Cannot read property 'on' of undefined in dbl.webhook.on()
is this code in a separate file
that code is in events
and if so, where is it in relation to your index file
how can i merge objects with Object.assign but also assigning properties that are objects too (and not overriding them again)? (super helpful screenshot attached)
it's events/messageDelete.js
ok
So I'm guessing I need to change it to snipes.js?
is this the only code in that file
that's the only code in the message delete
@mossy vine try {...game} ig
@raven urchin yeah in which case u can name it whatever
How to define number of bots from o server? discord.js 11.5.1
what
const addSnipe = require("./events/fileName.js")
Do I add that in index.js?
and then in your client.on("messageDelete") function, add the file addSnipe(client, msg)
@earnest phoenix i said to use process.env.PORT as your port, not to remove the entire port configuration?
yes
And in the command itself?
const addSnipe = require("./events/fileName.js") should be at the top of ur file
tim yes you are smart please tell me how i should do this c:
addSnipe(client, msg) should be in here https://cdn.discordapp.com/attachments/272764566411149314/709100992326664304/IMG_20200510_184645_308.JPG
wait
wronmg image
here
@mossy vine do what lmao
Ok
u can merge object properties in the same way u merge elements in an array
with ... syntax
merging 2 objects but the properties are also objects and doing Object.assign on that too will get overridden by the wrapping Object.assign
so u mean like
if u have two objects
const myObj = {
a: 1,
b: 2
};
const myObj2 = {
c: 3
};
no not really
no lemme explain
you want that children properties get merged instead of completely overwriting another child right?
const myObj = {
a: {
one: 'one',
two: 2
},
b: 3,
c: null
}
const myObj2 = {
a: {
two: 'two'
},
b: 4
}```
i want that to result in
```js
{
a: {
one: 'one',
two: 'two'
},
b: 4,
c: null
}```
ah
@quartz kindle so webhookPort: process.env.PORT,
you will need to object.assign the child too
yes and thats the problem
the wrapping Object.assign overwrites what the game property has already been modified to
i guess you'd have to loop over the object keys, and object.assign each child key lol
do that where tho thats what i cant figure out
no, it shouldnt
it assigns all of o
including the game property
which shouldnt be overridden once more
ah yes
you have to object assign them separately
or
object assign the object assigned o
cant i remove a property from an object but completely, without undefined bullshit
oh youre saying modify o first?
im pretty sure u can do delete object.property
o.game will just be undefined then and i dont want to experiment with what that will fuck up
Object.assign({
a:
b:{c:{}}
},{
a:10
b:Object.assign({c:{}},o.game)
})
``` something like this i guess
wait that still wont be enough
@raven urchin first way
so basically the same thing?
the same but inverted
ah
instead of changing the var then assigning it, i assign twice, the second one replacing the first
@white anvil an error
did you define addSnipe properly
whats the error then
addSnipe(client, msg)
thats the code not the error
the important part is the beginning of the error, which you didnt show lol
still missing the important part
That was the first part
your log is probably showing multiple copies of the same error
neither of those is the beginning of the error
Does anyone know how can I get the profilepicture of my bot (displayed on it's top.gg site) to update?
well, here is one actual error
your bot tried to do something that it doesnt have permissions for, and you didnt catch the error
That's weird
@pine jacinth mine updated by itself a few minutes after i changed it in the dev portal
Weird. Mine is the old one (default pick) since probably 1 day
will do
also, once it happened to me that the image wouldnt load, and i fixed it by resetting it in the dev portal
It worked, thanks TIm :D
👍
vps.cxllm.me (suppost to give you oauth login) but it gives me this
https://cdn.discordapp.com/attachments/626868989389438999/709064693553037352/adawdwaddwa.PNG any idea why?
well.. never knew pm2 used github pages oof lmao
lmao
a lot of static websites are
@mystic violet you're screwing up the redirection somehow
it works if you open the oauth url directly, but not when redirected from your website
the redirection should be done on server side, before the page loads
It should work then 
you're doing something weird then, because im seeing your page before being redirected
i should be redirected before the page loads
How to define the number of bots from a server?
filter them from the members cache
but this will not work for offline bots
ie: guild.members.cache.filter()
in discord.js v12
https://hasteb.in/udulefuy.js
/Users/sadashivappakenchannavar/Desktop/Frosty Revamp/commands/stonks.js:8
execute = async(message, args) => {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Invalid shorthand property initializer
but i dont even have that code
and i saved
well you clearly have that code
in stonks.js line 8
you're probably using = inside an object, where you should use : instead
How i can do something... To check if variable === null, then if variable null: variable = 1
Like this:
js
if(v===null) v=1;
code ```js
bot.on("guildMemberAdd", (member) => {
let chx = db.get(welchannel_${member.guild.id});
error:
```js
db.get is not a function```
Help ?
discord.js v11.5.1, quick.db
Show the code where you define db
const Discord = require("discord.js");
const db = require("quick.db")
Is that in the same file?
yes
Can you show the full code?
Is there a way I can do const events = require("./events"); and then to call a file inside the events folder just to events.fileName(p1, p2, p3)?
Make sure you remove the token
@wheat jolt i have the code in another file, should i show you here or in dm ? there are 106 lines of code
@abstract crow you can make an index.js in the events folder where you module.exports an object, if I understood good
@earnest phoenix use pastebin
Or hastebin
@wheat jolt i solved that error, but now i have other
.-.
Yeah but I'd rather just have it so in my events folder it's just my event files
code
const defaultmsg = new Discord.RichEmbed()
.setAuthor(`${message.member.username}`, message.member.displayAvatarURL)
.setTitle("**_Un nou membru tocmai a intrat!_**")
.setDescription(`:wave: -> ${message.member.username} s-a alaturat serverului **_${message.guild.name}_**!\n:wave: -> Nu uita sa citesti regulamentul!\n:wave: -> Speram ca te vei distra alaturi de noi!`)
.addField("User ID", `${message.member.id}`, "User Name", `${message.member.username}`)
.setFooter(`${message.guild.name}`, message.guild.displayAvatarURL);
bot.channels.cache.get(chx).send(defaultmsg)
events > message.js, etc
End goal is something like
client.on("message", async message => {
events.message(client, message)
});
events being a folder*
As I said, use an index.js file in the events folder
And export the events in an object
So I call an events index file, then which calls another file?
@earnest phoenix bot.channels.cache is not a property on v11.
^
Ok thank you. Sorry
v11 gang, you better switch to v12
You won't be able to turn your bot in mid-October if u use v11
@wheat jolt now i solved all the errors, but the bot still don't send any message on the specific channel, any idea why ?
no
do you want to see the code?
@hardy bough thats just wrong
you sure?
yes
he's sure
okay sorry then I'm wrong
in the events/index.js file, use this code:
module.exports = {
message: require('./message').run //.run should be your event's run function
}
and then, you can use your example code to call the events
const events = require('./events')
client.on("message", async message => {
events.message(client, message)
});
@abstract crow
When will the new domain be necessary?
Ah gotcha. Thank you good sir!
no?
whenever they stop paying for discordapp
Discord has finally made the switch to discord.com :tada:
With this change also means that the API endpoint is moving too! Please start moving your libraries, webhooks, and integrations over to using discord.com in place of discordapp.com.
We currently plan to start requiring the new domain later this year for third party developers on November 7th, 2020. We will be sending out more formal notices (system DMs and account emails) to announce this breaking change in the coming weeks.
---
addendum: the CDN domain (cdn.discordapp.com) will remain the same
ah
Yeah, 7 November then
wait wait lmao
Check #discord-news
they keep the domain but require discord.com?
why
if they keep using cdn.discordapp.com what's the point
Then v11 won't work after 7November
future™️
What was the point of the switch in the first place anyways
@hardy bough you know you can just modify the 1 line of code where it declares it as api base url
who?
the general public
like who puts discord"app".com
nobody adds the word "app" to their website. It just sounds stupid
Yeah, technically you can..
Every time I type "d" into the browser I do
Ok well there is 2 ways
Either way what's the big deal
It's more professional imho
It's not a big deal, just a change that was not required
discordapp.com sounds stupid. discord.com sounds better
why they're an app
Do you mean "why, they are an app" or "why are they an app?"
maybe they didnt have money for the domain when they started
Probably
well considering I used the contraction "they're" and didnt say "are they" the first one.
Yeah I'm kinda dumb
@quartz kindle - I got an error
r>stream http://online.kissfm.ua/KissFM_Deep_Live
[10/05/20 19:44:50] [ERROR] (node:23) UnhandledPromiseRejectionWarning: RequestError: Parse Error: Expected HTTP/
It was on the stream command you help me on
Everytime I boot up this happens (I’m thinking it’s a deleted giveaway that never actually finished)
probably
show code
let streamlink = args[0];
try {
let audiotypes = ["audio/aac","audio/mpeg","audio/opus"]
let check = await got(streamlink,{method:"HEAD"})
if(audiotypes.includes(check.headers["content-type"])) {
let connection;
try {
connection = await VC.join();
} catch (error) {
message.channel.send(` **Error occurred! Please retry the command again or contact support - https://discord.gg/**`);
}
const got = require('got');
My bot can't seem to find any messages in discord.js
guild.channels.cache.each(function(channel){
if (channel.type == "text"){
console.log("Exporting #" + channel.name + "...");
console.log(channel.messages.cache.array())
console.log(channel.lastMessage)
channel.messages.cache.each(function(message){
console.log(message.content);
console.log("hey")
});
}
});
Works completely fine except for not printing out any messages and just empty arrays
do this ```js
let check;
try {
check = await got(streamlink,{method:"HEAD"});
} catch(e) {
console.log(streamlink,e);
return
}
I wrote a similar script in python and it works perfectly and finds all messages
yeah it's feelsbad
@sullen salmon are you trying to get old messages, from before the script started?
all variable declarations must be lexical!!
Yhea @quartz kindle
that script will only work on messages received after your script goes online
let streamlink = args[0];
try {
let audiotypes = ["audio/aac","audio/mpeg","audio/opus"]
let check;
try {
check = await got(streamlink,{method:"HEAD"});
} catch(e) {
message.channel.send(` **Stream link unable to be played!**`);
console.log(streamlink,e);
return;
}
if(audiotypes.includes(check.headers["content-type"])) {
So like this?
old messages are not cached
Oh, how do I retrieve messages from before the script gets run?
Wait you can also use fetch without arguments and it just gives you all?
Never knew that lol
Thanks!
What are the limitations?
if you dont pass a limit, the default is 50 messages
afaik the max is 100
per request
and i dont think you can fetch messages that are over 2 weeks old
But it works fine in discord.py
There I can fetch every message on the server no matter how old
Ik you cant bulkdelete messages over 2 weeks old
7235 in total @quartz kindle
sounds like a lot of api abuse
It's my own server
i guess py handles the multiple requests internally
this is straight from the discord docs max number of messages to return (1-100)
let perms = message.channel.permissionsFor(bot.user)
if (!perms.has(['READ_MESSAGE_HISTORY', 'EMBED_LINKS'])) return;
Will this be correct?
How do I react to the bot being invited into a server?
That's an event @gloomy imp
guildCreate
https://oliy.is-just-a.dev/fm4o2j_3892.png it's limited by discord yeah
so d.py must just loop it
fetching a ton of messages and saving the last message as a cursor
imagine fetching a channel with over a million messages
I put that as a limit because no way do I have a channel with that many messages, the goal was just to get all
im surprised py even allows that xd
but well, rate limits will still be respected, so it will just be slow af
that's still an extra minute of startup (or whenever you call it I dont have context)
Does it scale linearly?
The only thing it does is printing the messages so not a big deal
assuming fetching messages shares the same 5/5 rate limit as sending them, thats 500 per 5 seconds, times 12 = 6000 per minute
Damn I'm only on python for a minute now and I already hate indentation again
lmao
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 stream = encoder.createReadStream();
message.channel.send({
files: [{ attachment: stream, name: "myfile.gif" }]
});
encoder.start();
// use node-canvas
const canvas = createCanvas(320, 240);
const ctx = canvas.getContext("2d");
const background = await Canvas.loadImage(message.author.displayAvatarURL);
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
ctx.font = "40px sans-serif";
// Select the style that will be used to fill the text in
ctx.fillStyle = "#000000";
// Actually fill the text with a solid color
ctx.fillText("#TRIGGERED", canvas.width / 40.5, canvas.height / 1.8);
encoder.addFrame(ctx);
encoder.finish();
message.channel.send(stream);
}```
like thats my code and i want to add a background color to the text
but idk how to do that
how would i make it behind the text though
draw it before drawing the text
all graphics are laid on top of each other in the same order as the code
so its like a fore ground layer background layer and so on'
yes, each time you call a method that draws something, its like creating a layer on the canvas
okay thank ou
My music bot Chord was working just fine until now. Now whenever I trying playing anything, in the console it says:
2020-05-10T21:18:58.978313+00:00 app[worker.1]: (node:4) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions
2020-05-10T21:18:58.978325+00:00 app[worker.1]: at RequestHandler.execute (/app/node_modules/discord.js/src/rest/RequestHandler.js:170:25)
2020-05-10T21:18:58.978326+00:00 app[worker.1]: at runMicrotasks (<anonymous>)
2020-05-10T21:18:58.978326+00:00 app[worker.1]: at processTicksAndRejections (internal/process/task_queues.js:97:5)
2020-05-10T21:18:58.978380+00:00 app[worker.1]: (node:4) 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)
2020-05-10T21:18:58.978424+00:00 app[worker.1]: (node:4) [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.```
I meant the Could not extract html5player key: https://www.youtube.com/s/player/0acb4375/player_ias.vflset/en_US/base.js error. I fixed the other one
What version of ytdl-core do you have?
I just updated ytdl-core-discord to 1.2.0 and 2.1.2 for ytdl-core
https://oliy.is-just-a.dev/xzhuya_3894.png found this on the github
Great. So my bot is broken until further notice?
whats the difference between them anyway?
I use both actually
no idea
there are so many variants of ytdl for some reason
apparently ytdl-core-discord simply tries to find an opus stream from a youtube video instead of using ffmpeg
falls back to ffmpeg if the video doesnt have an opus stream
I was programming in java
i had 200 lines of code
and i deleted the whole folder
accidentaly
im sorry

and you didnt make a backup
for (var a = 0; a < number; a++) {
var choice = array[Math.floor(Math.random() * array.length)];
choices.push(choice)
array.splice(array.indexOf(choice) - 1, 1);
}
this should work in creating multiple randomised choices right?(It isnt its doing the same ones sometimes)
its random
Im splicing the array
check array.splice
i see
its still not working for no reason
can you replicate this bug?
5 items in the array
aight
why splice index-1?
const request = require("superagent");
request.get("https://emilia-api.glitch.me/api/beautiful") // query can be used at the end of url like `?image=URL`
.set("Authorization", "Bearer YourTokenHere") // authentication
.query({ image: "https://i.redd.it/9kmsp9g62mzz.jpg" }) // the image to be used in the meme (Also work with query parameter above).
.then((res) => res.body); // handle the Buffer somehow ¯\_(ツ)_/¯```
how could i turn a request like that in a var so i can send it in a message
Ah rip
Thought indexOf as .length ;-;
as .length starts from 1
indexOf starts from 0 tho
Thanks tim
Again.....
@wet iron Hey fixed thanks for trying
you could also do a single liner lol```js
choices.push(array.splice(array.indexOf(Math.floor(Math.random() * array.length)),1))
lmfao one liners people
for the sake of my friend whos learning coding i'd pass
@wet iron Hey fixed thanks for trying
@small prairie NICE
haha true
could anyone help me turning a request in to a var soi can send it in a message
client.commands.get(command).execute(message, args);//line 29```
const levelInfo = await client.db.get(`level-${message.guild.id}-${message.author.id}`, {
level: 1,
xp: 0,
totalXp: 0
})//line 38-42```
if(message.content.startsWith(prefix + 'test')){
const request = require("superagent");
let fish = request.get("https://emilia-api.glitch.me/api/triggered") // query can be used at the end of url like `?image=URL`
.set("Authorization", "Bearer NjA2Mjc5MzI5ODQ0MDM1NTk0.oT34XsUAZwPvOAYugwaOzbzT05hgA0GxsIJ97Y71s") // authentication
.query({ image: message.author.displayAvatarURL}) // the image to be used in the meme (Also work with query parameter above).
.then((res) => res.body); // handle the Buffer somehow ¯\_(ツ)_/¯
message.channel.send(fish)
}``` it says cant send empty message
it would be better if we get more details
me?
@hardy vector what is client.db? client.db is undefined
also you passed the wrong args into your command
k i fixed i removed client from client.db things and took out client from the execute thing
but same error
wait different
error
what did you do?
Hello guys ...
Does anyone explain the complete steps for the servers to appear on the bot page?
npm i dblapi.js
@placid hamlet #topgg-api
@hardy vector https://www.npmjs.com/package/vultrex.db
you're using this package wrong
Lmao
wdym im using it wrong
my internet dead or API slow?
check their example and you'll see
if(message.content.startsWith(prefix + 'test')){
const request = require("superagent");
let fish = request.get("https://emilia-api.glitch.me/api/triggered") // query can be used at the end of url like `?image=URL`
.set("Authorization", "Bearer NjA2Mjc5MzI5ODQ0MDM1NTk0.oT34XsUAZwPvOAYugwaOzbzT05hgA0GxsIJ97Y71s") // authentication
.query({ image: message.author.displayAvatarURL}) // the image to be used in the meme (Also work with query parameter above).
.then((res) => res.body); // handle the Buffer somehow ¯\_(ツ)_/¯
message.channel.send(fish)
}``` it says can't send empty message
you gotta wait that AFAIK
what'\
assuming superagent works like that (their example is a bit different)
you need to either await it, or use .then
the result that you get inside .then can only be used inside it
so in your case
let fish = await request.get(...).set(...).query(...)
message.channel.send(fish.body)
``` or ```js
request.get(...).set(...).query(...).then(fish => {
message.channel.send(fish.body)
})
