#development
1 messages · Page 616 of 1
Other languages in #memes-and-media
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
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
I want Help
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
wdym reposting
Im RUnNiNg on FumEs hErE
Join the club man
i want help @dusky marsh @grizzled spruce @fiery stream @dusky marsh
What
<@&304313580025544704> this guy ^
he's pretty cool
Don't ping all mods
It's not necessary, you can just ping one mod but it's justified
Yeah, my bad, Ill keep it in mind
" 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
did you define "AuthorID"
Yup
AuthorID = ' 577694547124027402 '
why so many spaces
I think it don't matter
it does
messages.author.id?
What
message.author.id?
Messages work
is that your id
But let me try
414622975598395398 is your id when i copy it
Done
577697903565602816 is my id when I copy
Let me try with that id
Yup it worked
Your id is right
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)
yo need to add a
.toLowerCase()
bc you can't have capital letters in usernames
channel names*
@copper cradle Yes, I did that... still didn't work.
not to sound dumb
but does that channel exist
replace space with -
.replace(/ /g,'-')
Guild.members.foeach is allowed?
Foeach give role to everyone
yeah
Is it allowed
As it's a type of spam
We can role 4 member at a time
How
delete every channel
Lol
it's actually pretty easy
How can I role everyone
message.guild.members.forEach(member => member.addRole('you role's id here'))
I think it was something like that
Lets try
did it work?
@shy rose Thanks so much! It worked!! ❤
unu
Wait
nice
lol
it may leave some members without the role
just run it again to be sure
Ok
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
@earnest phoenix you are using res outside of the scope
message.guild.members.foreach(u => {
u.addrole(roleID)
})
break;```
Not working no console err
But bot goes off
addrole isnt a function, is it?
it should be addRole
Also that seems to be adding a role for all members
Thats API abuse
Ok
Discord probably doesn't see it as API abuse cuz Dyno does it
Doesn't Dyno have a delay between each member
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
there is no official api afaik
That is truly a tragic tale
i know it's not the official api but i would like to use it but i don't know how
@dry oracle https://ow-api.com/docs/
yes it's the api but i read the docs but i don't know how create my command with this 
(I'm starting in javascript)
if you don't know how to do http requests I suggest googling that for your language
Excellent, now you've found yourself upon a great learning opportunity.
I'm in js
Ok man, thank you
I already create a little piece of code but he say "battletag not found"
You want my code ?
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
dondish#2546 ?
pc
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 ^^
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
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
message.guild.members.forEach(u => {
u.addRole(roleID)
})
break;```
This command only role member is online how can I role everyone
@quartz kindle So my URl is good ?
@pallid zinc it should role everyone
It probably only contains cached members
anyone knows how can I access my bot client object (it is in a JS file) in a html file (for <script>)???
can you add System.out.println(YN); before the if statement, to make sure its the problem or not?
ok
@vague chasm im 90% sure you cant
what if I use template engine?
so they can eval your token if you do that
second thats dumb
third thats not possible
what
you can use a db
how would they eval my token
and link your bot
because html is public
you sent your entire bot object to the file
console on chrome?
ye
if your client is there, then they can eval your token
but can I use .require on html script to .require my db for client?
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
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?
do you have a webserver already?
you can make an enmap based webdashboard but that will not mean you dont need to make a rest api
should i do the headers: { token: "myPersonalMadeCode" } thing ?
no
can I do it without separating
You can but why would you?
do you have the webserver and the bot in different files?
because you can just add it to the webserver file then
first of all.. my bot creates the webserver by http.createServer()
its not recommended to host a webserver along side with your bot
why?
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?
wait for your turn
ive never used java, so no clue
so your guidelines to webdash
- make a separate webserver
- secure it
- make it sync to your bot
,
you dont need to buy another vps
it depends
@mossy vine then?
you can run 2 js files on the same vps
you make 2 program run on your vps
who says you need a new vps
I host 3 webservers on my server
pm2
pm2
pm2
pm2
@abstract quarry
your code does not work because ||it does not work||
@abstract quarry as for you what you want to do
read the code
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
You can't compare strings with ==
how can I?
lemme check something
and people say js is weird..
yep that would work
in Java if (command == null) return;
you even need to do that just to check
thank you @hushed berry
no shortcuts lmao
how would i create a role in djs?
Preferably by reading the docs
is there any way to make it so i can run a js file just with myjsfile in a linux terminal?
@pallid zinc
let lmfao = await eval(args.slice(0).join(' '))
return message.channel.send(lmfao)
that would be an eval command
Ayyy i have question is it better to hosting webpage for the bot with it or separately?
hello all anybody that could maby help me with my poll command please as im getting an error .map is not a function 😦
well because its not a function on the data type youre dealing with
https://hasteb.in/ulebikuw.js @fiery stream
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)
}
}```
@slate kayak why are u even mapping
Yup
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
Wait what
http://prntscr.com/nog2po example @fiery stream
the question part when into the answer part and that part i couldnt fixed 😦
Whats the err
there were none untill now http://prntscr.com/nog3pf @pallid zinc
Im getting confused by your code
@slate kayak it seems you aren't sure what you split with
Why do u have thumbs up and down thingy if u got the who alphabet letters there
Why??
huh?
@slate kayak check line no. 62
@slate kayak who did u say this to good question 😦 not sure 😭??
message.channel.send('**Poll 🗳 |** Polls are limited to \`20\` options.');
It's like this
@fiery stream for you sorry im trying to fix that part now i was doing it when i didnt sleep much 😦
Before your start from **poll and end at \
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
@slate kayak does it work
@late hill help
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
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
How do they set the welcome channel
A!set edit WelcomeChannel (name)
You could search for the channel when they use that command
using the .find() method you used above
Then store the id
Is there a major deference doing thar
No
So im too lazy to do that
🤷
I already built a great ai in it i dont have time to do it
Coding wise it would take like 10s
Might just be annoying if you already have data saved from some guilds
to do the transfer
Prob but nah
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
😂
@lofty hamlet What is the problem?
@late hill
if this was dbl bingo i would have 2 spaces right now
!== "true"
what
why don't just use = false
actually, why tf are you using true as a string
Does the welcomeChannel actually exist @fiery stream
Thats why i have check function
@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 ?
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
Yes embed existing
@fiery stream you could do guild.systemChannel.send('your text')
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...
just sending a get request to that link doesnt return what youre looking for i dont think
Nano did you defined superagent
its literally defined on the top of the code snippet he sent
console.log body and see what it looks like
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.
@grizzled spruce bruh, you're not using the endpoint of the api
http://version1.api.memegenerator.net/ this is the link
if you open it it opens a normal page
Oh
fails at life
oof
Anyone know a good api for memes?
I had one lemme find the link
Kk thx
Well it’s the best I got for now lol
Ooof I just discovered that
Anyone?
Dank Member has one
Plz help
It's limited on it's endpoints but has things like Trump tweets etc
Unlike DBL, it has can be parsed
the body is permalink
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'
if i put
permissions = !SEND_MESSAGES
for editing a role would it turn send messages off?
for js
how would i make it so it doenst have that permission
oh im a brick
nvm
Do you know mee6 level spec?
Like 300x900?
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
Can't you just change the server permissions for that role then
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
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
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?
@late hill i mean i do have channel
How i can make an .replace for an array ?
did you check settings.welcomeChannel
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)
someone hasnt heard of switch statements
But its still puts me that skytext is not defined
@mossy vine you talking about me?
yes
sry
I was wrong
switch(temps) {
case "Cloudy":
text = "Nuageux";
break;
}
@mossy vine
Sorry for the ping
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
does anyone know how to do tts and speech recognition using discord.js?
ping me if you do 🍉
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"```
Why does they say cant send of null
Didn't find the channel
^
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
Hey guys does anyone know how to do tts and speech recognition for discord.js please ping me!
Guides from {TheSourceCode} on YouTube are very straightforward and simple
For discord.js
It helps to know some JavaScript already tho
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
ooba
Can i send text to google cloud and stream the audio in a voice channel
iirc yes. google cloud has a tts api
Is there any tutorials on how to do this
not really, however you can figure it out by reading google's docs
Nice
iirc google cloud's tts api takes input text and outputs a json which contains the base64 version of the mp3 file
it also costs
for anything over 10 or 30 seconds you need a paid acnt
does the api still reveal the user's current voice activity even if they can't see the voice channel?
clarify
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
Why cant it just be free?```
because you're using the technology someone else made and using their computing power
me no grammar in night times
me no grammar 24/7 cuz it’s overrated
fair enough
😁
The free limits are kinda tiny
They are meant to demo the product, not for full scale use
I need a good random gif api for a hug command. Anyone know one?
(Preferably anime themed)
Just use a regular gif api like giphy and search for hug gifs
Why
Discord bots in a nutshell
How many third party APIs can I cram into one bot
Why would u hate authorization lmao
I have issues with the ones the require auth
Like...?
That sounds like user error there
^
😦
What errors do u have? Maybe we can help
yeah
Then what shows up?
They just don’t load
what response code do you get
I only get my preassigned text
"They just don't load" can mean a sfdsjhbbjillion things
I don’t get one
You always get a result
Nope
That's not how an API works
every request has a response code, no matter what
You always get a result... timeouts are rare
¯_(ツ)_/¯
If you show us a specific example we can show u what to do
lmfao
@opaque eagle
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
man that's a lot of threads
And very not healthy for the system
not to mention idek if that's possible
then how do I keep values from one guild to be changed by another one? Since all guilds use the same code
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
Use a dictionary, or however it's called in js
JSON
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
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.
I really can't think of anything what can an npm provide you that would be easier than a dictionary
A var per guild eh?
@past portal you mentioned this is your first time using js. Learn the language first :p
Wait
Nvm
I read wrong oof
The gifs aren’t displaying
"api key"
?
your api key is there
Oh it’s my giphy so idc
^
giphy has ratelimits
Which means.....?
someone can mess with you and block your key
.
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...?
tag must have no space
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?
nano u know that like every bot with an anime profile has this command right....
it wont be that original.. tho
Kk ty
Idc
he just want a hug command
ok
ooof
well I have a question
cant figure out whats wrong https://hasteb.in/libebaqe.js
discord.js
Im trying to loop a string that turns into an array through a random capitalizer
and posting it
show ss
ss?
screenshot of what ahppens
try to put let capOrNot = Math.floor(Math.random() * 2);
inside the loop
how about instead of using math.random use true or false
something like this but I think you want individual letter right?
here @empty owl
deleted it already
just save that photo
message.channel.send('**Random Cap**\n\n' + args.join(' ').split('')map(l => (Math.random() < 0.5) ? l.toLowerCase() : l.toUpperCase())).join(''));
yes
@buoyant wagon do u know how can i do bold in .setFooter(`The command \*${args[0]}\* has been reloaded`);
that
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
.
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
aha
Do you want me to send my bots one as an example?
sure why not!
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!
huum ping
well buddy
Well...?
aha
You dont need to introduce yourself
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
but man,idk why the puted that shity question
¯_(ツ)_/¯
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
I don’t know enough about your bot
it's About Moderation Actions & Basic Commands
Its your bot, your creation so why not you write it
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."
go type it in a text editor and watch how many characters it have
@opaque eagle I do not understand what you have given me
should i make it 300words excatly?
Who knows about weather command ?
characters minus space
minus?
meaning 300 characters but not including the spaces
You don’t have like word or word pad on ur computer?
nah ofc i've
Then use that
and then?
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
How in the hell.
How in the hell do I make my bot send any eval errors as a message response?
@pliant needle try catch
What, like channel.send(eval(args)).catch(error)?
Refer to the example code i sent above ig
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
Nope
my dear....
What now
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}});
}
}
});```
Director whats the err
errorcommands.send({embed: {"description": "❌ Error: \n" + Cmd err + "", "color": 0xff0000}});
}
Cmd err
like that
@earnest phoenix can you upload that to a pastebin and paste the full error here ?
ok
With err
error?
What do u mean?
what error does it give
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
@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
process.on('uncaughtException', function (err) {
client.channels.get("572482863702999051").send(`ERROR: ` + err);
})```
**TypeError: Cannot read property 'send' of undefined**
use webhooks for easier cross shard sending
provide*
oou so just but in a webhooks
ooh thanks
let me try that out
Can u example this to me...
('webhook id', 'webhook token')
id is the numbers in the webhook link,
token is the random characters after the numbers
it worked thanks
but it posts 2 times...
ahh nvm
its because of the console
thanks!
Mathjs
Yup it's mathjs
Can I add commands with eval?
Regular eval or math.eval?
Regular eval
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 ;
```
how does that even compile
^
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
That's just new level of ugliness
^
🤷
Lmao
? @fiery stream
Nothing
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
:/
@earnest phoenix yes?
Keep making mistake
I always put 140 more characteristics wrong
When I put more than 140 of the error
I dont understand wdym
Just read 
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 
there's a difference
maximum 140 for the short description
minimum 300 for the long description
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
@bitter sundial pls help my programming language is english
Is there a way, too store something in txt (JavaScript )

