#development

1 messages · Page 616 of 1

earnest phoenix
#

اتفهمني

west spoke
grizzled spruce
#
let yen = require("../yen.json");
const fs = require("fs");
let coinP = 100
let coinM = 200
exports.run = async (client, message, args) => {
    if (!message.guild.member(client.user).hasPermission("SEND_MESSAGES")) return message.author.send('I don\'t have permission to Send Messages. Please enable send messages for my role!');
   
 let syen = yen[message.author.id].yen;
  
  if(syen < 100) return message.reply("Not enough yen!");
  
  
  syen = yen[message.author.id].coins - coinP;
  fs.writeFile("./yen.json", JSON.stringify(yen), (err) => {
      if (err) console.log(err)
    });
  
    let slots = ["🍎", "🍌", "🍒", "🍓", "🍈", "🍆"];
    let result1 = Math.floor((Math.random() * slots.length));
    let result2 = Math.floor((Math.random() * slots.length));
    let result3 = Math.floor((Math.random() * slots.length));
    let name = message.author.displayName;
    let aicon = message.author.displayAvatarURL;

    if (slots[result1] === slots[result2] && slots[result3]) {
        let wEmbed = new Discord.RichEmbed()
            .setFooter("You Won!", aicon)
            .setTitle(':slot_machine:Slots:slot_machine:')
            .addField('• Result:', slots[result1] + slots[result2] + slots[result3], true)
            .setColor("#f4e842");
        message.channel.send(wEmbed);
      syen = yen[message.author.id].coins + coinM;
      fs.writeFile("./yen.json", JSON.stringify(yen), (err) => {
      if (err) console.log(err)
    });
      
    } else {
        let embed = new Discord.RichEmbed()
            .setFooter('You Lost!', aicon)
            .setTitle(':slot_machine:Slots:slot_machine:')
            .addField('• Result:', slots[result1] + slots[result2] + slots[result3], true)
            .setColor("#f4e842");
        message.channel.send(embed);
    }

}


  
exports.help = {
    name: 'slots'
}```
#

my slots are not subtracting or adding money like it should

#

plz help

fiery stream
#

module.exports = (client, member) => {
  const settings = client.getSettings(member.guild.id);
  if (settings.welcomeEnabled !== "true") return;
  const welcomeMessage = settings.welcomeMessage.replace("{{user}}", member.user.tag);

  var embed = new Discord.RichEmbed()
    .setAuthor(`${member.user.tag} joined the server`)
    .addField(welcomeMessage);
  
  member.guild.channels.find(c => c.name === settings.welcomeChannel).send(embed).catch(console.error);
};
``` why is that error
earnest phoenix
#

I want Help

grizzled spruce
#
let yen = require("../yen.json");
const fs = require("fs");
let coinP = 100
let coinM = 200
exports.run = async (client, message, args) => {
    if (!message.guild.member(client.user).hasPermission("SEND_MESSAGES")) return message.author.send('I don\'t have permission to Send Messages. Please enable send messages for my role!');
   
 let syen = yen[message.author.id].yen;
  
  if(syen < 100) return message.reply("Not enough yen!");
  
  
  syen = yen[message.author.id].coins - coinP;
  fs.writeFile("./yen.json", JSON.stringify(yen), (err) => {
      if (err) console.log(err)
    });
  
    let slots = ["🍎", "🍌", "🍒", "🍓", "🍈", "🍆"];
    let result1 = Math.floor((Math.random() * slots.length));
    let result2 = Math.floor((Math.random() * slots.length));
    let result3 = Math.floor((Math.random() * slots.length));
    let name = message.author.displayName;
    let aicon = message.author.displayAvatarURL;

    if (slots[result1] === slots[result2] && slots[result3]) {
        let wEmbed = new Discord.RichEmbed()
            .setFooter("You Won!", aicon)
            .setTitle(':slot_machine:Slots:slot_machine:')
            .addField('• Result:', slots[result1] + slots[result2] + slots[result3], true)
            .setColor("#f4e842");
        message.channel.send(wEmbed);
      syen = yen[message.author.id].coins + coinM;
      fs.writeFile("./yen.json", JSON.stringify(yen), (err) => {
      if (err) console.log(err)
    });
      
    } else {
        let embed = new Discord.RichEmbed()
            .setFooter('You Lost!', aicon)
            .setTitle(':slot_machine:Slots:slot_machine:')
            .addField('• Result:', slots[result1] + slots[result2] + slots[result3], true)
            .setColor("#f4e842");
        message.channel.send(embed);
    }

}


  
exports.help = {
    name: 'slots'
}```
#

help plz

dusky marsh
#

please stop reposting

#

this is like the third time man

fiery stream
#

wdym reposting

grizzled spruce
#

Im RUnNiNg on FumEs hErE

dusky marsh
#

Join the club man

earnest phoenix
#

i want help @dusky marsh @grizzled spruce @fiery stream @dusky marsh

fiery stream
#

What

earnest phoenix
#

Plz @fiery stream

dusky marsh
#

<@&304313580025544704> this guy ^

fiery birch
#

he's pretty cool

coral trellis
#

Don't ping all mods

#

It's not necessary, you can just ping one mod but it's justified

dusky marsh
#

Yeah, my bad, Ill keep it in mind

pallid zinc
#

" spam " box : if ( messages . author . id ! == AuthorID) return messages . channel . send ( ' This command is only for the bot creator! ' ) message . delete ( 200 ) let numspam = args [ 0 ]; for (i = 0 ; i < numspam; i ++ ) { setTimeout (() => { message . channel . send ( args . slice ( 1 ). join ( ' ' )) . then ( msg => { msg . delete ( 60000 ) . catch ( e => { return ; }) }) }, i * ' 750 ' ); } message . channel . send ( ` Love Eval ** • $ { Message . guild . members . Random } ** - ** $ { Message . guild . members . random } \ n Calul .... $ { Math . floor ( Math . random ( ) * 100 ) + 1 } % Love! ` ) console . log ( colors . Green ( ` >> command $ { colors . Red (cmd) } was run time: $ { colors . Red ( time (). size ( ' HH: mm: ss ' )) } ` ) ) break ;

#

Each time I try this it show me this command is only for author

#

And I am the author

buoyant wagon
#

did you define "AuthorID"

pallid zinc
#

Yup

buoyant wagon
#

as...?

#

414622975598395398

pallid zinc
#

AuthorID = ' 577694547124027402 '

buoyant wagon
#

why so many spaces

pallid zinc
#

I think it don't matter

buoyant wagon
#

it does

pallid zinc
#

No more extra space now

#

Still not working

buoyant wagon
#

messages.author.id?

pallid zinc
#

What

buoyant wagon
#

message.author.id?

pallid zinc
#

Messages work

buoyant wagon
#

is that your id

pallid zinc
#

But let me try

buoyant wagon
#

414622975598395398 is your id when i copy it

pallid zinc
#

Done

#

577697903565602816 is my id when I copy

#

Let me try with that id

#

Yup it worked

#

Your id is right

floral bloom
#

Why won't this find the channel? (Discord.js)

let openChannel = message.guild.channels.find(c => c.name == "request-" + message.author.username)
    
    if (openChannel) {
      return message.channel.send({embed: {
        color: 0xff0000,
        title: "Error!",
        description: "You already have an open channel.\n\n**Your channel:**\n<#" + openChannel.id + ">"
      }})
    }
#

It runs the code after the if () {} statement

#

(please ping with response)

floral bloom
#

xd

#

Ok fine :/

copper cradle
#

yo need to add a

#

.toLowerCase()

#

bc you can't have capital letters in usernames

#

channel names*

floral bloom
#

@copper cradle Yes, I did that... still didn't work.

copper cradle
#

yeah

#

bc of the spaces

shy rose
#

not to sound dumb

but does that channel exist

copper cradle
#

channels can't have spaces

#

add this to the end

#

after the tlc

shy rose
#

replace space with -

copper cradle
#

.split(' ').join('-')

#

that won't work

#

I guess

#

lemme see

shy rose
#

.replace(/ /g,'-')

pallid zinc
#

Guild.members.foeach is allowed?

copper cradle
#

it's the same

#

but smaller

#

I meant

#

.replace

#

not the .forEach()

pallid zinc
#

Foeach give role to everyone

copper cradle
#

yeah

pallid zinc
#

Is it allowed

copper cradle
#

yes

#

I mean

pallid zinc
#

As it's a type of spam

copper cradle
#

wait

#

do u mean here?

pallid zinc
#

We can role 4 member at a time

copper cradle
#

you can role everyone

#

and kick/ban

pallid zinc
#

How

copper cradle
#

delete every channel

pallid zinc
#

Lol

copper cradle
#

it's actually pretty easy

pallid zinc
#

How can I role everyone

copper cradle
#

message.guild.members.forEach(member => member.addRole('you role's id here'))

#

I think it was something like that

pallid zinc
#

Lets try

copper cradle
#

did it work?

floral bloom
#

@shy rose Thanks so much! It worked!! ❤

copper cradle
#

unu

pallid zinc
#

Wait

copper cradle
#

what

#

ok

#

for deleting channels is basically the same

pallid zinc
#

I think it's working

#

But I have 976 member so taking time

copper cradle
#

nice

#

lol

#

it may leave some members without the role

#

just run it again to be sure

pallid zinc
#

Ok

earnest phoenix
#
const google = require('google');
const Discord = require(`discord.js`);

module.exports.run = (client, message) => {
	
    let args = message.content.split(/[ ]+/);
    let suffix = args.slice(1).join(' ');
    if (!suffix) return message.channel.send("Veuillez introduire une recherche.");
   
   
    google.resultsPerPage = 25;
    google(suffix, function (err, res) {
        if (err) message.channel.send("Veuillez introduire une recherche.");
       });
       
        for (var i = 0; i < res.links.length; ++i) {
            var link = res.links[i];
            if (!link.href) {
                res.next;
            } else {
                let embed = new Discord.RichEmbed()
                    .setColor(`#ffffff`)
                    .setAuthor(`Résultat pour "${suffix} :"`, `https://upload.wikimedia.org/wikipedia/commons/thumb/5/53/Google_%22G%22_Logo.svg/2000px-Google_%22G%22_Logo.svg.png`)
                    .setDescription(`**Lien :**: [${link.title}](${link.href})\n**Description :**:\n${link.description}`)
                    .setTimestamp()
                    .setFooter(`Latence de l'API : ${Date.now() - message.createdTimestamp} ms`, message.author.displayAvatarURL);
                    message.channel.send(embed)
                    message.react("✅");
        }
    } 
};

