#development

1 messages · Page 919 of 1

nocturne grove
#

yeah ok but I've found more in the docs that doesn't do what it says

#

and some things are missing

#

TypeError: Discord.Util.CleanCodeBlockContent is not a function 🤦

mossy vine
#

lowercase

nocturne grove
#

oh oops. Thanks

#

that's totally me

#

works now. Thanks

delicate zephyr
#

@heavy marsh try process.uptime() I forgot it was a function lol

heavy marsh
#

Thank you but I already fixed it 🙂 - @delicate zephyr

delicate zephyr
#

Okie

opaque seal
#

How do I check if my bot has higher permissions than another? So if it's able to change permissions of another bot

drifting bramble
#

how can i add shards to my bot? (python)

limber flume
#

shards?

frail ocean
#

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".

formal hill
#

Pls weekly

regal saddle
opaque seal
#

@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.

earnest phoenix
#

get the highest role of both users and compare their positions

frail ocean
#

^

opaque seal
#

nice thank you

stuck scaffold
#

client.user.setActivity(Games[random], type: 'DND' ); @earnest phoenix

#

Games[random]'dan kastım buydu

earnest phoenix
#

özelden anlatsana

plush lion
#

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)

    })
stuck scaffold
#
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

earnest phoenix
#

ok

#

ee değişmedi

stuck scaffold
#

v11 mi v12 mi

#

@earnest phoenix

bleak jewel
#

DND küçük olcak

summer torrent
#

english only

bleak jewel
#

Turksh only

summer torrent
#

?

#

read rules

earnest phoenix
#

Cringe

bleak jewel
#

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ı

opaque seal
#

What's the best practice for removing send messages permissions from a guild member?

summer torrent
#

english only @bleak jewel

limber flume
#

hello @tepid nimbus

earnest phoenix
#

@earnest phoenix throw ur own error

tepid nimbus
#

Hey @limber flume

limber flume
#

ok

#

so what library u main?

tepid nimbus
#

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

limber flume
#

ok

#

whats that message

tepid nimbus
#

Like a reset reminder

limber flume
#

reset? can you explain more

heavy marsh
#
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
tepid nimbus
#

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

cinder patio
#

Director, id should be lowercase

opaque seal
#

What's the best practice for removing send messages permissions from a guild member?
anyone knows?

heavy marsh
#

IOh thank you

limber flume
#

a game?

cinder patio
#

Giu, it depends, do you want to change them for a specific channel, or the whole server

opaque seal
#

Whole server yeah

cinder patio
#

Using a role

opaque seal
#

Does member.permissions.remove('SEND_MESSAGES') do it?

#

Using a role
this would be quite inconvinitent

cinder patio
#

No such thing as member.permissions

opaque seal
#

there is

#

in discord.js

cinder patio
#

It's read-only

opaque seal
#

but wait, there is a remove method in them

tepid nimbus
#

@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

opaque seal
#

when is it used for then?

#

I'm not getting the point of those permissions

cinder patio
#

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

opaque seal
#

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?

cinder patio
#

You can make it / the server admins can make it the highest role

#

yes

opaque seal
#

ok

#

I thought it would be easier

limber flume
#

u liuke python @tepid nimbus

opaque seal
#

How can I remove a certain permission from a role though?

#

Seems like I have to use bitfields, isn't there an easiest way?

toxic jolt
summer torrent
#

"url must be a string"

#

show your code

toxic jolt
vivid crescent
#

can't use empty text

toxic jolt
#

hmm

vivid crescent
#

? : ''

toxic jolt
#

i how to fix this empty text error

vivid crescent
#

if its empty just don't continue the code and tell the user they need to give an argument

toxic jolt
#
  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

earnest phoenix
#

Oof

summer torrent
#

if its empty just don't continue the code and tell the user they need to give an argument

toxic jolt
#

already have

earnest phoenix
#

not

#

have

vivid crescent
#

Do an additional check, your replacement regex may make the string empty

#

idk

toxic jolt
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
#

Should I use args.slice instead of args?

#

okay

earnest phoenix
#

@toxic jolt if (!args[0]) uyarısını üste koy

toxic jolt
#

i fixed

#

tamam teşekkürler

earnest phoenix
#

How i can highlight code ??

summer torrent
#

highlight?

cinder patio
#

you left click and hover over the code you want to highlight if that's what you mean?

earnest phoenix
#

hightlight in discord

wild delta
#

that's syntax highlighting

#

you do that by adding the the language tag to the beginning of the code block

dire abyss
vivid crescent
#

flavours smugMLG

earnest phoenix
#

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

tepid nimbus
#

Hey @limber flume my skill set on coding languages are really limited and really basic

limber flume
#

i can teach u

earnest phoenix
#

xD

#

or you can look at docs

#
limber flume
#

