#development
1 messages · Page 442 of 1
which leads to the question, didn't you saw any error in the console
or a warning

do async functions return errors without catch? promises dont afaik
i've had my fair share of functions silently failing inside promises
it shall throw an unhandled promise rejection warning
drove me nuts trying to find them
unless you're listening to process unhandledRejection event and silently ignore it xD
im listening to it yes, but logging it
in theory then a promise should trigger it
unless you're explicitly catching the said promise as well
idk maybe my function structure is just bad
but like
im logging the rejection, i catching the promise and im using try catch blocks
and none return anything
until i find the problem my self and explicitly use a try catch block on it inside the function
then the error shows
if you can provide some sample I could possibly enlighten you further
oh wait, actually there was always one error
"cant send empty message"
xD
i still had to hunt exactly where the function failed that make it not return anything
i dont have any example at hand since i fixed all of them already
my worst experience was when some files needed by an npm module got corrupted and node started throwing segfaults everywhere
@sick cloud you might need to .run() aswell
well i got it fixed, run isn't affecting it
turns out it was my accidental use of msg.guild a lot lol
So I'm making my web dashboard. How do I do this? If someone clicks on /server/<id>, if the bot isn't there, it'll redirect to add the bot, if it is there, it'll show the page
look up some node express tutorials
I was told to come here to find help for development for a bot I have in mind
if you are facing a problem or looking for some guidance sure go ahead
@earnest phoenix someone to guide me ahead
are you new to programming?
Yes
have you used any programming language before?
well this is a more programming oriented channel unless you want to use that visual bot creator from steam lol, now if you are up to learn some programming you can pick up a relatively easy language (like javascript or python), start reading tutorials and stuff
you need to understand at least the basic concepts of programming and the basics of the language you'll be working with before diving into making a bot
otherwise you're going to have a nightmarish experience
@earnest phoenix can you help me
figured i can just check my database @earnest phoenix, which works since each guild has a record
@outer niche google
@sick cloud I don't know what I'm doing that's why I came here for help I've been trying for 2 months
oh I didn't realize you were literally asking how to check if the bot exists, thought more of how to make the dashboard xD
@earnest phoenix I don't have a computer with me currently it's only my phone that is also why I'm asking for help. I've also been trying for 2 months and I still can't figure out even on a computer
you can start with those for JavaScript, if you want a different language I don't have handy resources atm:
CodeCademy online course: https://www.codecademy.com/learn/javascript
Eloquent Javascript, free book: http://eloquentjavascript.net/
MDN's JavaScript guide: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Introduction
@earnest phoenix this isn't very helpful what I actually needed was someone to help me make it but I guess I'll go somewhere else to find someone
I don't think anyone will make a bot for you unless you pay them ;p
@sick cloud would you like to help me then
throw me a dm and i'll see what i can do
afaik people who do commissions usually charge like 20 bucks
Umm, how do you redirect to a URL when you successfully auth a bot?
oauth?
Yeah, I tried redirect_url but that didn't work
you need to add the exact url to the application page
and use that exact url for the token exchange
after that you could just send a 3xx redirect
i don't need any token exchange
and its added
i just want it so when the user adds the bot through the invite link, it redirects to the bots homepage/website
you do tho?
oh
i mean
why not open the bot invite in a new tab then?
and redirect them
on click
um
going through the oauth flow just to redirect users is overkill
this is how i do it
router.get('/server/:id', async (req, res) => {
const id = req.params.id;
if (!id) return res.redirect('/servers');
const server = await r.table('servers').get(id);
if (!server) {
return res.redirect('https://discordapp.com/oauth2/authorize/?permissions=0&guild_id='+id+'&scope=bot&client_id=463516407234297866&redirect_url='+encodeURIComponent('http://url/servers'));
} else {
res.render('server', { user: req.user, guild: { name: 'hello world', id: id } });
}
});
so if theres no server present it'll redirect to add the bot to the server, then when its added i wanted to redirect back to the servers page
for a dashboard you'd want to authenticate users tho
so random people don't make changes
also for redirecting them
you'd need to enable oauth code grant
which means all users adding your bot will need that url
with the redirect
just do a 404 on missing server
and leave a button "invite bot"
or that
one last question, how do you get a guilds data from the api?
i tried making a get request to discordapp.com/api/guild/id or something
but it didn't work
i use oauth2
i get the user's access token
then GET /api/guilds/@me
and do requests to the bot to filter which ones they have permission to modify
await snekfetch.get("https://discordapp.com/api/guilds/@me").set("Authorization", `${token_type} ${access_token}`)```
iirc
token type and access token are in the oauth2 response
you'll need the guilds scope for that
https://discordapp.com/developers/docs/topics/oauth2 this might help
i use passport-discord
and it handles all that
router.get('/api/login', passport.authenticate('discord', { scope: ['identify', 'guilds'] }), async (req, res) => {});
router.get('/api/callback', passport.authenticate('discord', { failureRedirect: '/' }), async (req, res) => { res.redirect('/'); });
router.get('/api/logout', checkAuth, async (req, res) => { req.logout(); res.redirect('/'); });
there should be a way of getting the token_type and access_token from it
you just need those two to make the request
alright
i'll see if i can get them
is this it?
passport.use(new DiscordStrategy({
clientID: 'id',
clientSecret: 'secret',
callbackURL: 'callbackURL'
},
function(accessToken, refreshToken, profile, cb) {
// ...
accessToken and such
https://hastebin.com/mebanurime.js I have some problem with my fortnite command
https://hastebin.com/anuvewesan.js here is my superagent edition (request above ^^)
hmmm?
const embed = new Discord.RichEmbed()
.setTitle(`**Fortnite Stats:** ${playerName}`)
.addField("Solo", `**Wins:** \`${stats.br.stats.pc.solo.wins}\`\n**Kills:** \`${stats.br.stats.pc.solo.wins}\`\n**Deaths:** \`${stats.br.stats.pc.solo.deaths}\`\n**Matches Played:** \`${stats.br.stats.pc.solo.matchesPlayed}\`\n**Win Rate:** \`${stats.br.stats.pc.solo.winrate}%\``)
.addField("Due", `**Wins:** \`${stats.br.stats.pc.due.wins}\`\n**Kills:** \`${stats.br.stats.pc.due.wins}\`\n**Deaths:** \`${stats.br.stats.pc.due.deaths}\`\n**Matches Played:** \`${stats.br.stats.pc.due.matchesPlayed}\`\n**Win Rate:** \`${stats.br.stats.pc.due.winrate}%\``)
.addField("squad", `**Wins:** \`${stats.br.stats.pc.squad.wins}\`\n**Kills:** \`${stats.br.stats.pc.squad.wins}\`\n**Deaths:** \`${stats.br.stats.pc.squad.deaths}\`\n**Matches Played:** \`${stats.br.stats.pc.squad.matchesPlayed}\`\n**Win Rate:** \`${stats.br.stats.pc.squad.winrate}%\``)
msg.channel.send({embed});
seems fine
@earnest phoenix
wait im blind i thought i saw a typo 👀
nvm lol
log errors ur not logging it rn so no wonder u dont get them in console
@upper ember
console log stats and see the body
because that might be causing the error
hmmm
I tried with other lib
this is the error [2018-07-05 10:51:25]: ERROR Unhandled rejection: TypeError: Cannot read property 'user' of undefined
const { RichEmbed } = require("discord.js");
const Discord = require("discord.js")
const Client = require('fortnite');
const fortnite = new Client('token');
exports.run = async (client, msg, args, level) => {
var playerName = args[0];
fortnite.user(playerName, 'pc').then(r => {
msg.channel.send(r.body.user.username);
})
}
this is the code
why are you requiring discord.js twice
There's a difference between { Thing } and just requring something
yes
But @upper ember you do not have to require richembed
just do ```js
let embed = new Discord.RichEmbed()
ok
const Client = require('fortnite');
const fortnite = new Client("4e5d99-f09cb1d833c1");
const Discord = require('discord.js');
exports.run = async (client, msg, args, level) => {
if (!args[0]) return msg.channel.send('**Please Include the username**\n`j!fortnite username`');
var playerName = args[0];
fortnite.user(playerName, 'pc').then(data => {
let embed = new Discord.RichEmbed()
.setTitle(`Stats for ${data.username}`)
.setDescription(`**Top Placement**\n\n**Top 3s:** *${data.lifetimeStats[0].value}*\n**Top 5s:** *${data.lifetimeStats[1].value}*\n**Top 6s:** *${data.lifetimeStats[3].value}*\n**Top 12s:** *${data.lifetimeStats[4].value}*\n**Top 25s:** *${data.lifetimeStats[5].value}*`, true)
.addField('Total Score', data.lifetimeStats[6].value, true)
.addField('Matches Played', data.lifetimeStats[7].value, true)
.addField('Wins', data.lifetimeStats[8].value, true)
.addField('Win Percentage', data.lifetimeStats[9].value, true)
.addField('Kills', data.lifetimeStats[10].value, true)
.addField('K/D Ratio', data.lifetimeStats[11].value, true)
.addField('Kills Per Minute', data.lifetimeStats[12].value, true)
.addField('Time Played', data.lifetimeStats[13].value, true)
.addField('Average Survival Time', data.lifetimeStats[14].value, true)
msg.channel.send(embed)
})
}
``` it returns `[2018-07-05 11:20:19]: ERROR Unhandled rejection: TypeError: Cannot read property '0' of undefined`
which line ??
no idea
probs .setDescription(Top Placement\n\nTop 3s: ${data.lifetimeStats[0].value}\nTop 5s: `
get yourself a better error logger
hmm
it's a json object, not an array
simply do console.log(error) and it should give you lines as well
is that your token LOL
I decided to use something from google, this is problem with the bot
I think you're just doing it wrong, we have a fortnite command like that and it certainly doesn't respond with an array
lifetimeStats[number] is the issue.
https://sourcecode.plexidev.org/view?key=1634924634457194
https://www.youtube.com/watch?v=QqB65WWdJWY
Interested in free source code, bot ideas, or want to share your projects/commands? Check out https://sourcecode.glitch.me/ ==== [ Source Code ] ==== https:/...
something from google isnt an issue, its preety much that either args or data.lifetimeStats doesnt exists at all
args is exist
That video is outdated
It's from feb
Fortnite's api surely has changed since then
because I did fortnite.user(playerName, 'pc').then(console.log) and it worked
I never found them...
well I would suggest you do console.log(data) before making the embed and show the response if possible
wrapper is not the problem, there is something wrong with your code
That module is a wrapper for an api, you can take a look at the API docs and see example responses
i think
anyway, our code uses (for example) lifetimeStats.timePlayed, that should serve as a base as to how to go about it. Use something like that instead of your current setup of lifetimeStats[number].value because that's not correct anymore
Yeah, lifetimeStats[number] is the issue.
so where is lifetimeStats? 😂
yes.
whats below the stats object ??
and data.solo.kills ?
i.e. get screenshot below it
lifetimeStats is part of the api
yeah that's correct
I'm using the fortnite api aswell, it's there
can you show me how you did it? @jagged plume
I need to see more of the API response if you are fine with it @upper ember
cant help without that
I'm using a slightly different lib to you
there is no lifetimeStats in the response you sent 😕
you might be looking for this. https://hamilton.is-serious.business/072f8d.png
lifetime instead of lifetimeStats
its rather data.stats.lifetime[]
yeah
wait data.solo.kills will do fine?
like I said earlier lifetimeStats didnt exist
data.stats.solo.kills
^
ok
it working
there's deaths on this api?
because I can't find and it sounds like a basic thing
@jagged plume
not sure, try googling it. not sure if they track deaths or not
alright
Any idea to accept an invitation for a discord server, when the AccountType is a user and not a bot ? 🤔 I'm using JDA
User Bots are forbidden
you shouldn't use them
wait did JDA not deprecated the User AccountType

gays
sorry i ment guys
guys ppls say that discord bot can't speak in more than 1 channel
buys there's a bots do that
even bots are still limited to 1 voice channel per server
can multiple shards be on one server?
just wondering 
also ik seems like a stupid question
a server is allocated a single shard
ok
I think it's server_id >> 22 / shardcount
To calculate which shard the events of that server will be send to
And DM's are always shard 0
When making new shards for the first time on your bot, do any existing servers get a random shard or are they not affected
And yes, your bot can connect to 1 voice channel per server
And need to be re invites to get one
They don't need to re-invite your bot
The formula for calculating which shard will handle that server's events is server_id >> 22 /shardcount
Ok
To answer more simply, it's not that it's just an numerical order low to high and every 2500 it switches over
For all intents and purposes you can say its "random"
Yes but it doesn't really matter that much since shards can operate indepently of each other
Besides shard 0 does DMs is there a difference or reason why a server would get a specific shard
No, it doesn't really matter which shard a server gets
Ok
Unless for example, you want to DM a member from a server and listen for their response
Ok
You can do this with js broadcasteval or discord.py internal sharding, latter which I use
I use .net
Hmm, you would need to see the docs about that lang since I don't know anything about .net
I’ve been reading then
But unless your bot relies on receiving DM's it's not a big issue
My bot doesn’t DM anything
You can run shard 0,1,2 in one process and 3,4,5 in another
or even on a different server if you wish
K
I see this conversation is about shards so far, so might as well ask
if a server from, lets say, shard 4 does a command that must be dmed to the user (shard 0), will it continue the same process in dms even tho those are different shards now?
Well, DM's are just HTTP requests
So you can send a DM with http
But the DM's that get received back are in shard 0
How to get the deleted message content..?
@earnest phoenix what lib
JDA
(Java)
im not sure for JDA
oh ok
most likely a message delete event listener
JDA has message delete event listener, but cant get content
only message id
discord doesn't provide the content for deleted messages
you'll need to cache them yourself
ok i know
thanks
ah
d.js has a message cache
mb
https://gist.github.com/Almighty-Alpaca/32629893e9cd305f1165652c80726b41
I found good thing
it won't work
why?
MessageImpl.class.getDeclaredField("reactions")
ik
JDA - Java wrapper for the popular chat & VOIP service: Discord https://discordapp.com
there's no MessageImpl class anymore
wait does JDA not provide the message object if cached on that event? 👀
Hue
JDA doesn't cache messages
and there is no option to enable caching? 👀
no
oof
I mean it is not hard to make your own implementation of it
sure thats what you can always do
JDA provides almost nothing that doesn't have a direct equivalent in the discord api
Yup
there are many third party projects tho
eg jda-utils
but implementing a message cache yourself can be done in 50 lines
or even less
¯_(ツ)_/¯
Yeah
not sure
it does commands, menus, event waiters
but a message cache can be just https://hastebin.com/zexuqovowa.java
How do you make a custom server prefix command?
You would need to save it into a database
Per guild
And make a command that makes you change it
It's funny because I'm working on it too 😛
Oh.
What video is the best to use?
The Source Code, Plexi Development, or Evies Code?
Evie.Codes*
Idk 1. I learned it my self 2. I would suggest Evie.Code cause she's probably one of the best discord.js developers I know
const args = message.content.split(" ").slice(1);
if (message.content.startsWith(config.prefix + "eval")) {
if(message.author.id !== config.ownerID) return;
try {
const code = args.join(" ");
let evaled = eval(code);
if (typeof evaled !== "string")
evaled = require("util").inspect(evaled);
message.channel.send(clean(evaled), {code:"xl"});
} catch (err) {
message.channel.send(`\`ERROR\` \`\`\`xl\n${clean(err)}\n\`\`\``);
}
}
});```
Is this good for eval command?
yes
Ok.
I mean it is copied but yeah
Ik
copied commands 
const args = message.content.split(" ").slice(1);
if (message.content.startsWith(config.prefix + "eval")) {
if(message.author.id !== config.ownerID) return;
try {
const code = args.join(" ");
let evaled = eval(code);
if (typeof evaled !== "string")
evaled = require("util").inspect(evaled);
message.channel.send(clean(evaled), {code:"xl"});
} catch (err) {
message.channel.send(`\`ERROR\` \`\`\`xl\n${clean(err)}\n\`\`\``);
}
}
});```
What do I need to edit?
Nothing I guess if it works ¯_(ツ)_/¯
How do I make it so if no one is tagged it returns with a message.
let aTaged = msg.mentions.users.first();
msg.channel.send(`${aTaged.displayAvatarURL}`);
}
module.exports.help = {
name: "Avatar"
}
What do I add.
Im not doing eval anymore.
?
Ok
I see that you are trying to run your bot
Do you have the files on your computer?
Nvm
Could you post a picture/snippet of your code?
R.I.P token
Ok you may want to watch a tutorial on YouTube
I saw it from this site
For this, just change untitled.txt to untitled.js
I recommend you deleting the screenshot and resetting your token
https://anidiotsguide_old.gitbooks.io/discord-js-bot-guide/content/getting-started/the-long-version.html
Sorry I ma on gogle crome
And if you have installed npm and node you can run it using node untitled
https://youtu.be/Z-tc91hArlM
🎥 Discord.js Bot Development - Project Setup - Episode 1
Tune in every Wednesday & Friday for Discord.js Videos! Go easy on Ned as it's his first coding tutorial in a while! :D SourceCode: https://github.com/The-So...
Is node affilated with discord
This should go over setup
no
thank 4 token
No, node is a backend version of js
Why wont my command work!
Panther error please
Ima send my code.
let aTaged = msg.mentions.users.first();
msg.channel.send(`**<@${message.author.id}>, Heres the avatar for your mentioned user! :white_check_mark:** ${aTaged.displayAvatarURL}`);
if(!args[0]) return message.channel.send(`**<@${message.author.id}>, Please insert a mention! :white_check_mark:**`);
}
module.exports.help = {
name: "Avatar"
}
Error please
Ok
it isn't displayAvatarURL afaik
Can you help fix my code?
Done.
I told you how to check if there was a mention but you ignored that. Guess you could just use args but could cause errors
Heres should be here's -- if you care about grammar
Ik.
You need a user for avatarURL
The avatar command works
but if someone
hasnt put in
a
mention
it doesnt work
Hello, I'm currently using MySQL with Discord.js to store all the user and bot data. Would I benefit from switching to MongoDB or SQLite? If so, what would the benefits be and would there be any cons?
@restive silo There is no wiki for User AccountType with JDA. I'm making an application for my self account ^^ to join automatically a guild when i receive an invitation in private and to check to get some statistics
it all depends on how much data and what capabilities you'd like to have/store
sqlite for example will not require a background process
I want the ability to store data of up to 10k users
I'd stick with mysql or mongo
I guess both are fine
although mongo is designed for humongous data
so it might be a bit overkill
So if I'm already with MySQL I shouldn't bother with switching?
why do you want to switch?
I've seen many people use Mongo with Discord bots and none use MySQL
take a look at this
@restive silo
I already have an application running for 1 year and I'm not banned 🤔
why would anyone use MySQL these days
@rugged pond i could get you banned by reporting it

why wouldn't they
No 😂

postgres is like 5x faster and support NoSQL Types
it all depends on the application that you're building
anyway don't run bots on your account
I know many people who make this to filter advertisements in private messages like me
😂
you remember the bridge saying
if everyone jumps off a bridge
will you do it too?
I'd advise not to
they already stated otherwise
Thanks, Atlas
👍
.infods
Can someone help me with my avatar command? I've only fixed half of it.
Sure but we need more info
My code?
yes
Ok.
let aTaged = msg.mentions.users.first();
msg.channel.send(`**<@${msg.author.id}>, Heres the avatar for your mentioned user! :white_check_mark:** ${aTaged.displayAvatarURL}`);
if(!args[0]) return message.channel.send(`**<@${msg.author.id}>, Please insert a mention! :white_check_mark:**`);
}
module.exports.help = {
name: "Avatar"
}
or like your problem
The avatar bit works.
But if no one has mentioned a user and just done <avatar it doesnt do error message.
check if args[0] includes a mention?
How?
?
if(!args[0].includes msg.mentions.users.first(); return message.channel.send(`**<@${msg.author.id}>, Please insert a mention! :white_check_mark:**`);
?
🤦
args[0].includes(msg.mentions.users.first)
Thx
With includes you always need () and inside the () you need to put the thing you want to check
also you could do size instead of first
can you send code
the thing before displayAvatarURL is undefined
also don't ping johans
let aTaged = msg.mentions.users.first();
msg.channel.send(`**<@${msg.author.id}>, Heres the avatar for your mentioned user! :white_check_mark:** ${aTaged.displayAvatarURL}`);
args[0].includes(msg.mentions.users.first); return message.channel.send(`**<@${msg.author.id}>, Please insert a mention! :white_check_mark:**`);
}
module.exports.help = {
name: "Avatar"
}
ok maybe someone didn't mention anyone
if no mentions are present then first will be undefiened
why do you want an error though?
What do I do to make work?
No like
I want it to send an error message
if
someone didnt
mention
anyone
but its saying
Avatar thing is undefined
if (aTaged == null)?
Im confused on to make this work?
let aTaged = msg.mentions.users.first();
msg.channel.send(`**<@${msg.author.id}>, Heres the avatar for your mentioned user! :white_check_mark:** ${aTaged.displayAvatarURL}`);
args[0].includes(msg.mentions.users.first); return message.channel.send(`**<@${msg.author.id}>, Please insert a mention! :white_check_mark:**`);
}
module.exports.help = {
name: "Avatar"
}
It says displayAvatarURL is underfined
What do I do to make this work?
if (aTaged == null) {
// do whatever you want
}```?
Im confused?
it's basic JavaScript
Whas the full code for me to use to make this work?
I won't spoonfeed
@tribal hazel you're not dumb, you just have a limited knowledge of JavaScript.
Is there a doc somewhere where I can find python example on how to add a vote command ?
In the owner textbox How do i add multiple owners. I sepetate em with what? (tried space, commas) Coz i try something n it just says Invalid Format
Also idk if its the right place to ask
So bear with me and sorry in advance
Are you adding ids?
No idea
Omg thanks man. I tried comma but not comma and a space
np
@tribal hazel use user.displayAvatarURL
is there anything i can do to deal with ws connection errors in discord.js?
at Client.emit (events.js:116:17)
at WebSocketConnection.onError (/home/timotejroiko_gmail_com/astrobot/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:374:17)
at WebSocket.onError (/home/timotejroiko_gmail_com/astrobot/node_modules/ws/lib/event-target.js:128:16)
at WebSocket.emit (events.js:127:13)
at _receiver.cleanup (/home/timotejroiko_gmail_com/astrobot/node_modules/ws/lib/websocket.js:211:14)
at Receiver.cleanup (/home/timotejroiko_gmail_com/astrobot/node_modules/ws/lib/receiver.js:557:13)
at WebSocket.finalize (/home/timotejroiko_gmail_com/astrobot/node_modules/ws/lib/websocket.js:206:20)
at TLSSocket.emit (events.js:127:13)
at emitErrorNT (internal/streams/destroy.js:64:8)
at process._tickCallback (internal/process/next_tick.js:114:19)
handle the error event
ErrorEvent {
target:
WebSocket {
_events: [Object],
_eventsCount: 4,
_maxListeners: undefined,
readyState: 2,
protocol: '',
_binaryType: 'nodebuffer',
_finalize: [Function: bound finalize],
_closeFrameReceived: false,
_closeFrameSent: false,
_closeMessage: '',
_closeTimer: null,
_finalized: true,
_closeCode: 1006,
_extensions: {},
_isServer: false,
_receiver: [Receiver],
_sender: [Sender],
_socket: [TLSSocket],
_error: null,
url: 'wss://gateway.discord.gg/?v=6&encoding=json',
_req: null },
type: 'error',
message: 'read ECONNRESET',
error: { Error: read ECONNRESET
at TLSWrap.onread (net.js:619:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' } } }
just handle the error event and you are fine
how do i handle it? process.on()?
i was hunting for the exact event name, but apparently its simply .on('error') lol
now for the error itself its ECONNRESET which means the connection was abruptly terminated
like a network issue
How do i copy ids of emojis prebuilt into discord such as 🇫
you right-click it in the client (not the browser, it won't work)
I cant its an asset not a png like a custom emoji for a server
why do you need the ID?
so theres the id in the link of
but default discord ids do not have it
I need it to test for specific emojis
I did
you can google the unicode character and copy/paste it directly into your code
there's a discord bot somewhere that gives you the unicode
discord itself gives you the unicode
How do i get this oof
here
%emote 🇫
oki
you can also google the emoji, like "regional indicator f", and copy paste it into your code like if(emoji === "🇫")
What would one do similar of a // in js file in json?
So like i can add notes without affecting the code
json doesn't allow comments
some parsers allow, but the spec doesn't
tl;dr you can try adding them, but it's not guaranteed to work
if you really need a comment add inside a key
eg
{
"__comment": "bla bla bla"
}```
Would you know how to make my life any easier by when running my js file it does its normal characters checks but it does ANOTHER check but this time everything thats already defined with be swapped to emojis?
Cuz right, i have a censor bot and I have a bypass and a swears .json files and they all have the normal words in it
But Id also like to make it do the same to those words but do another checks but instead of the word itll be worded using the emojis
if that makes any sense?
why cant you add the emojis the same way as the words in the same check?
easier to just use fuzzy string match
Cuz its really annoying cuz it just shows boxes instead of the actual character
if your json file is utf-8 encoded, it would show unicode emojis correctly
Im using notepad++ and it says encoding with utf-8 but i still dont see them
Im using windows 7 if that makes any difference
unicode version is tied to system version
i've never found a way to update unicode without updating the entire operating system
would love to find out how to do it as well, if its even possible
probably system fonts
No its a microsoft package
I did it before
But i reinstalled windows and have no idea
yeah probably, although i remember trying to install/replace system fonts with newer ones back on windows 8.1 but still didnt display newer unicode characters properly
so to summarize new site updates it basically partner with us and you get some money from ads
don't partner with us and we get all the money from ads?
partner with us = you're big enough to make us lots of money, so we'll share it with you
no partner = you're not big enough, you dont make us enough money
xD
jk pls no ban
why doesnt this work
Okay im coming up with a new problem so once again im trying to censor emoji curse bypasses, so lets just say fuck, right, so 🇫 🇺 🇨 🇰 trying to censor that but for some reason it cant find it cuz the combination of the last two unicode emojis create this 🇨🇰 and then the actual combination of bad letters doesnt get censored
@slim heart its what you dont see
in that flag there is 3 characters
letter, joiner char , letter
So how would i get rid of the joiner char
nvrm i see
theres no space in between i feel dumb
Hey all! I'm trying to reward users with something every time they vote, but the webhook documentation is confusing me, because I don't know how to get the webhook url and it says that the webhook is undefined and i'm following the docs exactly.
Can someone plz help me with this? it would be awesome :)
thanks,
Codingpro
Does any1 have a open-source bot that uses this?
I believe we hooks don't work atm idk for sure tho
@wet ferry
Webhooks*
webhooks work fine
Then the documentation for node.js I outdated
Is*
Unless theyve fixed it since I tried
¯_(ツ)_/¯
you mean the node.js lib
Yeah
discord.js
@keen anvil
I tried your https://github.com/melmsie/dbl-webhook-handler
but it didn't work for me, because how do I get the user that upvoted?
its in the data
😦
EADDRINUSE means something is using the port 3000
so u need to use a diff port @wet ferry
H
Little off topic off bots but, when trying to use a php script on my end using sharex which worked before hand. which now says it's got to many redirects, yet when I try accessing it on a other pc it works fine.
how to check if someone voted for the bot or not ??????????
how many times can you change your activity per hour or something?
Unlimited times
so theres no ratelimits?
okay, will take a look
also how do you change the format of an avatar in djs master?
.setAuthor(`Hi there`, client.user.displayAvatarURL({ type: 'png' }))
it goes to webp and it wouldn't display as an avatar img, dunno how to make it a png properly
You could always replace .webp with .png in the string
i cant get this to return hasPermission, and idk why. function permCheck(userToCheck) { bot.getMember({ serverID: retrieveServerID(), userID: userToCheck }, (e, aa) => { console.log(aa) fs.readFile('./allowed_roles/' + retrieveServerID() + '.settings', function(err, data) { var string = data.toString('utf8').replace(/,/g, '; '); var i = 0; var y = 0; var stopLoop = false; do { if (string.includes(aa.roles[y]) == true) { const hasPermission = true; stopLoop = true; }else { y = ++y if (aa.roles[y] == undefined) { const hasPermission = false; stopLoop = true; } } } while (stopLoop == false); }); }); return hasPermission; }
U using vscode by chance?
yes
Debug that function
alright
And do else if maybe.. instead of else { if
Because if the string doesnt include the role... but the role is defined, stopLoop will never be set to true
Vs code says it returns the hasPermission before it even finishes checking for permissions
Count your } brackets make sure you dont have too many or too few
It says they all have a pair
Oh, I updated it slightly
var hasPermission = false;
bot.getMember({
serverID: retrieveServerID(),
userID: userToCheck
}, (e, aa) => {
console.log(aa)
fs.readFile('./allowed_roles/' + retrieveServerID() + '.settings', function(err, data) {
var string = data.toString('utf8').replace(/,/g, '; ');
var i = 0;
var y = 0;
var stopLoop = false;
do {
if (string.includes(aa.roles[y]) == true) {
hasPermission = true;
stopLoop = true;
}else {
y = ++y
if (aa.roles[y] == undefined) {
hasPermission = false;
stopLoop = true;
}
}
} while (stopLoop == false);
});
});
return hasPermission;
}```
Getting comfortable with debug will help you tremendously. 🙌 ty for not using a text editor
Did you place any breakpoints inside your loop to see whats going on there? Make sure youre stepping into during debug. And iirc y = ++y will make the iteration first of y = 1.. yeah?
I did place breakpoints, I am not stepping in during debug, and iirc y = ++y will increment it by one
y++.. in c# atleast, ++y will evaluate the loop on the increased y value.. if that makes any sense
Shouldnt need y = either.. just y++.. im not familiar with JS, but i think thats fairly universal
.. if im understanding correctly.. youre checking if the string contains the first role in that user has.. if it doesnt, you check if the 2nd role is undefined.. then check if the 2nd role is in string. Then check if 3rd is undefined.. etc?
Yep, and if any of them are undefined it ends the while
Only if it doesn't find it's match
Tbh, id do a foreach loop for all their roles, much more simple
Can probably use lambda expressions. But like i said im not familiar with JS
today i tried to make my first bot and i did add it to my server, but i dont know how to allow other people how to add it
how do you do it?
They need the same link you used to add your bot to your server
i did use the user id to add it
https://discordapp.com/oauth2/authorize?client_id=XXXXXXXXXXXX&scope=bot this link and then add it
so do i share the link with the client id i do have?
Yes. The same one you use
ok thanks
There is a link builder on your bot page.
how do i implement voting
java and i can set one up if i need one
Webhooks is your best bet
looking at the provided api theres no event triggered
guess i gotta do that myself then
No events, you can get votersbyId or something.. the documents are not great
But a webhook listener is your best bet.. dont necessarily need a db.. but good to store values
There are other ways, i send voter ids directly to a discord webhook and give them their daily reward from that
You would need to store that yourself.. if you wanted to keep a tally.. dbl will only let them vote every 24 hours
So no, everyone can vote more than once.. just 24 hours between votes
bot has only been up a week
but got 6 votes anyways
mh
is it slimey to add a donation command to a bot
lmfao
To late.. perm banned!!
😐
Yeh i hate bot dms
Read #rules-and-info
This was meant to be asked in #general but whatever.
-nsfw to hide NSFW channel. Disable server members DMs if you don't wanna het DMs from bots (or just don't use the common prefixes)
Rule 11: You will be attacked if your topic != channel topic this should be added
who can help me with my !ping command?
What part do you need help with?
the command part
i dont know how i setup a ping command
i need help with my kick command
i am trying to make one on my bot
if it works i can help you @earnest phoenix
So you need help sending the time it takes for your bot to ping something and get a response?
What language?
my kick command doesn't kick
i am trying to fix mine
i can help you if mine works
First questions.. does it have permissions.. and is it higher role than the person its trying to kick?
i gave admin role
it has every permission
i made the role for EVERY permission
Admin role doesnt superseded hierarchy
Ofc u can
do it in dm then
No.. just paste code in here.. use code blocks
Unless youre sending $1,000,000 usd. Plz dont dm :D
Bots cant respond in this channel
o
Thats what testing channels are for
Gaming.. if you need to know how to send a ping and record the response time.. just google "ping request {yourprogramminglanguage}"
Yes.. which is why i asked what part you need help with.. and what language
You need help setting up commands? Or you need help sending the message of how long the ping took
the Or you need help sending the message of how long the ping took
Well i still dont know which language.. and im sure there are tons of examples on StackOverflow
const Discord = require("discord.js");
const fs = require("fs");
module.exports.run = async (bot, message, args) => {
let kUser = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
if(!kUser) return message.channel.send("Böyle bir kullanıcı yok!");
let reason = args.join(" ").slice(22);
if(!message.member.hasPermission("MANAGE_MESSAGES")) return message.channel.send("Bunu yapamam!");
if(kUser.hasPermission("MANAGE_MESSAGES")) return message.channel.send("Bu kullanıcı atılamaz!");
if(kUser === message.author) return message.channel.send("Kendini atamazsın!");
let kickEmbed = new Discord.RichEmbed()
.setDescription("Sunucudan At")
.setColor("#c63af4")
.addField("Atılan:", `${kUser} ID: ${kUser.id}`)
.addField("Atan:", `<@${message.author.id}> ID: ${message.author.id}`)
.addField("Sebep:", reason)
.addField("Atıldığı Kanal", message.channel)
.addField("Tarih", message.createdAt);
let kickChannel = message.guild.channels.find(`name`, "atılanlar");
if(!kickChannel) return message.channel.send("Atılanlar kanalı bulunamıyor, bir tane oluşturun.");
message.channel.send(`<@${kUser.id}> sunucudan atıldı!`);
kickChannel.send(kickEmbed);
message.delete().catch(O_o=>{});
return;
}
module.exports.help = {
name: "at"
}
what
Google "get ping response time (Javascript or Java or C#.... etc)
Thats written in Javascript
oo now i see
mine? its javascript
when i kick someone it says kicked but doesn't kick actually
on DBM it is Edit Raw Data
Where in your code do you actually .kick
its the problem
How do I get the hide nsfw? @earnest phoenix
i watched a video to make that command
oh thnx
lul
Try kUser.kick () or something.. idk what function is used to kick users im JS
this is js
Ehhh that didn't work
my library is discord.js
Yeah, youll need to find the discord.js docs and check the Member object to see which function to use.
tyty
You define kUser as the member you want to kick, so youll need to add that into your code
nope
stop putting commands in #development
TO MUTCH DMS
no shit
@quiet bobcat no me
what is the redirect for?
Yo guys. Question about the latest update to bot requirements: I believe bots should allow it in DMs. All a person has to do is use the command to say they are above legal age and only they and the bot can see it, as opposed to a public channel where anyone could try to use the command even if others are below the correct age. It just makes intuitive sense to me.
Oh, question: Does anyone agree with me?
we're talking discord stuff here. discord does not allow nsfw stuff in dms, that's not got anything to do with dbl
it has to specifically be a nsfw channel, dms are not.
Hey so I have an economy bot and want to give people who vote a free case but how do I get it so my bot see's when someone upvotes him
the usage of webhooks is the recommended option
note: not discord's webhooks, use your webserver for that
Ok so I am generating an Image using canvas, I can easily send it in a message with no issues. I want to send it in an embed with .setThumbnail() but I require a url for that. Does anyone know away around this or a suggestion of how to send the image in an embed?
if a thumbnail says it needs a url it means it needs a url, if there would be another way if would have said that in the beginning
I knew that, (I don't think I asked my question well enough) Let me try this again, After generating an image using canvas I want to send it in an embed but I can't because I don't have a url for it. Would it be possible to send the image to a hidden channel in my discord, grab the url of the image and use that in the .setThumbnail() and send the embed?
anything should work as long as the link redirects to the actual image
k that's what I figured. Thanks
have you tried using a base64 url?
actually, you can use discord attachements
"thumbnail": {
"url": "attachment://image.png"
}
}
message.channel.send({ embed, files: [{ attachment: 'img/image.png', name: 'image.png' }] });
let me try that real quick.
hey anyone help me
with what?
i can't set status of my bot
show code
TypeError: Cannot read property 'setStatus' of null
setActivity or setStatus gives the same error
@thorn forge
👍
Anyone knows how to export database values?
sql.get(`SELECT * FROM users WHERE userid = "${message.author.id}"`).then(row => {
if(!row) {
sql.run("INSERT INTO users (userid, farmmoney, farmlevel) VALUES (?, ?, ?)", [message.author.id, Math.floor(Math.random() * 50) + 10, Math.floor(Math.random() * 20) + 10]);
} else {
var userid = row.userid;
let money = row.farmmoney;
let level = row.farmlevel;
let prefix = '!';
let cmd = client.commands.get(command.slice(prefix.length));
if(cmd) cmd.run(client, message, args, database, sql, level, money, userid);
}
}).catch(() => {
console.error;
sql.run(`CREATE TABLE IF NOT EXISTS users (userid TEST, farmmoney INTEGER, farmlevel INTEGER)`).then(() => {
sql.run("INSERT INTO users (userid, farmmoney, farmlevel) VALUES (?, ?, ?)", [message.author.id, Math.floor(Math.random() * 50) + 10, Math.floor(Math.random() * 20) + 10]);
});
});
Doesn't work
🤦
Export to eventually import for use of my command handler
Is a raspberry pi wireless?
Any idea how I would make it so that every word if it contains multiple of the same letter itll condense the string into that words with only 1 letter so if someone were to say fuuuck in the code it would redefine it as fuck
You would need to slice it then check how many there are and then paste it back together and replace it to just 1
@tulip ledge if you have a powerbank a pi can be 100% wireless yeah
make sure you aren't underpowering it though
it wouldn't be wireless anymore at that point, lol
no
@tulip ledge How exactly would I scan for those multiple letters
normalize user input
then do a normal scan
String normalize(String input) {
StringBuilder sb = new StringBuilder();
int last = -1;
for(int i = 0, j = input.length(); i < j; i++) {
char c = input.charAt(i);
if(c != last) {
sb.append(c);
}
last = c;
}
return sb.toString();
}```
just apply this logic to $YOUR_LANGUAGE
@slim heart You can also use regex to scan
Thats what I was planning on using
don't just try to solve everything with regex
it's
a) more expensive
b) slower
c) harder to debug
d) try reading the massive regex expressions you'll end up having
/[\da-z]+/.test(message.content.toLowerCase())
Pretty sure that's it
Or you could
/.+/
That's smaller XD
.+ matches literally everything
Oh yeah he wants 2
or more
might just replace with true at that point
How would you test if it has 2 time or more?
he wants eg fuuuck -> fuck
Ye
if i have a mention prefix and a command that uses mentions to get user data, how can i make it work?
this current command works when i use the default textprefix:balance @ mention, but if i use the bots name mention as a prefix then do balance @ mention, it gets the user data for the bot, not the user i mention
const tagged = msg.mentions.users.first();
if (tagged && !tagged.bot) {
msg.channel.send(`**${tagged.nickname || tagged.username}** has **0 credits** in their balance currently. :credit_card:`);
} else {
msg.channel.send(`You have **0 credits** in your balance currently. :credit_card:`);
}
hi also
or fuuck -> fuck
dunno how to do either of those
okay
so hold on if i scan for fu.+ck it will scan for everything in between correct?
parsing args to users would just need an id->user function
.+ matches anything
and that won't match "fuck"
woo that worked, thanks :D
@slim heart that's not how regex works
How would I go about getting anything after, for example, Hello in a text with regex?
also if i have eg fun and some word that ends in ck, eg check it'd error
that regex would match ^ this message
but there's no fuck there
The regex i already sets up singles out every single word and splits by " "
You would better normalize the user input and then scan it
const words = swears.var
const arrays = byp
arg.forEach(arg => {
words.forEach(words => {
let word = new RegExp (words, 'gi')
if(arg.match(word)) {
const array = arrays[words.toLowerCase()]
if(array[0]) {
let sio1 = new RegExp (array[0], 'gi')
if(arg.match(sio1)) return;
}
//Goes on about 20 times ^
stopped();
console.log(crash)
}
})
})```
fuuuu ckk
also that's extremely inefficient
you do words.length * arg.length * messages regex compilations
So heres the thing word and arg are split by space so it would only match one word so if i match for fu.+ck it wouldnt word for fun lol xd check
Because it already slices the message content
const arg = message.content.slice().trim().split(/ +/g)
so what about f.+ck
and then i just add fsck to the bypass list
hmm
What about flick
flruck also does
ye?
In the process of making this for all my words this website will be my savior lmaoo https://www.visca.com/regexdict/
@client.command(name='10h',
description="This took me so long",
brief="|Random 10 hour video.",
aliases=['10 hour'],
pass_context=True)
async def h(context):
possible_responses = [
'https://www.youtube.com/watch?v=chPcGQbE9g8',
'https://www.youtube.com/watch?v=wI__53kBBKM',
'https://www.youtube.com/watch?v=wZZ7oFKsKzY',
'https://www.youtube.com/watch?v=FWO5Ai_a80M',
'https://www.youtube.com/watch?v=8YGlzSl6cxU',
'https://www.youtube.com/watch?v=-UAUCJNIFXo',
'https://www.youtube.com/watch?v=kxopViU98Xo',
'https://www.youtube.com/watch?v=M8fvsbQmxZw',
'https://www.youtube.com/watch?v=9Fv5cuYZFC0',
'https://www.youtube.com/watch?v=eh7lp9umG2I',
'https://www.youtube.com/watch?v=9gcO6w38svQ',
'https://www.youtube.com/watch?v=FCO95esUzBw',
'https://www.youtube.com/watch?v=3acYFiDejfA',
'https://www.youtube.com/watch?v=Um4OQ6KP1m4',
'https://www.youtube.com/watch?v=rTlAmiLKX_U',
'https://www.youtube.com/watch?v=ArYf4W0tWNY',
'https://www.youtube.com/watch?v=bWr2rZtV0Kk',
'https://www.youtube.com/watch?v=JAfFH-AFEFE',
'https://www.youtube.com/watch?v=p0jNLUhWOrA',
'https://www.youtube.com/watch?v=H0YDbhBNJfY',
'https://www.youtube.com/watch?v=sCNrK-n68CM',
'https://www.youtube.com/watch?v=N7BDEY6GmW0',
'https://www.youtube.com/watch?v=51Gq2fsQty8',
'https://www.youtube.com/watch?v=a6GGZ68mOZA',
]
await client.say(random.choice(possible_responses) + " You asked for it, " + context.message.author.mention)```
why does this make my bot message a random choice 3 times in a row
do you have 3 bot instances running?
its suppose to send 1 link, but it sends 3
when i use the command in my first bot it ignores it and says it doesnt exist, can i share the code there? -.-
yeah
how do you make a bot?
Look up a tutorial?
what does ctx stands for?
context
Ignoring exception in command None
discord.ext.commands.errors.CommandNotFound: Command "sa" is not found
@left gazelle
- You've showed your bots token in that code you will want to get a new one by going to https://discordapp.com/developers/applications/me and going to your bots application from there you can get a new one
@bot.commandshould be@bot.command()await ctx.send_message("Hola")should beawait ctx.send("Hola")
rip
also () for events?
no, just commands
hello I have a javascript code but can you help me I have a problem with thank you 😭 🔫
I don't speak js, but if you post the error and your code someone else can help you
what code returns the error