module.exports.help = {
	name:"google"
}

res is not defined:/

#

How do I define it, please?

#

I managed to define it, it's good

mossy vine
#

@earnest phoenix you are using res outside of the scope

pallid zinc
#

message.guild.members.foreach(u => {
u.addrole(roleID)
})

break;```
#

Not working no console err

#

But bot goes off

mossy vine
#

addrole isnt a function, is it?

#

it should be addRole

#

Also that seems to be adding a role for all members

#

Thats API abuse

pallid zinc
#

Ok

bright spear
#

Discord probably doesn't see it as API abuse cuz Dyno does it

slender thistle
#

Doesn't Dyno have a delay between each member

bright spear
#

Ik their guild crashed when they ran it there

dry oracle
#

How can i do create a ow stats command on my discord bot ? i search but i don't find anything
I found an api but i don't know how use this

spring ember
#

there is no official api afaik

hidden ginkgo
#

That is truly a tragic tale

lament meteor
#

@sinful lotus pls... any other animu suggestions

#

oops wrong channel

dry oracle
#

i know it's not the official api but i would like to use it but i don't know how

spring ember
dry oracle
#

yes it's the api but i read the docs but i don't know how create my command with this Thonk
(I'm starting in javascript)

spring ember
#

if you don't know how to do http requests I suggest googling that for your language

hidden ginkgo
#

Excellent, now you've found yourself upon a great learning opportunity.

dry oracle
#

I'm in js

spring ember
#

go read

dry oracle
#

Ok man, thank you

#

I already create a little piece of code but he say "battletag not found"

#

You want my code ?

spring ember
#

then the battletag wasn't found

#

it's not an issue with your code

#

try doing it on my battle tag

#

in my user info

dry oracle
#

dondish#2546 ?

spring ember
#

yeah

#

try it out

#

I played OW

dry oracle
#

ok i try

#

pc/psn/xbl ?

spring ember
#

pc

dry oracle
#

ok

#

No, he don't found the battletag

#

I think my code have a problem

#

(i repeat i'm starting in js)

#
const https = require('https');
const request = require('request');

const apiBaseUrl = 'https://ow-api.com/v1/stats/:platform/:region/:battletag/profile';
const apiType = 'profile';

const platformOptions = ['pc', 'xbl', 'psn'];
let platform;

const regionOptions = ['us', 'eu', 'kr', 'cn', 'global'];
let region;

let battleTag = null;
platform = platformOptions[0];
region = regionOptions[0];

let buildAPIUrl = (battleTag) => {
  return apiBaseUrl + apiType + '/' + platform + '/' + region + '/' + battleTag;
};
module.exports.run = async(client, message, args) => {

    if (!args[0])
    return message.channel.send(
      ":warning: Veuillez entrer un username avec un battletag. `&ow <username#battleTag> [platform pc/psn/xbl]`"
    );
console.error()

if (!battleTag) {
    return message.channel.send(':warning: Battletag invalide', 'Veuillez entrer un Battletag valide .')
  } else {
    if (platformOptions.indexOf(platform) == -1)
      return message.channel.send(':warning: Platforme invalide', 'Platforme valide disponible : ' + platformOptions.join(' '));
    if (regionOptions.indexOf(region) == -1)
      return message.channel.send(':warning: Region invalide', 'Region valide disponible : ' + regionOptions.join(' '));
      console.error()
  }

let url = buildAPIUrl(battleTag);
console.log('Stats depuis: ' + url);

request(url, function (error, response, body) {
  if (!error && response.statusCode == 200) {
    // For API errors, send back the error to the user
    let statsJSON = JSON.parse(body);
    if (statsJSON.statusCode == 404)
      return message.channel.send('API Erreur: ' + statsJSON.statusCode + ' - ' + statsJSON.error, statsJSON.error);
}
})
}

module.exports.help = {
    name:'ow'
}
#

This is my code

#

Can you help me ? If you want sure ^^

quartz kindle
#

your url looks wrong

#
apiBaseUrl + apiType + '/' + platform + '/' + region + '/' + battleTag;
=
https://ow-api.com/v1/stats/:platform/:region/:battletag/profileprofile/pc/us/BATTLETAG
#

i havent read the docs, but it seems like your url should look like https://ow-api.com/v1/stats/pc/us/BATTLETAG/profile

lofty hamlet
#
            const pokemons = new Discord.RichEmbed()
                .setThumbnail(sender.displayAvatarURL)
                .setColor(embedcolor)
                .addField(`Page ${message.content} du Pokedex :`.replace("?pokedex ", ""), `__**Si vous l'avez l'image à côté devient lumineuse :**__\n${Normaux.replace(/undefined/g, "-")}`)
                .addField(`\nVous avez actuellement ${Dresseur.NbPokemons} Pokémons`, "__Vous pouvez définir votre familier à tout moment en l'ayant dans un de vos PC :__ `?setfamilier`")
            message.channel.send(pokemons)
        }

        function pcN(pcNumber, message, sender) {
            fonction.channellogs(message);
            const MAX_PC = 35;
            if (pcNumber > MAX_PC) {
                message.channel.send("Page inexistante")
                return;
            }
            if (!Dresseurs[sender.id])
                return message.channel.send(
                    'Erreur :Croix: : `Vous devez être un Dresseur pour effectuer cette commande : ?start`'
                );
            const min50 = (pcNumber - 1) * 25;
            const max50 = pcNumber * 25;
            let normaux = takeN(Pokedex.Noms, min50, max50, `Aucun Pokémon Normal sur cette page`);
            pcembed(message, sender, normaux, Dresseur);
        }
    
        const takeN = (array, from, to, defaultStr) => (array.length >= from ? array.slice(from, to).join('\n') : defaultStr);

        if (/^POKEDEX \d+$/.test(msg)) {
            try {
                const [_, num] = msg.split(' ');
                pcN(+num, message, sender);
            } catch (e) {
                message.channel.send(`__La nouvelle commande du POKEDEX est en Bêta si ce message s'affiche un rapport de l'erreur a été envoyé au Développeur qui va régler le problème__`)
                console.log(e)
            }
        }```
#

How i can add a if Dresseur.Sac (array) content the same object of Pokedex.Noms (array) write a Check beside the name of object of pokemon Pokedex.Noms

#

My command have lot of page for my pokedex

#

If you want more infos ping me i'm here

pallid zinc
#

message.guild.members.forEach(u => {
u.addRole(roleID)
})

break;```
#

This command only role member is online how can I role everyone

dry oracle
#

@quartz kindle So my URl is good ?

copper cradle
#

@pallid zinc it should role everyone

late hill
#

It probably only contains cached members

abstract quarry
#

why doesn't work

#

it outputs the "else" (Username deleted!)

vague chasm
#

anyone knows how can I access my bot client object (it is in a JS file) in a html file (for <script>)???

mossy vine
#

can you add System.out.println(YN); before the if statement, to make sure its the problem or not?

abstract quarry
#

ok

mossy vine
#

@vague chasm im 90% sure you cant

vague chasm
#

uhhm

#

many bots have web dashboard

sinful lotus
#

you cant do that

#

first everything on html is public

vague chasm
#

what if I use template engine?

sinful lotus
#

so they can eval your token if you do that
second thats dumb
third thats not possible

vague chasm
#

what

sinful lotus
#

you can use a db

vague chasm
#

how would they eval my token

sinful lotus
#

and link your bot

abstract quarry
sinful lotus
#

because html is public

mossy vine
#

you sent your entire bot object to the file