Nobody can help^me ?
@earnest phoenix just post your question
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
on the discordapp website
you are logged into your alt on the web platform, which is what discordbots.org redirects you to
^
also, reading #502193464054644737 might be a good idea
@mossy vine you can help me now ? ^^
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"
}
Nobody find solution for me become my hero
what am I doing wrong ^^^
@grizzled spruce uh
oh boy 2 code dumps to deal with
Do you have a error in the console?
no error
c but longer
sadly
@grizzled spruce is the message not sending?
the message is sending but the gif isnt
wait nvm im blind
@grizzled spruce test to console.log(neko.url) for show if he return a valid url
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
ooof neko.url doesnt exist apparently
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
^
:-0
You are 2 fast 4 me
i am a dumb coder
yes tyvm
@mossy vine do you know if i can put a canvas in a embed?
also can you pls resend that code so i dont have to scroll so much
@earnest phoenix i never used canvas, sorry
Okay np
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
But user.id does not work
well obviously, there is no user in the scope
So ho i can get the user who put the reaction ?
Returns: Promise<Collection<string, MessageReaction>>
collected will be a Collecting of strings and MessageReaction objects
What i replace for user.id
no
I don't understand what you want i do
So explain me ?
It's been 1 hour that I do not arrive trying solutions
<MessageReaction>.users is what you need, but keep in mind that it returns Collection<Snowflake, User>
What 🤔
i have no idea how youre handling your Dresseurs object, so just refer to the docs
I want to get the ID user who add the reaction
I think you did not understand what I want: /
exactly
Exactly what ?
i never used awaitReactions, i use a completely different approach that fits my needs
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?
if <MessageReaction>.users contains idimlookingfor
It's been 1 hour that I do not find solutions
not a bot but html
i have a <div> and it needs a background image of https://cdn.discordapp.com/attachments/.....
and then have text inside the div
.mydiv {
background-image: url('https://cdn.discordapp.com/...');
}
<div class="mydiv">
<p>Yeet</p>
</div>```
no image appears
right click > copy link
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
}
}
I have replace user.id by reaction.user.id
How i can take the id of the user
@lofty hamlet bah
reaction.users.id = undefined
well yes
?
use your brain, its a collection of users
How can I get the id of the second user so me? @earnest phoenix
How i can get a object to a collection ?
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?
- Responds with a message that they can only subscribe via DMs because of insufficient rights.
- Responds with a DM that they can only subscribe via DMs and should resend the command if they really want to subscribe.
- Responds with a DM that they are now subscribed to the game and will receive updates via DMs.
2
@lofty hamlet how do u get an object from a json file :^)
Lmao
and in 3 include the unsub command as well
Lemme get code
track the bots connection state ever x seconds or minutes then store it in a database, you can then use the basic percentage formula
yes
const duration = moment.duration(bot.uptime).format(" D [days], H [hrs], m [mins], s [secs]");
thats uptime,not the percentage of total
well what they showed had both ¯_(ツ)_/¯
they stated percentage in their message
{
"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 promise pending
await it