im py

earnest phoenix
#

oof

#

anyone can help me ?

limber flume
#

with?

lusty quest
#

is the IF valid?

earnest phoenix
#

IF = ??

lusty quest
#

if(data.Countries[i].CountryCode == code) is code valid? otherwise it will use else

earnest phoenix
#

yes

#

it is valid

#

if i remove else() it will work

#

no problem

lusty quest
#

hmm

earnest phoenix
#

mhm

lusty quest
#

is you country code exactly code or is it a value you set on a other point?

earnest phoenix
#

other point

#

u mean on json file

lusty quest
#

its possible that you need to run this async bcs the country code is not valid at execution

earnest phoenix
#

wut

#

i dont understand

lusty quest
#

my coding knowledge is not the best but i think you need to run it async

earnest phoenix
#

how ?

#

i dont understand what u mean

lusty quest
earnest phoenix
#

u mean i put if() in async()

#

oh i mean else

lusty quest
#

i hust got a other idea. how did you get the code value?

#

maybe there is the issue

earnest phoenix
#

with args[0]

#
let code = args[0]
lusty quest
#

hmm

#

where did you get this from? data.Countries[i].CountryCode

earnest phoenix
#

corona api

lusty quest
#

there could be the issue

earnest phoenix
#
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

lusty quest
#

api calls can be slower than your code execute. i think you need to run your api call asyncrouse

earnest phoenix
#

no

#

no i added this let msg = await message.channel.send("Working....");
will it work ??

lusty quest
#

this will await that the message got send

earnest phoenix
#

so it will let api load

#

?

#

or it stop the code

lusty quest
#

try to run your request with await -> asyncrouse

#

then it should wait until the API answered

lapis ocean
#

@turbid bough hey, you here?

turbid bough
#

kind of

lapis ocean
#

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

turbid bough
#

yeah you can do that. if you just want to use querystring

earnest phoenix
#

look back at this

wise quartz
#

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: GWcodesPython)

earnest phoenix
#

@turbid bough the else() is loopping

turbid bough
#

just the else?

earnest phoenix
#

yes

turbid bough
#

like, how exactly?

earnest phoenix
#

no country found

#

no country found

#

no country found

#

no country found

#

like that

turbid bough
#

well, does data.Countries[i].CountryCode == code equal false? yes

earnest phoenix
#

what

turbid bough
#

well, if you have a for loop

earnest phoenix
#

aha

turbid bough
#

and you use an if statement

earnest phoenix
#

yes

turbid bough
#

and if that if statement is false, then it goes to else

earnest phoenix
#

yes

turbid bough
#

But if its something unintentional, you would have to check what data you are comparing

#

by using console.log() or debugging

earnest phoenix
#

the Corona Virus Api

turbid bough
#

nono thats fine

#

im talking about this data: Countries[i].CountryCode

#

and your code

earnest phoenix
#

i will try to console.log(Countries[i].CountryCode)

turbid bough
#

btw, it seems also like you are trying to use like it .find

earnest phoenix
#

yes

#

no

lapis ocean
#

@turbid bough guess what, the # character breaks the query string

earnest phoenix
#

idk

turbid bough
#

data.Countries.find(x => x.CountryCode == code)

earnest phoenix
#

console.loged it and the output are the country codes

turbid bough
#

is it a list of country codes?

earnest phoenix
#

yes

turbid bough
#

with the [i] part?

earnest phoenix
#

no like

#

GB
US
. . .

turbid bough
#

thats not what im asking

earnest phoenix
#

ah yes with [i] method

turbid bough
#

ok, so you know then CountryCode is an array

#

then you are going to compare it with code