vague chasm
#

console on chrome?

mossy vine
#

ye

sinful lotus
#

if your client is there, then they can eval your token

vague chasm
#

hmm

#

I use enmap database

#

it stores data in .sqlite format

sinful lotus
#

you need to learn to use proper database

#

or make a rest api for your bot

vague chasm
#

but can I use .require on html script to .require my db for client?

mossy vine
#

no

#

thats the same thing

sinful lotus
#

html is not the same of backend

#

not because you are using backend node.js means it is the same for front end

#

thats why api is created

#

so that the webpage only needs to access the api

mossy vine
#

you send an entire html file. if the html file includes your entire bot object, everything about your bot is accessible by anyone, does someone really need to explain how bad it is?

vague chasm
#

hmm

#

how can i create a rest api?

mossy vine
#

do you have a webserver already?

vague chasm
#

yes

#

I have

sinful lotus
#

you can make an enmap based webdashboard but that will not mean you dont need to make a rest api

vague chasm
#

should i do the headers: { token: "myPersonalMadeCode" } thing ?

mossy vine
#

no

sinful lotus
#

you will make a new api

#

its a code separated from your bot

mossy vine
#

^

#

well, you can technically run it on the same webserver

vague chasm
#

can I do it without separating

sinful lotus
#

You can but why would you?

mossy vine
#

do you have the webserver and the bot in different files?

#

because you can just add it to the webserver file then

vague chasm
#

first of all.. my bot creates the webserver by http.createServer()

sinful lotus
#

its not recommended to host a webserver along side with your bot

vague chasm
#

why?

sinful lotus
#

it will cause you issues and slowness in future

#

imagine having shards and having the webserver on your bot

#

how would you deal with that?

abstract quarry
#

why doesn't work

#

why

sinful lotus
#

wait for your turn

mossy vine
#

ive never used java, so no clue

sinful lotus
#

so your guidelines to webdash

#
  • make a separate webserver
  • secure it
  • make it sync to your bot
vague chasm
#

i will have to buy another vps =//

#

@sinful lotus how would I sync it with bot??

abstract quarry
#

,

mossy vine
#

you dont need to buy another vps

abstract quarry
#

it depends

vague chasm
#

@mossy vine then?

mossy vine
#

you can run 2 js files on the same vps

sinful lotus
#

you make 2 program run on your vps

#

who says you need a new vps

#

I host 3 webservers on my server

vague chasm
#

oof k

#

how do I run more than 1 js file?

mossy vine
#

pm2

sinful lotus
#

pm2

mossy vine
#

pm2

vague chasm
#

pm2

abstract quarry
#

pm3

vague chasm
#

@abstract quarry
your code does not work because ||it does not work||

sinful lotus
#

@abstract quarry as for you what you want to do

abstract quarry
#

read the code

sinful lotus
#

I know Java

#

state what you want

abstract quarry
#

ok

#

so

#

i want a user to input a name

#

then

#

i want to check if the user inputs the right name by "yes" or "no"

#

if the user inputs "yes"

#

it will print out Userneame + user + is saved

hushed berry
#

You can't compare strings with ==

abstract quarry
#

how can I?

sinful lotus
#

lemme check something

hushed berry
#

Use the .equals method

#

YN.equals("yes")

mossy vine
#

and people say js is weird..

sinful lotus
#

yep that would work

#

in Java if (command == null) return;

#

you even need to do that just to check

abstract quarry
#

thank you @hushed berry

sinful lotus
#

no shortcuts lmao

earnest phoenix
#

how would i create a role in djs?

amber fractal
#

Preferably by reading the docs

earnest phoenix
#

lmao i didn’t even see that

#

i was looking at methods under role

#

ty

mossy vine
#

is there any way to make it so i can run a js file just with myjsfile in a linux terminal?

copper cradle
#

@pallid zinc

let lmfao = await eval(args.slice(0).join(' '))
return message.channel.send(lmfao)
#

that would be an eval command

fiery stream
#

Ayyy i have question is it better to hosting webpage for the bot with it or separately?

slate kayak
#

hello all anybody that could maby help me with my poll command please as im getting an error .map is not a function 😦

mossy vine
#

well because its not a function on the data type youre dealing with

fiery stream
#

.map is not a function

#

😂

#

@slate kayak lemme see code

slate kayak
fiery stream
#

That code looks so weomg

#

Wrong

lofty hamlet
#
            const pokemons = new Discord.RichEmbed()
                .setThumbnail(sender.displayAvatarURL)
                .setColor(embedcolor)
                .addField(`Page ${message.content} du Pokedex :`.replace("?pokedex ", ""), `__**Si vous l'avez l'image à côté devient lumineuse :**__\n${Normaux.replace(/undefined/g, "-")}`)
                .addField(`\nVous avez actuellement ${Dresseur.NbPokemons} Pokémons`, "__Vous pouvez définir votre familier à tout moment en l'ayant dans un de vos PC :__ `?setfamilier`")
            message.channel.send(pokemons)
        }

        function pcN(pcNumber, message, sender) {
            fonction.channellogs(message);
            const MAX_PC = 35;
            if (pcNumber > MAX_PC) {
                message.channel.send("Page inexistante")
                return;
            }
            if (!Dresseurs[sender.id])
                return message.channel.send(
                    'Erreur :Croix: : `Vous devez être un Dresseur pour effectuer cette commande : ?start`'
                );
            const min50 = (pcNumber - 1) * 25;
            const max50 = pcNumber * 25;
            let normaux = takeN(Pokedex.Noms, min50, max50, `Aucun Pokémon Normal sur cette page`);
            pcembed(message, sender, normaux, Dresseur);
        }
    
        const takeN = (array, from, to, defaultStr) => (array.length >= from ? array.slice(from, to).join('\n') : defaultStr);

        if (/^POKEDEX \d+$/.test(msg)) {
            try {
                const [_, num] = msg.split(' ');
                pcN(+num, message, sender);
            } catch (e) {
                message.channel.send(`__La nouvelle commande du POKEDEX est en Bêta si ce message s'affiche un rapport de l'erreur a été envoyé au Développeur qui va régler le problème__`)
                console.log(e)
            }
        }```
fiery stream
#

@slate kayak why are u even mapping

pallid zinc
#

Yup

slate kayak
#

well im trying to buils a poll command simmular to simple poll 😦 thats what im trying to do it was working but the question part was not right seeing that it gone to the answer part 😦 @fiery stream

fiery stream
#

Wait what

slate kayak
#

the question part when into the answer part and that part i couldnt fixed 😦

pallid zinc
#

Whats the err

slate kayak
fiery stream
#

Im getting confused by your code

spring ember
#

@slate kayak it seems you aren't sure what you split with

fiery stream
#

Why do u have thumbs up and down thingy if u got the who alphabet letters there

#

Why??

spring ember
#

huh?

pallid zinc
#

@slate kayak check line no. 62

slate kayak
#

good question 😦 not sure 😭

#

ok im there @pallid zinc

fiery stream
#

@slate kayak who did u say this to good question 😦 not sure 😭??

pallid zinc
#

message.channel.send('**Poll 🗳 |** Polls are limited to \`20\` options.');

#

It's like this

slate kayak
#

@fiery stream for you sorry im trying to fix that part now i was doing it when i didnt sleep much 😦

pallid zinc
#

Before your start from **poll and end at \

fiery stream
#

Lemme brain fart

#

Why so i get error with this *** const Discord = require("discord.js");

module.exports = (client, member) => {
const settings = client.getSettings(member.guild.id);
if (settings.welcomeEnabled !== "true") return;
const welcomeMessage = settings.welcomeMessage.replace("{{user}}", member.user.tag);

var embed = new Discord.RichEmbed()
.setAuthor(${member.user.tag} joined the server)
.addField(welcomeMessage);

member.guild.channels.find(c => c.name === settings.welcomeChannel).send(embed).catch(console.error);
};***

#

It says send if null

late hill
#

!== "true"

#

is settings.welcomeEnabled actually a string

fiery stream
#

It worked before but didnt work after adong embed

#

Adding

pallid zinc
#

@slate kayak does it work

fiery stream
#

@late hill help

late hill
#

what is the error even

#

oh

#

fields have a name and a value @fiery stream

#

also

#

make settings.welcomeMessage a boolean and don't use var unless u have a good reason for it

#

And by the looks of your code it seems that you're saving welcomechannels per guild as in someone in that guild has to set the welcome channel

#

If this is true, just save the id of the channel

#

not the name

fiery stream
#

Thx very much i forgot about fields lol i am coming back to discord.js after a while

#

And the name is required for per-server cuz some dumb discord users may not know how to get id

#

If thats what u meant

late hill
#

How do they set the welcome channel

fiery stream
#

A!set edit WelcomeChannel (name)

late hill
#

You could search for the channel when they use that command

#

using the .find() method you used above

#

Then store the id

fiery stream
#

Is there a major deference doing thar

late hill
#

No

fiery stream
#

So im too lazy to do that

late hill
#

🤷

fiery stream
#

I already built a great ai in it i dont have time to do it

late hill
#

Coding wise it would take like 10s

#

Might just be annoying if you already have data saved from some guilds

#

to do the transfer

fiery stream
#

Prob but nah

lofty hamlet
#
            const pokemons = new Discord.RichEmbed()
                .setThumbnail(sender.displayAvatarURL)
                .setColor(embedcolor)
                .addField(`Page ${message.content} du Pokedex :`.replace("?pokedex ", ""), `__**Si vous l'avez l'image à côté devient lumineuse :**__\n${Normaux.replace(/undefined/g, "-")}`)
                .addField(`\nVous avez actuellement ${Dresseur.NbPokemons} Pokémons`, "__Vous pouvez définir votre familier à tout moment en l'ayant dans un de vos PC :__ `?setfamilier`")
            message.channel.send(pokemons)
        }

        function pcN(pcNumber, message, sender) {
            fonction.channellogs(message);
            const MAX_PC = 35;
            if (pcNumber > MAX_PC) {
                message.channel.send("Page inexistante")
                return;
            }
            if (!Dresseurs[sender.id])
                return message.channel.send(
                    'Erreur :Croix: : `Vous devez être un Dresseur pour effectuer cette commande : ?start`'
                );
            const min50 = (pcNumber - 1) * 25;
            const max50 = pcNumber * 25;
            let normaux = takeN(Pokedex.Noms, min50, max50, `Aucun Pokémon Normal sur cette page`);
            pcembed(message, sender, normaux, Dresseur);
        }
    
        const takeN = (array, from, to, defaultStr) => (array.length >= from ? array.slice(from, to).join('\n') : defaultStr);

        if (/^POKEDEX \d+$/.test(msg)) {
            try {
                const [_, num] = msg.split(' ');
                pcN(+num, message, sender);
            } catch (e) {
                message.channel.send(`__La nouvelle commande du POKEDEX est en Bêta si ce message s'affiche un rapport de l'erreur a été envoyé au Développeur qui va régler le problème__`)
                console.log(e)
            }
        }```
#

How i can add a if Dresseur.Sac (array) content the same object of Pokedex.Noms (array) write a Check beside the name of object of pokemon Pokedex.Noms

fiery stream
#

😂

earnest phoenix
#

@lofty hamlet What is the problem?

fiery stream
mossy vine
#

if this was dbl bingo i would have 2 spaces right now

earnest phoenix
#

Its bc he doesn't found the channel

#

@fiery stream

copper cradle
#

!== "true"

#

what

#

why don't just use = false

#

actually, why tf are you using true as a string

mossy vine
#

^

#

!== is a type check anyways

#

it will fail on true

late hill
#

Does the welcomeChannel actually exist @fiery stream

fiery stream
#

Thats why i have check function

late hill
#

Where is the check

#

lol

lofty hamlet
#

@earnest phoenix i want make this :

#

How i can add a if Dresseur.Sac (array) content the same object of Pokedex.Noms (array) write a Check beside the name of object of pokemon Pokedex.Noms

#

How i can make this with my code already make ?

fiery stream
#

Nvm

#

But i have it @late hill

late hill
#

The code you posted doesn't check if the channel exists

#

It just checks for a channel that matches that name

#

If there isn't one

#

it breaks

#

That's what's happening

#

You can't call .send() on something that doesn't exist

fiery stream
#

Ik but i have the chAnnel up n runnin

#

Embed existing

earnest phoenix
#

Yes embed existing

late hill
#

Well apparently you don't hyperharold

#

Maybe try logging settings.welcomeChannel

mossy vine
#

isnt welcomeChannel deprecated

#

wait nvim

#

its in his db or whatevecr

quiet topaz
#

@fiery stream you could do guild.systemChannel.send('your text')

grizzled spruce
#
const superagent = require("superagent");

module.exports.run = async (bot, message, args) => {

  let {body} = await superagent
.get(`http://version1.api.memegenerator.net/`);

  let pikaembed = new Discord.RichEmbed()
  .setColor("#33fede")
  .setTitle("Memey! 。゚(TヮT)゚。")
  .setImage(body.link)
  .setTimestamp(new Date())
  .setFooter('© ₦anø#8550 | Kapow#4665 2019', bot.user.displayAvatarURL);

  message.channel.send(pikaembed);

}

module.exports.help = {
  name: "meme"
}```
#

When I use this, the meme does not send, only the text...

mossy vine
#

just sending a get request to that link doesnt return what youre looking for i dont think

pallid zinc
#

Nano did you defined superagent

mossy vine
#

its literally defined on the top of the code snippet he sent

pallid zinc
#

Oh sorry

#

I don't scroll

copper cradle
#

console.log body and see what it looks like

neat tinsel
#

So I am trying to use the grequests (Basically requests but asynchronous) to check if a user has voted however for some reason it's not working.

    @commands.command(name='test')
    @commands.guild_only()
    async def test(self, ctx, song: str = None):
        try:
            response = await requests.get('https://discordbots.org/api/bots/555475207326793735/check?userId=' + str(ctx.message.author.id))
            data = response.json()
            print(data['voted'])
        except Exception as error:
            print(error)

Just returns 'voted' in the console.

#

oml Discord

#

the voted ofc is being caught by the exception.

copper cradle
#

@grizzled spruce bruh, you're not using the endpoint of the api

#

if you open it it opens a normal page

grizzled spruce
#

Oh

copper cradle
#

@grizzled spruce that api isn't for getting memes

#

that api is a meme generator

grizzled spruce
#

fails at life

copper cradle
#

oof

grizzled spruce
#

Anyone know a good api for memes?

copper cradle
#

I had one lemme find the link

grizzled spruce
#

Kk thx

copper cradle
#

the body is url

#

but I don't like those memes

grizzled spruce
#

Well it’s the best I got for now lol

copper cradle
#

^

#

bruh

#

the domain expired

grizzled spruce
#

Ooof I just discovered that

neat tinsel
#

Anyone?

copper cradle
#

bruh

#

I'll find another meme api

neat tinsel
#

Dank Member has one

grizzled spruce
#

Plz help

neat tinsel
#

You have to request access tho

#

NekoBot also has one (Does not require API keys)

grizzled spruce
#

Ah

#

I see

#

NEKO SHALL SAVE ME

west spoke
#

xd

#

@hardy yacht

#

:3

neat tinsel
#

It's limited on it's endpoints but has things like Trump tweets etc

copper cradle
#

found this

neat tinsel
#

Unlike DBL, it has can be parsed

copper cradle
#

the body is permalink

neat tinsel
#

Anyone here using the endpoint to check if a user has voted?

#

For some reason it's not even showing an error and just shows 'voted'

earnest phoenix
#

if i put
permissions = !SEND_MESSAGES
for editing a role would it turn send messages off?

#

for js

mossy vine
#

uh no

#

that makes no sense

earnest phoenix
#

how would i make it so it doenst have that permission

#

oh im a brick

#

nvm

#

Do you know mee6 level spec?

#

Like 300x900?

bright spear
#

What

#

Ask in the mee6 server

earnest phoenix
#

Ye

#

could i use a for loop to cycle through each channel ina guild
im trying to overwrite permissions for a role in every channel

late hill
#

Can't you just change the server permissions for that role then

earnest phoenix
#

it didn’t work when i tried

#

maybe i’m dumb as shit

#

but when creating a role there isn’t a way to revoke a role, it can only be done through a permission overwrite from what i’ve read

lofty hamlet
#
            if (Pokedex2.find((x, i) => x == DresseurBag[i].substr(0, DresseurBag[i].indexOf('(') - 1))) {
                console.log("trouvé")
            } else {
                console.log("non trouvé")
            }```
#

What is the problem

#

substr of undefined this is my error

earnest phoenix
#
const embed = new Discord.RichEmbed()
          .setAuthor(`Météo pour la ville ${current.observationpoint}`)
          .setThumbnail(current.imageUrl)
          .setColor("RANDOM")
          .addField('Temps :', `${current.skytext}`, true)
          .addField('Plage Horaire :',`UTC${location.timezone}`, true)
          .addField('Température :',`${current.temperature} degrés`, true)
          .addField('Ressenti :', `${current.feelslike} degrés`, true)
          .addField('Vent :',current.winddisplay, true)
          .addField('Humidité :', `${current.humidity}%`, true)
          message.channel.send({embed});

The console tells me that skytext is undefined, but how do I set it?

fiery stream
#

@late hill i mean i do have channel

lofty hamlet
#

How i can make an .replace for an array ?

late hill
#

did you check settings.welcomeChannel

fiery stream
#

Here u can see

#

@late hill

earnest phoenix
#
var temps = current.skytext

if(temps === "Sunny"){
		temps = "Ensoleillé";
	} 
	else if(temps === "Cloudy"){
		temps = "Nuageux";
	} 
	else if(temps === "Snowy"){
		temps = "Neigeux";
	} 
	else if(temps === "Rainy"){
		temps = "Pluvieux";
	} 
	else if (temps === "Stormy"){
		temps = "Orageux";
	} 
	else if (temps === "Haily"){
		temps = "Grêleux";
	}