earnest phoenix
#
    {
      "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

turbid bough
#

ooh

#

nvm yeah CountryCode is not an array then

earnest phoenix
#

yes

turbid bough
#

so, what is code by then?

earnest phoenix
#

the country code

#
let code = args[o];
turbid bough
#

yeah but what is the actual value

#

what values of arguments are you adding?

earnest phoenix
#

for example i type in chat "/corona US" so code is "US"

turbid bough
#

can you double check by printing out code?

earnest phoenix
#

are yall forgetting properties are case sensitive

#

okk

turbid bough
#

.toLowerCase()

earnest phoenix
#

nevermind im blind

#

maybe later i maxed limit request

#

xD

turbid bough
#

yeah, you don't want to do message.send in a for loop with an else

earnest phoenix
#

also

vivid crescent
#

are the objects linked to keys in your json?

earnest phoenix
#

have you heard of debugging lol

#

inspect your variables

turbid bough
#

(its called pressing F5)

vivid crescent
#

breakpoints S3hmmm

turbid bough
#

man its fun not checking what data values you are comparing

earnest phoenix
#

omg how long for this max request

#
You have reached maximum request limit.
#

:((

turbid bough
#

lol

#

you trying to send too many messages

vivid crescent
#

X-RateLimit

earnest phoenix
#

no i tested so many time so now . . .

turbid bough
#

yes, maby thats why lol

earnest phoenix
#

need to wait 10m

#

oof

modest maple
#

How df do u even hit the ratelimits lmao

earnest phoenix
#

LoL

turbid bough
#

he used message.send in a for loop

earnest phoenix
#

so what i should use

#

??

vivid crescent
earnest phoenix
#

message.reply ?

turbid bough
#

put it after the for loop

#

no lol

earnest phoenix
#

ik xD

turbid bough
#

you dont want to reply 100 times

earnest phoenix
#

LoL

#

wait

#

how i put it after for loop

#

when if() is in for()

turbid bough
#

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

limber flume
#

how to make bot display how many servers its in discord.py?

earnest phoenix
#

display where

limber flume
#

playing .help server: 23

#

or

#

.botinfo

#

in the embed it says

earnest phoenix
#

u mean

for{
  else
  {
    trueFalse = true;
  }
}
if(trueFalse == true)
{
message.send("Error");
}
limber flume
#

how many servers

earnest phoenix
turbid bough
#

@earnest phoenix something else, inside the if statement

slender thistle
#

P.S Python's built-in len function

limber flume
#

discord.bot.guilds?

slender thistle
#

discord.Client being an instance of your client/bot

earnest phoenix
#
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

turbid bough
#

so instead of assinging "i found nothing", you are assigning "i found something"

earnest phoenix
#

wut

#

i dont understand

#

oh btw

#

i console.loged the code

#

and the output is : US 100 times (maybe more)

turbid bough
#

😐

earnest phoenix
#

so ?

turbid bough
#

you are also sending 100s of "not found"

earnest phoenix
#

no

turbid bough
#

rate limiting the embed

earnest phoenix
#

no

#

i put the console.log outside the if()

turbid bough
#

thats good isnt it?

#

oh

#

wait

earnest phoenix
#

what ?

turbid bough
#

im not quite sure

earnest phoenix
#

about ?

#

Hmm

#

hmm

#

did u found the hosting

#

@earnest phoenix ??

#

No

#

why

#

i suggested

#

Rn Im Working On Economy System But....

turbid bough
#

there are probably 100's of countries with the us code

#

if so

earnest phoenix
#

Its Not Working

mystic violet
#

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?

Lightshot

Captured with Lightshot

vivid crescent
#

Should be careful

earnest phoenix
#

no it console.log "US" cuz the loop

vivid crescent
#

you may be banned if you continue spamming the api

earnest phoenix
#

who

turbid bough
#

you don't use authorize with query

earnest phoenix
#

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

mystic violet
#

hastebin

#

my boi

earnest phoenix
#

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

vivid crescent
#

I mean if you're sending 100 message requests to discord, they won't like that >.>

earnest phoenix
#

No

#

i am not sending 100 request

#

just repeating the msg

turbid bough
#

exactly

#

lol

earnest phoenix
#

with for()

#

@turbid bough helppp

mystic violet
#

@turbid bough wdym "you dont use authorize with query"

earnest phoenix
#

:((

#

wdym = what do you mean ??

turbid bough
#

you are getting 100 in if statement, you are using message.send in the if statement

earnest phoenix
#

what

mystic violet
#

Were you talking about my question or his? lol

earnest phoenix
#

i am not getting 100 in if(), is it in for()

#

not in if()

turbid bough
#

i thought you said in if

earnest phoenix
#

when -_-

turbid bough
#

still sending 100 in else though

earnest phoenix
#

yes

turbid bough
#

thats rate limiting

earnest phoenix
#

omg

#

so the question is HOW I CAN STOP ITT

turbid bough
#

dont use message.send in there

earnest phoenix
#

so how i can send msg to user that there Country Code is not found ??

vivid crescent
#

Store if the code has been found outside of the loop

earnest phoenix
#

oh ik how

#

yes

vivid crescent
#

If its found break the loop as well, you don't need to continue searching for something that has already been found

earnest phoenix
#

smart

turbid bough
#

you store the found item in a variable before the for loop

earnest phoenix
#

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

vivid crescent
#

You are still sending the message

earnest phoenix
#

is not sending embed

vivid crescent
#

bruh

earnest phoenix
#

i need [i] to send info

vivid crescent
#

if its found notFound should be set to true and the loop should terminate, not the other way around

turbid bough
#

console.log both data values

earnest phoenix
#

which both

#

xD

vivid crescent
#

@turbid bough he is setting it to false on each iteration

turbid bough
#

ik

earnest phoenix
#

what

#

var notFound = false;

#

i wrote it outside for()

earnest phoenix
#

but which item

turbid bough
#

in the if

earnest phoenix
#

i dont understand

#

u mean embed

turbid bough
#

the item you are sending

vivid crescent
#
let foundIndex = -1;

for (....) {
  if (mything[i] === otherthing) {
     foundIndex = i;
     break;
   }
}

if (foundIndex < 0) {
  // was not found
  return;
}

// Your index exists```
earnest phoenix
#

but i need [ i ] to see which array the info in

vivid crescent
#

I left out syntax so you don't just copy and paste

earnest phoenix
#

cuz there are many

vivid crescent
#

Which is why you are storing the index

earnest phoenix
#
"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

vivid crescent
#

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

earnest phoenix
#

ok

#

ok

copper cradle
#

imagine checking if a boolean is true

quartz kindle
#

could also simply use array.find()

copper cradle
#

😳

quartz kindle
#

rip

earnest phoenix
#

then how i can find x.TotalDeaths

#

?

quartz kindle
#
let data = array.Countries.find(country => country.CountryCode === code);
if(!data) { return "country not found" }
console.log(data.NewDeaths)
console.log(data.TotalDeaths)
earnest phoenix
#

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

sullen night
#

How many servers can a free heroku host can handle for a music bot?

modest maple
#

it cant

pale vessel
#

at least two

earnest phoenix
digital ibex
#

how can i create a reaction collector with eris?

pale vessel
#

try eris-additions

digital ibex
#

where r the docs for that?

pale vessel
#

actually

#

there's no reaction collector

#

only message

vivid crescent
#

Which intents are you using

#

might be related

digital ibex
#

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

restive furnace
#

i dont recommend ^

digital ibex
#

i do lol

#

i don't use djs

#

yes

earnest phoenix
quartz kindle
#

run enable pnpm in your glitch console

earnest phoenix
#

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

white anvil
#

so this happens when u try running it?

earnest phoenix
#

yes

white anvil
#

u need to do node .

earnest phoenix
#

ok thank you

white anvil
#

np

tight plinth
#

is there a eris equivalent of message.mentions or I have to hard code it?

earnest phoenix
#

run enable pnpm in your glitch console
@quartz kindle not fix it i will used

tight plinth
#

oh wait

#

nvm

limber flume
#

npm init?

#

mybie

earnest phoenix
#

@limber flume me?

limber flume
#

yes

#

try

#

npm init

earnest phoenix
#

wait

#

package name?

#

@limber flume

limber flume
#

just

#

press

#

enter

#

on everything baisicly

earnest phoenix
#

Ok wait

#

Not worked

#

@limber flume

limber flume
#

hrm

#

dm me

earnest phoenix
#

Okey

limber flume
#

🙂

pine jacinth
#

Does anyone know how can I get the onsite-profilepicture of my bot to update?

quartz kindle
#

@earnest phoenix show your package.json

earnest phoenix
#

@quartz kindle i will send you wait

#

@quartz kindle come dm

#

@quartz kindle sendend dm

quartz kindle
#

you have too many dependencies, delete everything that you're not using

earnest phoenix
#

Okeey

#

@quartz kindle deleted?

#

what is the heorku url for webhook

#

?

limber flume
#

hrm what

#

i use heroku

earnest phoenix
#

the webhook heroku url

quartz kindle
#

what url

earnest phoenix
tight plinth
mossy vine
#

string

tight plinth
#

according to docs im using the function as intended,o

#

o

#

fuc

#

am dumb

quartz kindle
#

@earnest phoenix not correct

earnest phoenix
#

then what is the url

#

?

quartz kindle
#

YOURPROJECTNAME.herokuapp.com/dblwebhook

earnest phoenix
#

oh

abstract crow
#

Is there any good command handlers online that I can use? A lot of the videos are outdated

mossy vine
#

make your own

earnest phoenix
#

@quartz kindle Do i need to remove the port in const dbl

#

webhookPort: 5003,

#

or what ?

abstract crow
#

Thats the thing is I have no clue how to

shell totem
#

@abstract crow which programming language?

abstract crow
#

The videos are outdated

#

Discord.js

#

Sorry my bad

tight plinth
#

so unbanning a member returns literally nothing. interesting...

shell totem
abstract crow
#

I'll try that one thx 🙂

shell totem
#

You're welcome

dusty oxide
#

Anyone run into attempting a reconnect error?

#

Code=1000 (ok) no reason

white anvil
gritty frost
#

np

raven urchin
#

In the events folder

white anvil
#

example

raven urchin
#

events/messageDelete.js because that's where the ready.js and message.js are

white anvil
#

ye show the code

raven urchin
#

That's for the events

white anvil
#

oh

#

do u have client.on('messageDelete') anywhere

raven urchin
#

In the index?

white anvil
#

well anywhere

#

index included

rare tangle
#

hi

gritty frost
#

np

raven urchin
#

lemme check real quick

rare tangle
#

anyone can help me with my problem

white anvil
#

can you help me by asking a question

rare tangle
#

Can I 😄

white anvil
#

you can

gritty frost
#

Jacher np problem fixed thanks reporting

raven urchin
rare tangle
#

When I modify a field at mongodb database some of my number fields also turning into string

white anvil
#

@raven urchin u arent calling the function to add a snipe anywhere?

raven urchin
white anvil
#

@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

raven urchin
#

So i add client.on('messageDelete')?

white anvil
#

u just need to call ur function somewhere in ur existing event

raven urchin
#

So do I add the client.on('messageDelete') in the event?

white anvil
#

no u already have that

#

this is that

#

const addSnipe = require(path to snipe add code)

#

addSnipe(client, msg)

raven urchin
#

so const addSnipe = require("snipes")
then execute: addSnipe (client, msg)?

quartz kindle
#

@earnest phoenix yes, remove the port

white anvil
#

is the snipes file in the same folder as ur index

earnest phoenix
#

ok

quartz kindle
#

and in your dblapi.js config, you use process.env.PORT as the port

white anvil
#

or how does the file tree look

earnest phoenix
#

How to define number of bots from o server? discord.js 11.5.1

raven urchin
#

the client.snipes = new Map(); and everything is in index.js

white anvil
#

yeah

#

but is snipes.js in a subfolder or what

raven urchin
#

there's is no snipes.js folder

earnest phoenix
#

@quartz kindle Well it says Cannot read property 'on' of undefined in dbl.webhook.on()

white anvil
#

is this code in a separate file

raven urchin
#

that code is in events

white anvil
#

and if so, where is it in relation to your index file

mossy vine
#

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)

white anvil
#

so its like

#

events/snipes.js?

raven urchin
#

it's events/messageDelete.js

white anvil
#

ok

raven urchin
#

So I'm guessing I need to change it to snipes.js?

white anvil
#

is this the only code in that file

raven urchin
#

that's the only code in the message delete

white anvil
#

@mossy vine try {...game} ig

#

@raven urchin yeah in which case u can name it whatever

earnest phoenix
#

How to define number of bots from o server? discord.js 11.5.1

mossy vine
#

what

white anvil
#

const addSnipe = require("./events/fileName.js")

raven urchin
#

Do I add that in index.js?

white anvil
#

and then in your client.on("messageDelete") function, add the file addSnipe(client, msg)

quartz kindle
#

@earnest phoenix i said to use process.env.PORT as your port, not to remove the entire port configuration?

white anvil
#

yes

raven urchin
#

And in the command itself?

white anvil
#

const addSnipe = require("./events/fileName.js") should be at the top of ur file

mossy vine
#

tim yes you are smart please tell me how i should do this c:

earnest phoenix
#

oh sorry

#

i didnt see it

quartz kindle
#

@mossy vine do what lmao

raven urchin
#

Ok

white anvil
#

u can merge object properties in the same way u merge elements in an array

#

with ... syntax

mossy vine
#

merging 2 objects but the properties are also objects and doing Object.assign on that too will get overridden by the wrapping Object.assign

white anvil
#

so u mean like

#

if u have two objects

#
const myObj = {
  a: 1,
  b: 2
};
const myObj2 = {
  c: 3
};
mossy vine
#

no not really

white anvil
#

and u want to convert this to single object

{
  a: 1,
  b: 2,
  c: 3
}
#

no?

mossy vine
#

no lemme explain

quartz kindle
#

you want that children properties get merged instead of completely overwriting another child right?

mossy vine
#
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
}```
white anvil
#

ah

earnest phoenix
#

@quartz kindle so webhookPort: process.env.PORT,

quartz kindle
#

you will need to object.assign the child too

mossy vine
#

yes and thats the problem

#

the wrapping Object.assign overwrites what the game property has already been modified to

quartz kindle
#

i guess you'd have to loop over the object keys, and object.assign each child key lol

mossy vine
#

😩

#

cant the spread operator do some magic like jacher said earlier

quartz kindle
#

did you try it?

#

...o.game

mossy vine
#

do that where tho thats what i cant figure out

quartz kindle
#

wait a sec

#

actually the way you have should work?

#

wth

mossy vine
#

no, it shouldnt

#

it assigns all of o

#

including the game property

#

which shouldnt be overridden once more

quartz kindle
#

ah yes

#

you have to object assign them separately

#

or

#

object assign the object assigned o

mossy vine
#

cant i remove a property from an object but completely, without undefined bullshit

#

oh youre saying modify o first?

steel drum
#

im pretty sure u can do delete object.property

mossy vine
#

o.game will just be undefined then and i dont want to experiment with what that will fuck up

quartz kindle
#
Object.assign({
  a:
  b:{c:{}}
},{
  a:10
  b:Object.assign({c:{}},o.game)
})
``` something like this i guess
#

wait that still wont be enough

mossy vine
#

hang on i think i got it

#

yeah got it

#

wow this is stupid

raven urchin
#

Which way?

quartz kindle
#

i guess lmao

#

i can show you what i have lmao

white anvil
#

@raven urchin first way

mossy vine
#

so basically the same thing?

quartz kindle
#

the same but inverted

mossy vine
#

ah

quartz kindle
#

instead of changing the var then assigning it, i assign twice, the second one replacing the first

raven urchin
white anvil
#

did you define addSnipe properly

raven urchin
#

yeah

#

I added it to the top of index.js

white anvil
#

whats the error then

raven urchin
#

addSnipe(client, msg)

white anvil
#

thats the code not the error

raven urchin
quartz kindle
#

the important part is the beginning of the error, which you didnt show lol

raven urchin
quartz kindle
#

still missing the important part

raven urchin
#

That was the first part

quartz kindle
#

your log is probably showing multiple copies of the same error

#

neither of those is the beginning of the error

pine jacinth
#

Does anyone know how can I get the profilepicture of my bot (displayed on it's top.gg site) to update?

quartz kindle
#

well, here is one actual error

#

your bot tried to do something that it doesnt have permissions for, and you didnt catch the error

raven urchin
#

That's weird

quartz kindle
#

@pine jacinth mine updated by itself a few minutes after i changed it in the dev portal

pine jacinth
#

Weird. Mine is the old one (default pick) since probably 1 day

quartz kindle
#

try going to its edit page in top.gg and update something random

pine jacinth
#

will do

quartz kindle
#

also, once it happened to me that the image wouldnt load, and i fixed it by resetting it in the dev portal

pine jacinth
#

It worked, thanks TIm :D

quartz kindle
#

👍

mystic violet
earnest phoenix
quartz kindle
#

lmao

amber fractal
#

a lot of static websites are

quartz kindle
#

@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

mystic violet
#

res.redirect()

#

right?

#

for express

quartz kindle
#

idk, possibly yes

#

i dont use express

mystic violet
#

It should work then zoomeyes

quartz kindle
#

you're doing something weird then, because im seeing your page before being redirected

#

i should be redirected before the page loads

earnest phoenix
#

How to define the number of bots from a server?

quartz kindle
#

filter them from the members cache

#

but this will not work for offline bots

#

ie: guild.members.cache.filter()

#

in discord.js v12

hardy vector
#

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

quartz kindle
#

well you clearly have that code

#

in stonks.js line 8

#

you're probably using = inside an object, where you should use : instead

hardy vector
#

hehe

#

didnt see that

iron scroll
#

How i can do something... To check if variable === null, then if variable null: variable = 1
Like this:

#

js

hardy bough
#

if(v===null) v=1;

earnest phoenix
#

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
wheat jolt
#

Show the code where you define db

earnest phoenix
#
const Discord = require("discord.js");
const db = require("quick.db")
wheat jolt
#

Is that in the same file?

earnest phoenix
#

yes

wheat jolt
#

Can you show the full code?

abstract crow
#

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)?

wheat jolt
#

Make sure you remove the token

earnest phoenix
#

@wheat jolt i have the code in another file, should i show you here or in dm ? there are 106 lines of code

wheat jolt
#

@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

earnest phoenix
#

@wheat jolt i solved that error, but now i have other

wheat jolt
#

.-.

abstract crow
#

Yeah but I'd rather just have it so in my events folder it's just my event files

earnest phoenix
#

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)
abstract crow
#

events > message.js, etc

#

End goal is something like

client.on("message", async message => {
events.message(client, message)
});
#

events being a folder*

wheat jolt
#

As I said, use an index.js file in the events folder

#

And export the events in an object

abstract crow
#

So I call an events index file, then which calls another file?

sudden geyser
#

@earnest phoenix bot.channels.cache is not a property on v11.

wheat jolt
#

^

earnest phoenix
#

ooohh

#

i forgot

wheat jolt
#

@abstract crow let me show you an example

#

Hold on

abstract crow
#

Ok thank you. Sorry

hardy bough
#

v11 gang, you better switch to v12

#

You won't be able to turn your bot in mid-October if u use v11

earnest phoenix
#

@wheat jolt now i solved all the errors, but the bot still don't send any message on the specific channel, any idea why ?

wheat jolt
#

no

earnest phoenix
#

do you want to see the code?

mossy vine
#

@hardy bough thats just wrong

hardy bough
#

you sure?

mossy vine
#

yes

wheat jolt
#

he's sure

hardy bough
#

okay sorry then I'm wrong

wheat jolt
#

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

hardy bough
#

When will the new domain be necessary?

abstract crow
#

Ah gotcha. Thank you good sir!

wheat jolt
#

np

#

When will the new domain be necessary?
@hardy bough what?

hardy bough
#

It will be necessary some day, won't it

wheat jolt
#

no?

mossy vine
#

yes

#

it will be

#

nov 7

amber fractal
#

whenever they stop paying for discordapp

abstract crow
#
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
wheat jolt
#

ah

hardy bough
#

Yeah, 7 November then

amber fractal
#

wait wait lmao

abstract crow
amber fractal
#

why

hardy bough
#

Then v11 won't work after 7November

mossy vine
#

future™️

amber fractal
#

What was the point of the switch in the first place anyways

mossy vine
#

@hardy bough you know you can just modify the 1 line of code where it declares it as api base url

abstract crow
amber fractal
#

who?

mossy vine
#

the general public

abstract crow
#

like who puts discord"app".com

#

nobody adds the word "app" to their website. It just sounds stupid

hardy bough
#

Yeah, technically you can..

amber fractal
#

Every time I type "d" into the browser I do

abstract crow
#

that's you

#
  • new people
amber fractal
#

or you could just search discord

abstract crow
#

Ok well there is 2 ways

#

Either way what's the big deal

#

It's more professional imho

amber fractal
#

It's not a big deal, just a change that was not required

abstract crow
amber fractal
#

why they're an app

hardy bough
#

Do you mean "why, they are an app" or "why are they an app?"

quartz kindle
#

maybe they didnt have money for the domain when they started

hardy bough
#

Probably

amber fractal
#

well considering I used the contraction "they're" and didnt say "are they" the first one.

hardy bough
#

Yeah I'm kinda dumb

heavy marsh
#

@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

onyx hare
#

Everytime I boot up this happens (I’m thinking it’s a deleted giveaway that never actually finished)

quartz kindle
#

probably

heavy marsh
#

What does that error mean?

quartz kindle
#

show code

heavy marsh
#
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](https://cdn.discordapp.com/emojis/678624265276358696.webp?size=128 "error") **Error occurred! Please retry the command again or contact support - https://discord.gg/**`);
}
#
const got = require('got');
sullen salmon
#

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

quartz kindle
#

do this ```js
let check;
try {
check = await got(streamlink,{method:"HEAD"});
} catch(e) {
console.log(streamlink,e);
return
}

sullen salmon
#

I wrote a similar script in python and it works perfectly and finds all messages

amber fractal
#

you could also define check with var

#

which allows it to be used in above scopes

quartz kindle
#

but then people will flame you for using var

#

lmao

amber fractal
#

yeah it's feelsbad

quartz kindle
#

@sullen salmon are you trying to get old messages, from before the script started?

amber fractal
#

all variable declarations must be lexical!!

sullen salmon
#

Yhea @quartz kindle

quartz kindle
#

that script will only work on messages received after your script goes online

heavy marsh
#
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(`![cross](https://cdn.discordapp.com/emojis/678626371110567973.webp?size=128 "cross") **Stream link unable to be played!**`);
console.log(streamlink,e);
return;
}

if(audiotypes.includes(check.headers["content-type"])) {
#

So like this?

quartz kindle
#

old messages are not cached

sullen salmon
#

Oh, how do I retrieve messages from before the script gets run?

quartz kindle
#

by fetching them from the api

sullen salmon
#

Wait you can also use fetch without arguments and it just gives you all?

#

Never knew that lol

#

Thanks!

quartz kindle
#

keep in mind that there are severe limitations

#

you cannot fetch all messages

sullen salmon
#

What are the limitations?

quartz kindle
#

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

sullen salmon
#

There I can fetch every message on the server no matter how old

quartz kindle
#

i guess they changed that then

#

but how many are you fetching?

amber fractal
#

Ik you cant bulkdelete messages over 2 weeks old

quartz kindle
#

ah so it was bulk deleting

#

not fetching

sullen salmon
#

7235 in total @quartz kindle

quartz kindle
#

mb

#

and in py you do it in a single request?

sullen salmon
#

Yep

#
channel.history(limit=10000000)
amber fractal
#

sounds like a lot of api abuse

sullen salmon
#

It's my own server

quartz kindle
#

i guess py handles the multiple requests internally

#

this is straight from the discord docs max number of messages to return (1-100)

sullen salmon
#

Oh well I'll just write it in py

#

Sad

heavy marsh
#
let perms = message.channel.permissionsFor(bot.user)
if (!perms.has(['READ_MESSAGE_HISTORY', 'EMBED_LINKS'])) return;

Will this be correct?

gloomy imp
#

How do I react to the bot being invited into a server?

sullen salmon
#

That's an event @gloomy imp

quartz kindle
#

guildCreate

amber fractal
#

so d.py must just loop it

#

fetching a ton of messages and saving the last message as a cursor

sullen salmon
#

Damn

#

Guess it's an edge case to need more than 100 messages anyway

quartz kindle
#

imagine fetching a channel with over a million messages

sullen salmon
#

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

quartz kindle
#

im surprised py even allows that xd

#

but well, rate limits will still be respected, so it will just be slow af

sullen salmon
#

Only takes like a minute for 7k messages

#

Weird

amber fractal
#

that's still an extra minute of startup (or whenever you call it I dont have context)

#

Does it scale linearly?

sullen salmon
#

The only thing it does is printing the messages so not a big deal

quartz kindle
#

assuming fetching messages shares the same 5/5 rate limit as sending them, thats 500 per 5 seconds, times 12 = 6000 per minute

sullen salmon
#

Damn I'm only on python for a minute now and I already hate indentation again

quartz kindle
#

lmao

queen needle
#
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

quartz kindle
#

draw a rectangle behind the text

#

fillRect

queen needle
#

how would i make it behind the text though

quartz kindle
#

draw it before drawing the text

#

all graphics are laid on top of each other in the same order as the code

queen needle
#

so its like a fore ground layer background layer and so on'

quartz kindle
#

yes, each time you call a method that draws something, its like creating a layer on the canvas

queen needle
#

okay thank ou

wintry sonnet
#

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.```
amber fractal
#

You're missing permissions

#

Most likely to send messages or speak

wintry sonnet
#

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

amber fractal
#

What version of ytdl-core do you have?

wintry sonnet
#

I just updated ytdl-core-discord to 1.2.0 and 2.1.2 for ytdl-core

amber fractal
wintry sonnet
#

Great. So my bot is broken until further notice?

amber fractal
#

ytdl-core-discord is broken it seems

#

I just use ytdl-core

quartz kindle
#

whats the difference between them anyway?

wintry sonnet
#

I use both actually

amber fractal
#

no idea

quartz kindle
#

there are so many variants of ytdl for some reason

amber fractal
#

isnt ytdl a command line tool anyways?

#

that's what ytdl-core is for right?

quartz kindle
#

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

wet iron
#

I was programming in java

#

i had 200 lines of code

#

and i deleted the whole folder

#

accidentaly

queen needle
#

im sorry

wet iron
queen needle
#

and you didnt make a backup

wet iron
#

yep

#

ah sh*t here we go again

#

btw

#

can someone that has perms

small prairie
#
  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)

wet iron
#

its random

small prairie
#

Im splicing the array

wet iron
#

if its doing the same ones

#

oh

small prairie
#

check array.splice

wet iron
#

i see

small prairie
#

its still not working for no reason

#

can you replicate this bug?

#

5 items in the array

wet iron
#

hmm

#

lemme try

small prairie
#

aight

hardy vector
quartz kindle
#

why splice index-1?

queen needle
#
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

small prairie
#

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

quartz kindle
#

you could also do a single liner lol```js
choices.push(array.splice(array.indexOf(Math.floor(Math.random() * array.length)),1))

small prairie
#

lmfao one liners people

hardy vector
small prairie
#

for the sake of my friend whos learning coding i'd pass

wet iron
#

@wet iron Hey fixed thanks for trying
@small prairie NICE

quartz kindle
#

haha true

queen needle
#

could anyone help me turning a request in to a var soi can send it in a message

quartz kindle
#

@hardy vector the error is not in that file lol

#

bot.js line 29 and bot.js line 38

small prairie
#

Yeah

#

Lmao

#

I was like

#

wtf where is get?

hardy vector
#
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```
queen needle
#
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
hardy vector
#

what did i do wrong tho

#

no other command gave me that error

small prairie
#

it would be better if we get more details

hardy vector
#

me?

quartz kindle
#

@hardy vector what is client.db? client.db is undefined

#

also you passed the wrong args into your command

small prairie
#

client.commands too maybe

#

Ahhh yeah

#

welp im off cya later

hardy vector
#

oh so can i take off client?

#

how did i pass wrong args

quartz kindle
#

args are passed by order, not by name

hardy vector
#

k i fixed i removed client from client.db things and took out client from the execute thing

#

but same error

#

wait different

#

error

quartz kindle
#

what did you do?

hardy vector
placid hamlet
#

Hello guys ...
Does anyone explain the complete steps for the servers to appear on the bot page?

hardy vector
#

npm i dblapi.js

small prairie
quartz kindle
#

you're using this package wrong

small prairie
#

Lmao

hardy vector
#

wdym im using it wrong

small prairie
#

my internet dead or API slow?

quartz kindle
#

check their example and you'll see

queen needle
#
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
small prairie
#

you gotta wait that AFAIK

queen needle
#

what'\

quartz kindle
#

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)
})