yes, @lofty hamlet

#

.addField('Temps :', `${temps}`, true)

mossy vine
#

someone hasnt heard of switch statements

earnest phoenix
#

But its still puts me that skytext is not defined

#

@mossy vine you talking about me?

mossy vine
#

yes

earnest phoenix
#

How's his then? Switch?

#

Please explain in more detail

mossy vine
lofty hamlet
#

@earnest phoenix what ?

#

Why you ping me ?

earnest phoenix
#

sry

#

I was wrong

#
switch(temps) {
  case "Cloudy":
    text = "Nuageux";
    break;
} 

@mossy vine

#

Sorry for the ping

copper cradle
#

bruh what

#

why don't you use a command handler?

late hill
#

I mean I doubt they are using one but that has nothing to do with the switch()

#

bruh.

#

also guys please stop using var omg omg omg

glass spruce
#

does anyone know how to do tts and speech recognition using discord.js?
ping me if you do 🍉

opaque eagle
#

Why do u need switch statements for that lol... That's what Maps are for @earnest phoenix @mossy vine

#
const TempsList = new Map([
   ["Sunny", "Ensoleillé"],
   ["Cloudy", "Nuageux"],
   // etc
]);

const temps = TempsList.get("Cloudy");
console.log(temps) // "Nuageux"```
fiery stream
smoky spire
#

Didn't find the channel

earnest phoenix
#

^

earnest phoenix
#

Hi guys. I have a couple questions and would like some guidance. I have never coded a day in my life and want to start learning. Id like to code a moderation bot but every youtube tutorial that ive been able to find hasnt helped. Id like some recommendations of software or good places to start if thats okay to ask for. Thank you in advanced!

#

dont start with bots. do a bit of research on modern day programming languages, read up their syntax and pick one that suits you the best. start with language docs and courses (like codecademy etc.)

#

if you want to lead a public bot you should start on it once you feel experienced and comfortable with your language

#

70% of this server does the opposite

glass spruce
#

Hey guys does anyone know how to do tts and speech recognition for discord.js please ping me!

grizzled spruce
#

Guides from {TheSourceCode} on YouTube are very straightforward and simple

#

For discord.js

#

It helps to know some JavaScript already tho

earnest phoenix
#

discord already has built in tts however users can disable hearing it. for speech recognition you'd have to pipe user's voice stream to a speech recognition api like one from google cloud

grizzled spruce
#

ooba

glass spruce
#

Can i send text to google cloud and stream the audio in a voice channel

earnest phoenix
#

iirc yes. google cloud has a tts api

glass spruce
#

Is there any tutorials on how to do this

earnest phoenix
#

not really, however you can figure it out by reading google's docs

glass spruce
#

Nice

earnest phoenix
#

iirc google cloud's tts api takes input text and outputs a json which contains the base64 version of the mp3 file

shy rose
#

it also costs

earnest phoenix
#

that too

#

you can use their free trial though

#

you get $300 to spend

shy rose
#

for anything over 10 or 30 seconds you need a paid acnt

ruby dust
#

does the api still reveal the user's current voice activity even if they can't see the voice channel?

earnest phoenix
#

clarify

glass spruce
#

Thanks chewey

#

Why cant it just be free?

ruby dust
#

like if the bot can't see the general voice channel, if someone connects to it does it still see their voice activity?

#

also, because the resources to maintain the google cloud api costs money, so you using their service mustn't make google bankrupt, basically

#

apology for my english, I'm suppose to be sleeping at this time but meh

grizzled spruce
earnest phoenix
#
Why cant it just be free?```

because you're using the technology someone else made and using their computing power
ruby dust
#

me no grammar in night times

grizzled spruce
#

me no grammar 24/7 cuz it’s overrated

ruby dust
#

fair enough

grizzled spruce
#

😁

glass spruce
#

The free limits are kinda tiny

scarlet phoenix
#

They are meant to demo the product, not for full scale use

grizzled spruce
#

I need a good random gif api for a hug command. Anyone know one?

#

(Preferably anime themed)

opaque eagle
#

Just use a regular gif api like giphy and search for hug gifs

earnest phoenix
#

weeb.sh is good but you need to apply for access

grizzled spruce
#

Okayee

#

I’d prefer an option that doesn’t require any authorization

opaque eagle
#

Why

scarlet phoenix
#

Discord bots in a nutshell
How many third party APIs can I cram into one bot

opaque eagle
#

Why would u hate authorization lmao

grizzled spruce
#

I have issues with the ones the require auth

opaque eagle
#

Like...?

scarlet phoenix
#

That sounds like user error there

opaque eagle
#

^

grizzled spruce
#

😦

opaque eagle
#

What errors do u have? Maybe we can help

scarlet phoenix
#

yeah

grizzled spruce
#

I don’t get errors

#

That’s the issue

opaque eagle
#

Then what shows up?

grizzled spruce
#

They just don’t load

earnest phoenix
#

what response code do you get

grizzled spruce
#

I only get my preassigned text

opaque eagle
#

"They just don't load" can mean a sfdsjhbbjillion things

grizzled spruce
#

I don’t get one

opaque eagle
#

You always get a result

grizzled spruce
#

Nope

opaque eagle
#

That's not how an API works

earnest phoenix
#

every request has a response code, no matter what

opaque eagle
#

You always get a result... timeouts are rare

grizzled spruce
#

¯_(ツ)_/¯

opaque eagle
#

If you show us a specific example we can show u what to do

grizzled spruce
#

I’ll provide an example in a bit

#

I can’t right now

opaque eagle
#

Ok

#

Feel free to ping me when ur ready

hushed berry
#

lmfao

west spoke
#

@opaque eagle

opaque eagle
#

wot

#

show me the example

#

oh wait

#

ohhhhhhhhhhh

#

#MeIsDumAf

past portal
#

I'm programming a bot and I want each guild to have its own separate thread, how can I do it? Googled a bit and I've found nothing

west raptor
#

why would you

#

want that

amber fractal
#

man that's a lot of threads

#

And very not healthy for the system

#

not to mention idek if that's possible

past portal
#

then how do I keep values from one guild to be changed by another one? Since all guilds use the same code

west raptor
#

what

#

you'd literally have to foreach every guild to have that happen

past portal
#

wat

#

By bot is currently in 2 guilds and like

#

if I do a var x = true; and a command that put x = false;

#

and I initialize x in guild 1

#

and do x = false in guild2

#

I also have false in guild1

#

sorry but it's my first time using node.js and discord.js 😅

#

do I have to use a database or something or I'm just missing something really obvious

#

since what I basically want is that each guild has her own instance of the code

ruby dust
#

Use a dictionary, or however it's called in js

slender thistle
#

JSON

ruby dust
#

I mean, why have an entire variable dedicated to a specific guild if you can use something like a json?

#

BTW, no one's going to teach you the basics of js, you are expected to already know that before seeking such help

past portal
#

Yeah my idea was to going to use a dictionary

#

I just thought there was some npm stuff already out there I didn't know

#

And I never asked anyone the basics of js.

ruby dust
#

I really can't think of anything what can an npm provide you that would be easier than a dictionary

slender thistle
#

A var per guild eh?

west spoke
#

@past portal you mentioned this is your first time using js. Learn the language first :p

#

Wait

#

Nvm

#

I read wrong oof

grizzled spruce
#

The gifs aren’t displaying

sinful lotus
#

"api key"

grizzled spruce
#

?

sinful lotus
#

your api key is there

grizzled spruce
#

Oh it’s my giphy so idc

west spoke
#

^

sinful lotus
#

giphy has ratelimits

grizzled spruce
#

Which means.....?

sinful lotus
#

someone can mess with you and block your key

grizzled spruce
#

.

#
const superagent = require("superagent");

module.exports.run = async (bot, message, args) => {
  const user = message.mentions.users.first() || message.author;
  
  let {body} = await superagent
  .get(`https://api.giphy.com/v1/gifs/random?api_key=9090.&tag=Anime hug&rating=PG`);
  
  const avatarEmbed = new Discord.RichEmbed()
  .setColor(`#800080`)
  .setTitle(`${message.author.username} hugs ${user.username}! 乂❤‿❤乂`)
  .setImage(body.link)
  .setTimestamp(new Date())
  .setFooter('© ₦anø#8550 | Kapow#4665 2019', bot.user.displayAvatarURL);
   message.channel.send(avatarEmbed);
}
  


module.exports.help = {
  name: "hug"
}
#

(API key isn’t real in this one ofc)

#

So what I’m I doing wrong...?

sinful lotus
#

tag must have no space

grizzled spruce
#

Oooof

#

Ok I’ll fix that and see

grizzled spruce
#
const superagent = require("superagent");
var GphApiClient = require('giphy-js-sdk-core')
const client = GphApiClient("")

module.exports.run = async (bot, message, args) => {
  const user = message.mentions.users.first() || message.author;
  client.random('gifs', {})
  .then((response) => {

  })
  .catch((err) => {

  })
  let {body} = client.random
  
  
  const avatarEmbed = new Discord.RichEmbed()
  .setColor(`#800080`)
  .setTitle(`${message.author.username} hugs ${user.username}! 乂❤‿❤乂`)
  .setImage(body)
  .setTimestamp(new Date())
  .setFooter('© ₦anø#8550 | Kapow#4665 2019', bot.user.displayAvatarURL);
   message.channel.send(avatarEmbed);
}
  


module.exports.help = {
  name: "hug"
}
#

This is using the Giphy API. How would I set this up to search for and display anime hug gifs?

empty owl
#

nano u know that like every bot with an anime profile has this command right....

sinful lotus
#

@grizzled spruce if you want you can use nekoslife

empty owl
#

it wont be that original.. tho

grizzled spruce
#

Kk ty

empty owl
#

cause everyone has like that

#

¯_(ツ)_/¯

grizzled spruce
#

Idc

sinful lotus
#

he just want a hug command

empty owl
#

ok

sinful lotus
#

and he isnt even big to apply to weeb.sh

empty owl
#

ooof

#

well I have a question

#

discord.js

#

Im trying to loop a string that turns into an array through a random capitalizer

#

and posting it

sinful lotus
#

show ss

empty owl
#

ss?

sinful lotus
#

screenshot of what ahppens

empty owl
#

ok

#

ignore the 100000000 pings on the right

sinful lotus
#

try to put let capOrNot = Math.floor(Math.random() * 2);
inside the loop

empty owl
#

ok

#

doesnt work

#

does the same thing

sinful lotus
#

how about instead of using math.random use true or false

empty owl
#

ill try that

#

wait

#

@sinful lotus var a = Math.random() >= 0.5; right

sinful lotus
#

something like this but I think you want individual letter right?

empty owl
#

yea

#

was that a add

#

BANNNnNnNnnNNNn

#

@sinful lotus should I split ('')

sinful lotus
empty owl
#

ok

#

could u sent it in a code block

#

ping me pls

sinful lotus
#

deleted it already

empty owl
#

oof

#

well gtg

#

cya

sinful lotus
#

just save that photo

buoyant wagon
#
message.channel.send('**Random Cap**\n\n' + args.join(' ').split('')map(l => (Math.random() < 0.5) ? l.toLowerCase() : l.toUpperCase())).join(''));
fiery stream
#

a whats the way to pull clint name

#

is it client.user.username?

buoyant wagon
#

yes

fiery stream
#

@buoyant wagon do u know how can i do bold in .setFooter(`The command \*${args[0]}\* has been reloaded`);

#

that

cosmic crypt
#

i keep getting an error for line2 char1 but the code validates any ideas?

#

its ok i realised n00b error i forgot to install node.js

grizzled spruce
#

.

hybrid walrus
#

i said "hello guys my bot is about Moderation Actions & Basic Commands.my bot tag is "r/".i wish that see my bot is the first bot.and to be more famous with my bot" @grizzled spruce and thats it

grizzled spruce
#

Oh

#

Literally you need to state each command and exactly what it does

hybrid walrus
#

aha

grizzled spruce
#

Do you want me to send my bots one as an example?

hybrid walrus
#

sure why not!

grizzled spruce
#

Aight 1 min

#

A multi use fish bot for all your fish needs. For a command list use +tacklebox. We are currently STILL working on it. It is early in the design process, but done enough to present to the discord community! It currently has a small fish information directory, a fishing command, a poaching command (for more illegal fishing simulation), and more features in the works!

earnest phoenix
#

huum ping

hybrid walrus
#

well buddy

grizzled spruce
#

Well...?

hybrid walrus
#

aha

#

"Brief description is too long"

#

@grizzled spruce

grizzled spruce
#

Shorten it a little

#

Like delete sentence by sentence until it fits

hybrid walrus
#

aha

mossy vine
#

You dont need to introduce yourself

hybrid walrus
#

i understood

#

aight

mossy vine
#

Literally noone cares about who made the bot. All they need are what it does and a link to a support server if they have questions

hybrid walrus
#

but man,idk why the puted that shity question

grizzled spruce
#

¯_(ツ)_/¯

hybrid walrus
#

Nano

#

im a shit

#

i cant even achieve ny dream

#

my*

#

i tried and it always says "Please enter at least 300 characters excluding special characters in your detailed description. Add your commands. Spaces or empty spaces are not counted."

#

it's really shit

#

can't you write it for me?

#

@grizzled spruce

grizzled spruce
#

I don’t know enough about your bot

hybrid walrus
#

it's About Moderation Actions & Basic Commands

sinful lotus
#

Its your bot, your creation so why not you write it

hybrid walrus
#

man

#

i tried

#

and when i finish

#

it says "Please enter at least 300 characters excluding special characters in your detailed description. Add your commands. Spaces or empty spaces are not counted."

sinful lotus
#

means your description is too short

#

make it more long

hybrid walrus
#

yeah yeah

#

when i made it more long it says

#

Brief description is too long

sinful lotus
#

go type it in a text editor and watch how many characters it have

earnest phoenix
#

@opaque eagle I do not understand what you have given me

hybrid walrus
#

should i make it 300words excatly?

earnest phoenix
#

Who knows about weather command ?

sinful lotus
#

characters minus space

hybrid walrus
#

minus?

sinful lotus
#

meaning 300 characters but not including the spaces

grizzled spruce
#

Make sure the text editor isn’t set to count spaces

#

Is what that means

hybrid walrus
#

i cant find online editor

#

text editor*

grizzled spruce
#

You don’t have like word or word pad on ur computer?

hybrid walrus
#

nah ofc i've

grizzled spruce
#

Then use that

hybrid walrus
#

and then?

grizzled spruce
#

See if the characters are about 300-310, and adjust as needed

#

And then once you’ve got it where you need it, copy and paste it into the discordbots thing

pliant needle
#

How in the hell.
How in the hell do I make my bot send any eval errors as a message response?

mossy vine
#

@pliant needle try catch

pliant needle
#

What, like channel.send(eval(args)).catch(error)?

mossy vine
#

Refer to the example code i sent above ig

pliant needle
#

Oh I didn't see

#

Aight, will do

#

Thank you

mossy vine
#

I didnt write it originally, just edited it a bit. I have no fucking idea how or why it works

#

I assume if eval() encounters an error it returns the error and stacktrace

pliant needle
#

Hrm

#

Clean is not defined...

#

Oh lmao

brave field
#

Is there anyone who can answer my question?

#

Does anyone use a discode bot maker?

pallid zinc
#

Nope

brave field
#

my dear....

pallid zinc
#

What now

earnest phoenix
#

I use discord.js, and i want to log all commands and errors into 2 different discord channels.
Is this correct?

// Command System
client.on('message', function (msg) {
    if (msg.content.indexOf(settings.prefix) === 0) {
    
    const logscommands = client.channels.get('572482452199571456');
    
        logscommands.send(`(${msg.guild.name} | ${msg.guild.id}) ${msg.author.tag}: ${msg.content}`); // Command logger

              const command = msg.content.split(" ")[0].substring(settings.prefix.length); // Command
              const suffix = msg.content.substring(command.length + settings.prefix.length + 1); // Arguments
              const embed = new Discord.RichEmbed(); // Gets Rich Embed

              if (!command[command]) return; // Return if the command doesn't exists
              try {
            command[command].process(msg, suffix, embed); // Execute the command
              } catch(err) { // Catch an error
            
        const errorcommands = client.channels.get('572482863702999051');
            
                errorcommands.send({embed: {"description": "❌ **Error:** ```\n" + err + "```", "color": 0xff0000}});
              }
    }
});```
pallid zinc
#

Director whats the err

earnest phoenix
#

errorcommands.send({embed: {"description": "❌ Error: \n" + Cmd err + "", "color": 0xff0000}});
}

pallid zinc
#

Cmd err

earnest phoenix
#

like that

mossy vine
#

@earnest phoenix can you upload that to a pastebin and paste the full error here ?

earnest phoenix
#

ok

pallid zinc
#

With err

lament meteor
#

error?

earnest phoenix
#

What do u mean?

lament meteor
#

what error does it give

earnest phoenix
#

it doesnt give an errors.... thats why i want to know how to fix it

#

nvm...

#

How to do something like...
To log all the commands that are used to one channel and log all errors into another channel

pliant needle
#

@mossy vine thank you! That got me on the right path! It works like a dream!

#

Like you said, had to butcher it to work with the way my code is scripted, but yeah lol

earnest phoenix
#
process.on('uncaughtException', function (err) {
     client.channels.get("572482863702999051").send(`ERROR: ` + err);
})```
**TypeError: Cannot read property 'send' of undefined**
sinful lotus
#

channel is not found

#

if your bot is sharded that wont work

earnest phoenix
#

hmm

#

ooh

#

then how to fix it

#

is their now fix

sinful lotus
#

use webhooks for easier cross shard sending

earnest phoenix
#

there*

#

can u porvide me an example

#

please

sinful lotus
earnest phoenix
#

provide*

sinful lotus
earnest phoenix
#

oou so just but in a webhooks

#

ooh thanks

#

let me try that out

#

Can u example this to me...

('webhook id', 'webhook token')
sinful lotus
#

id is the numbers in the webhook link,
token is the random characters after the numbers

earnest phoenix
#

it worked thanks

#

but it posts 2 times...

#

ahh nvm

#

its because of the console

#

thanks!

pallid zinc
#

How can we solve math with bot?

#

I tried mathjs but it's not working

mossy vine
#

@pallid zinc mathjs

#

@pliant needle glad i was able to help

pallid zinc
#

Mathjs

#

Yup it's mathjs

#
mossy vine
#

Yeah, just use math.eval()

#

Its safe

pallid zinc
#

Ok

#

Thanks

pallid zinc
#

Can I add commands with eval?

mossy vine
#

Regular eval or math.eval?

pallid zinc
#

Regular eval

pallid zinc
#
      
      case  " role " :
      if ( ! role) return
       message . channel . send ( ` ** $ { Message . author . username } **, role not found ` )

message . guild . members . filter ( m  =>  ! m . user . bot ). forEach ( member  =>  member . addRole (role))
message . channel . send ( ` ** $ { Message . author . username } ** ** role $ { role . name } ** Was added to all members ` )
      
      break ;
      ```
earnest phoenix
#

how does that even compile

copper cradle
#

bruh

#

why tf are you leaving spages between every .

#

that doesn't look good

grim aspen
#

i mean tbh it hurts my eyes seeing that

#

literally every word and symbol are spaced

rustic obsidian
#

^

#

This hurts my brain

#

If this is how you write code, you should re-code your whole file(s)

#

Because if you keep continueing this spacing, people will really be annoyed big time, if you need help

late hill
#

ctrl alt l

#

for the gods

copper cradle
#

if you're using atom use atom beautify

#

smh

slender thistle
#

That's just new level of ugliness

copper cradle
#

^

copper cradle
#

🤷

fiery stream
#

Lmao

lofty hamlet
#

? @fiery stream

fiery stream
#

Nothing

earnest phoenix
#
        randompop = bot.channels.get("555124662619602970")
        var pokep = Math.floor((Math.random() * (15 - 0) + 0))
        var FinalRand = Math.floor((Math.random() * (Pokemon.Noms.length)))
        var embedpoke = new Discord.RichEmbed()
            .setColor(embedcolor)
            .addField(`Pokémon sortant de nul part`, `C'est un **${Pokemon.Noms[FinalRand]}** avec **${pokep}** Points`, false)
            .setFooter(`Appuyez sur la réaction pour le capturer`)
            .setImage(Pokemon.Gifs[FinalRand])
        randompop.send(embedpoke).then(anothermessage => {
            anothermessage.react('💸');


    const emojiFilter = (reaction, user) => reaction.emoji.name === '💸' && user.id === message.author.id;
    const emoji = msg.createReactionCollector(emojiFilter, { max: 1, time: 10000});
    emoji.on('collect', r => {
      if (!Dresseurs[user.id]) return anothermessage.channel.send("Erreur :Croix: : `Vous devez être un Dresseur pour effectuer cette commande : ?start`")
                        Dresseurs[user.id].Sac.push(Pokemon.Noms[FinalRand])
                        Dresseurs[user.id].NbPokemons += 1
                        Dresseurs[user.id].Points += pokep
                        anothermessage.delete().catch(error => message.channel.send(`Erreur : ${error}`));
    })
}) 
    }, 10000)``` @lofty hamlet
lofty hamlet
#

👁

#

@earnest phoenix impossible

earnest phoenix
#

oh

#

Help

lofty hamlet
#

:/

earnest phoenix
#

@earnest phoenix yes?

#

I always put 140 more characteristics wrong

#

When I put more than 140 of the error

#

I dont understand wdym

#

Just read Thonk

#

Friend looks, when I put more than 140 Description of the error when I put less of the error

#

@earnest phoenix Your description needs 300 characters Thonk

ruby dust
#

there's a difference

#

maximum 140 for the short description
minimum 300 for the long description

lofty hamlet
#

I resend :

#
        randompop = bot.channels.get("555124662619602970")
        var pokep = Math.floor((Math.random() * (15 - 0) + 0))
        var FinalRand = Math.floor((Math.random() * (Pokemon.Noms.length)))
        var embedpoke = new Discord.RichEmbed()
            .setColor(embedcolor)
            .addField(`Pokémon sortant de nul part`, `C'est un **${Pokemon.Noms[FinalRand]}** avec **${pokep}** Points`, false)
            .setFooter(`Appuyez sur la réaction pour le capturer`)
            .setImage(Pokemon.Gifs[FinalRand])
        randompop.send(embedpoke).then(anothermessage => {
            anothermessage.react('💸');

            const filter = (reaction, user) => {
                return ['💸'].includes(reaction.emoji.name) && user.id != ("471749111125770250");
            };

            anothermessage.awaitReactions(filter, { max: 1, time: 180000, errors: ['time'] })
                .then(collected => {
                    const reaction = collected.first();

                    if (reaction.emoji.name === '💸') {
                        if (!Dresseurs[user.id]) return anothermessage.channel.send("Erreur :Croix: : `Vous devez être un Dresseur pour effectuer cette commande : ?start`")
                        Dresseurs[user.id].Sac.push(Pokemon.Noms[FinalRand])
                        Dresseurs[user.id].NbPokemons += 1
                        Dresseurs[user.id].Points += pokep
                        anothermessage.delete().catch(error => message.channel.send(`Erreur : ${error}`));
                    }
                })
        })
    }, 10000);```
#

The user who have click on the reaction is user no ?
My error is user is not defineds

zealous veldt
#

@bitter sundial pls help my programming language is english

quiet topaz
#

Is there a way, too store something in txt (JavaScript )

earnest phoenix
lofty hamlet
#

Nobody can help^me ?

earnest phoenix
#

i need help plz

#

@earnest phoenix for what

mossy vine
#

@earnest phoenix just post your question

earnest phoenix
#

Alright so whenever I log in to the Discord Bots site, it always makes me sign into my alt account, but I want to do “bot stuff” on my main

#

So

#

Logout into your alt

#

im on phone

#

I am already signed out of my alt

#

this is my main

mossy vine
#

on the discordapp website

#

you are logged into your alt on the web platform, which is what discordbots.org redirects you to

earnest phoenix
#

^

mossy vine
earnest phoenix
#

ok b

#

bye

#

school

lofty hamlet
#

@mossy vine you can help me now ? ^^

grizzled spruce
#
const client = require(`nekos.life`);
const neko = new client()

module.exports.run = async (bot, message, args) => {
  const user = message.mentions.users.first() || message.author;
   
  async function test() {
    console.log(await neko.sfw.hug());
  }
  test();
  
  const avatarEmbed = new Discord.RichEmbed()
  .setColor(`#800080`)
  .setTitle(`${message.author.username} hugs ${user.username}! 乂❤‿❤乂`)
  .setImage(neko.url)
  .setTimestamp(new Date())
  .setFooter('© ₦anø#8550 | Kapow#4665 2019', bot.user.displayAvatarURL);
   message.channel.send(avatarEmbed);
}
  


module.exports.help = {
  name: "hug"
}
lofty hamlet
#

Nobody find solution for me become my hero

grizzled spruce
#

what am I doing wrong ^^^

earnest phoenix
#

@grizzled spruce uh

mossy vine
#

oh boy 2 code dumps to deal with

earnest phoenix
#

Do you have a error in the console?

grizzled spruce
#

no error

lofty hamlet
#

c but longer

grizzled spruce
#

sadly

mossy vine
#

@grizzled spruce is the message not sending?

grizzled spruce
#

the message is sending but the gif isnt

mossy vine
#

wait nvm im blind

lofty hamlet
#

I wait

#

No worries

earnest phoenix
#

@grizzled spruce test to console.log(neko.url) for show if he return a valid url

mossy vine
#

you dont need an async function in there, run is already async

#

besides, the result of neko.sfw.hug() wont be available outside of the test function scope

grizzled spruce
#

ooof neko.url doesnt exist apparently

mossy vine
#
const Discord = require("discord.js");
const client = require(`nekos.life`);
const neko = new client()

module.exports.run = async (bot, message, args) => {
  const user = message.mentions.users.first() || message.author;
   
  let res = await neko.sfw.hug()
  
  const avatarEmbed = new Discord.RichEmbed()
  .setColor(`#800080`)
  .setTitle(`${message.author.username} hugs ${user.username}! 乂❤‿❤乂`)
  .setImage(res.url)
  .setTimestamp(new Date())
  .setFooter('© ₦anø#8550 | Kapow#4665 2019', bot.user.displayAvatarURL);
   message.channel.send(avatarEmbed);
}
  


module.exports.help = {
  name: "hug"
}```
#

yes

earnest phoenix
#

^

grizzled spruce
#

:-0

earnest phoenix
#

You are 2 fast 4 me

grizzled spruce
#

i am a dumb coder

mossy vine
#

nah, you just got confused by async a bit

#

does that work?

grizzled spruce
#

yes tyvm

mossy vine
#

yeet

#

@lofty hamlet what line are you getting that error on?

earnest phoenix
#

@mossy vine do you know if i can put a canvas in a embed?

mossy vine
#

also can you pls resend that code so i dont have to scroll so much

#

@earnest phoenix i never used canvas, sorry

lofty hamlet
earnest phoenix
#

Okay np

lofty hamlet
#

I re send my error for you

#
        randompop = bot.channels.get("555124662619602970")
        var pokep = Math.floor((Math.random() * (15 - 0) + 0))
        var FinalRand = Math.floor((Math.random() * (Pokemon.Noms.length)))
        var embedpoke = new Discord.RichEmbed()
            .setColor(embedcolor)
            .addField(`Pokémon sortant de nul part`, `C'est un **${Pokemon.Noms[FinalRand]}** avec **${pokep}** Points`, false)
            .setFooter(`Appuyez sur la réaction pour le capturer`)
            .setImage(Pokemon.Gifs[FinalRand])
        randompop.send(embedpoke).then(anothermessage => {
            anothermessage.react('💸');

            const filter = (reaction, user) => {
                return ['💸'].includes(reaction.emoji.name) && user.id != ("471749111125770250");
            };

            anothermessage.awaitReactions(filter, { max: 1, time: 180000, errors: ['time'] })
                .then(collected => {
                    const reaction = collected.first();

                    if (reaction.emoji.name === '💸') {
                        if (!Dresseurs[user.id]) return anothermessage.channel.send("Erreur :Croix: : `Vous devez être un Dresseur pour effectuer cette commande : ?start`")
                        Dresseurs[user.id].Sac.push(Pokemon.Noms[FinalRand])
                        Dresseurs[user.id].NbPokemons += 1
                        Dresseurs[user.id].Points += pokep
                        anothermessage.delete().catch(error => message.channel.send(`Erreur : ${error}`));
                    }
                })
        })
    }, 10000);```
#

The user who have click on the reaction is user no ? My error is user is not defineds

#

I want get the user who put reaction

mossy vine
#

well obviously, there is no user in the scope

lofty hamlet
#

So ho i can get the user who put the reaction ?

mossy vine
#
Returns: Promise<Collection<string, MessageReaction>>
lofty hamlet
#

🤔

#

What ?

mossy vine
#

collected will be a Collecting of strings and MessageReaction objects

lofty hamlet
#

What i replace for user.id

mossy vine
lofty hamlet
#

🤔

#

You can send what I need to do and explain ?

mossy vine
#

no

lofty hamlet
#

I don't understand what you want i do

#

So explain me ?

#

It's been 1 hour that I do not arrive trying solutions

mossy vine
#

<MessageReaction>.users is what you need, but keep in mind that it returns Collection<Snowflake, User>

lofty hamlet
#

What 🤔

mossy vine
#

i have no idea how youre handling your Dresseurs object, so just refer to the docs

lofty hamlet
#

I want to get the ID user who add the reaction

#

I think you did not understand what I want: /

mossy vine
#

exactly

lofty hamlet
#

Exactly what ?

mossy vine
#

i never used awaitReactions, i use a completely different approach that fits my needs

lofty hamlet
#

Oh opk

#

Ok*

#

And you do not have an idea how I can get the id of the user who added the reaction with my system?

mossy vine
#

if <MessageReaction>.users contains idimlookingfor

lofty hamlet
#

It's been 1 hour that I do not find solutions

wide ruin
#

not a bot but html

#

and then have text inside the div

mossy vine
#
.mydiv {
    background-image: url('https://cdn.discordapp.com/...');
}
#

<div class="mydiv">
    <p>Yeet</p>
</div>```
wide ruin
#

no image appears

mossy vine
#

are you sure the attachment is valid

wide ruin
#

right click > copy link

mossy vine
#

can you give me that link so i can test it?

#

its working fine for me

lofty hamlet
#

reaction.user.id

#
  '471749111125770250' => ClientUser {
    id: '471749111125770250',
    username: 'Akimitsu',
    discriminator: '0507',
    avatar: 'd5a7a839f8fbd697c5428c684d08a394',
    bot: true,
    lastMessageID: '578251945505062912',
    lastMessage: Message {
      channel: [TextChannel],
      id: '578251945505062912',
      type: 'DEFAULT',
      content: '',
      author: [Circular],
      member: [GuildMember],
      pinned: false,
      tts: false,
      nonce: null,
      system: false,
      embeds: [Array],
      attachments: Collection [Map] {},
      createdTimestamp: 1557936407210,
      editedTimestamp: NaN,
      reactions: [Collection],
      mentions: [MessageMentions],
      webhookID: null,
      hit: null,
      _edits: [Array]
    },
    verified: true,
    email: null,
    localPresence: {},
    _typing: Map {},
    friends: Collection [Map] {},
    blocked: Collection [Map] {},
    notes: Collection [Map] {},
    premium: null,
    mfaEnabled: false,
    mobile: null,
    settings: ClientUserSettings { user: [Circular] },
    guildSettings: Collection [Map] {}
  },
  '403159739178942464' => User {
    id: '403159739178942464',
    username: 'Nebulus',
    discriminator: '1859',
    avatar: '78bfb86ebdd87928c9a3b99aa4bfb17e',
    bot: false,
    lastMessageID: null,
    lastMessage: null
  }
}
mossy vine
#

yep

#

thats supposed to happen

lofty hamlet
#

How i can take the id of the user

earnest phoenix
#

@lofty hamlet bah

lofty hamlet
earnest phoenix
#

well yes

lofty hamlet
#

?

earnest phoenix
#

use your brain, its a collection of users

lofty hamlet
#

How can I get the id of the second user so me? @earnest phoenix

lofty hamlet
#

How i can get a object to a collection ?

toxic hedge
#

Hi, my bot has commands to subscribe/unsubscribe a channel to games to see whenever a mod is added or edited. At the moment, the commands need manage_channel permission to manage the subs for a guild channel.

now i want to let normal users receive updates via DMs if they want. What would be the best approach if they use the commands in a guild channel?

  1. Responds with a message that they can only subscribe via DMs because of insufficient rights.
  2. Responds with a DM that they can only subscribe via DMs and should resend the command if they really want to subscribe.
  3. Responds with a DM that they are now subscribed to the game and will receive updates via DMs.
earnest phoenix
#

2

copper cradle
#

@lofty hamlet how do u get an object from a json file :^)

lofty hamlet
#

Lmao

idle basalt
#

and in 3 include the unsub command as well

sonic pivot
#

discord.js, best way to do % uptime?

grizzled spruce
#

Lemme get code

earnest phoenix
#

track the bots connection state ever x seconds or minutes then store it in a database, you can then use the basic percentage formula

unique nimbus
#

yes

grizzled spruce
#

const duration = moment.duration(bot.uptime).format(" D [days], H [hrs], m [mins], s [secs]");

earnest phoenix
#

thats uptime,not the percentage of total

grizzled spruce
#

well what they showed had both ¯_(ツ)_/¯

earnest phoenix
#

they stated percentage in their message

grizzled spruce
#

oof

#

IQ level Retard

wide ruin
#
{
  "home": [
    {
      "background": "https://cdn.discordapp.com/attachments/image...",
      "title": "Game name",
      "description": "game desc here."
    }
  ]
}```
```js
const images = [];
var json;
async function getJSON() {
  json = await (await fetch("data.json")).json();
}
var fetchpromise = getJSON();
fetchpromise.then(function() {
  for(var home of json.home) {
    var divTag = document.createElement("div");
    divTag.style = `width: 40vw;height:20vw;float: left;background-size:100%;border-radius: 1vw;padding: 25px;margin: 25px;background-image: url('${home.bakground}')`
    var title = document.createElement("h1");
    title.textContent = home.title;
    var image = new Image();
    image.src = home.background[0];
    divTag.appendChild("<br><br>")
    divTag.appendChild(title);
    divTag.appendChild(home.description);
    divTag.appendChild("<br><br><br><br><br><br><br><br>")
    images.push(divTag);
  }
});
async function onLoad() {
  await fetchpromise;
  var element = document.getElementById("div");
  for(var image of images) element.appendChild(image);
}```
but it doesnt load anything
```html
<body onload="onLoad();"> ```
#

it should

  • load html document
  • run js
  • add thing from json
mossy vine
#

can you try fetch("/data.json")

#

just in a console

late hill
#

"<br><br><br><br><br><br><br><br>"

wide ruin
#

how is it meant to be done?

#

@mossy vine

mossy vine
#

in the chrome/firefox terminal

#

on the website

copper cradle
#

:^)

wide ruin
#

@mossy vine promise pending

mossy vine
#

await it

wide ruin
#

no idea which bit to open

#

Response { type: "basic", url: "https://......glitch.me/data.json", redirected: false, status: 200, ok: true, statusText: "OK", headers: Headers, body: ReadableStream, bodyUsed: false }