#development

1 messages · Page 442 of 1

quartz kindle
#

id: msg.guild.id

#

there is no msg

earnest phoenix
#

which leads to the question, didn't you saw any error in the console

#

or a warning

quartz kindle
#

do async functions return errors without catch? promises dont afaik

sick cloud
#

oof

#

no console errors

quartz kindle
#

i've had my fair share of functions silently failing inside promises

earnest phoenix
#

it shall throw an unhandled promise rejection warning

quartz kindle
#

drove me nuts trying to find them

earnest phoenix
#

unless you're listening to process unhandledRejection event and silently ignore it xD

quartz kindle
#

im listening to it yes, but logging it

earnest phoenix
#

in theory then a promise should trigger it

#

unless you're explicitly catching the said promise as well

quartz kindle
#

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

earnest phoenix
#

if you can provide some sample I could possibly enlighten you further

quartz kindle
#

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

uncut slate
#

@sick cloud you might need to .run() aswell

sick cloud
#

well i got it fixed, run isn't affecting it

#

turns out it was my accidental use of msg.guild a lot lol

sick cloud
#

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

earnest phoenix
#

look up some node express tutorials

outer niche
#

I was told to come here to find help for development for a bot I have in mind

earnest phoenix
#

if you are facing a problem or looking for some guidance sure go ahead

outer niche
#

@earnest phoenix someone to guide me ahead

earnest phoenix
#

are you new to programming?

outer niche
#

Yes

earnest phoenix
#

have you used any programming language before?

outer niche
#

No I am brand new to all of this

#

I just came here for help creating my bot

earnest phoenix
#

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

outer niche
#

@earnest phoenix can you help me

sick cloud
#

figured i can just check my database @earnest phoenix, which works since each guild has a record

#

@outer niche google

outer niche
#

@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

earnest phoenix
#

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

outer niche
#

@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

earnest phoenix
outer niche
#

@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

earnest phoenix
#

I don't think anyone will make a bot for you unless you pay them ;p

sick cloud
#

if its simple enough i make bots for free

#

¯_(ツ)_/¯

outer niche
#

@sick cloud would you like to help me then

sick cloud
#

throw me a dm and i'll see what i can do

shy verge
#

afaik people who do commissions usually charge like 20 bucks

sick cloud
#

Umm, how do you redirect to a URL when you successfully auth a bot?

inner jewel
#

oauth?

sick cloud
#

Yeah, I tried redirect_url but that didn't work

inner jewel
#

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

sick cloud
#

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

inner jewel
#

you do tho?

#

oh

#

i mean

#

why not open the bot invite in a new tab then?

#

and redirect them

#

on click

sick cloud
#

um

inner jewel
#

going through the oauth flow just to redirect users is overkill

sick cloud
#

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

inner jewel
#

for a dashboard you'd want to authenticate users tho

#

so random people don't make changes

sick cloud
#

auth is already done

#

its handled by something else

inner jewel
#

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

sick cloud
#

oh

#

ouch

inner jewel
#

just do a 404 on missing server

sick cloud
#

i guess i'll just use a new tab

#

yeah

inner jewel
#

and leave a button "invite bot"

sick cloud
#

or that

inner jewel
#

you can use the guild_id query param on the invite url

#

to preselect one

sick cloud
#

one last question, how do you get a guilds data from the api?

#

but it didn't work

inner jewel
#

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

sick cloud
#

well uh, i dunno how to make the get request ;-;

#

thats what i'm asking mainly

inner jewel
#
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

sick cloud
#

i have no idea how to get them, uhhm

#

ok

inner jewel
sick cloud
#

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('/'); });
inner jewel
#

there should be a way of getting the token_type and access_token from it

#

you just need those two to make the request

sick cloud
#

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

inner jewel
#

¯_(ツ)_/¯

#

i never used it

upper ember
spring ember
#

@upper ember what is the problem?

upper ember
#

idk

#

it just doesn't response

#

no errors in the console..

earnest phoenix
#

@upper ember msg.channel.send({embed}) hmmm?

upper ember
#

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

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

upper ember
#

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

sick cloud
#

why are you requiring discord.js twice

meager flower
#

There's a difference between { Thing } and just requring something

topaz fjord
#

yes

meager flower
#

But @upper ember you do not have to require richembed

#

just do ```js
let embed = new Discord.RichEmbed()

upper ember
#

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`
shy flicker
#

which line ??

upper ember
#

no idea

#

probs .setDescription(Top Placement\n\nTop 3s: ${data.lifetimeStats[0].value}\nTop 5s: `

shy flicker
#

get yourself a better error logger

upper ember
#

hmm

jagged plume
#

pretty sure lifetimeStats isnt an array

#

but you're treating it like one

upper ember
#

hmmmm

#

not possible

jagged plume
#

it's a json object, not an array

shy flicker
#

simply do console.log(error) and it should give you lines as well

timid mantle
#

is that your token LOL

upper ember
#

I decided to use something from google, this is problem with the bot

jagged plume
#

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.

upper ember
shy flicker
#

something from google isnt an issue, its preety much that either args or data.lifetimeStats doesnt exists at all

upper ember
#

args is exist

jagged plume
#

That video is outdated

#

It's from feb

#

Fortnite's api surely has changed since then

upper ember
#

because I did fortnite.user(playerName, 'pc').then(console.log) and it worked

jagged plume
#

I'm just gonna advise you read the docs

#

for the package you're using

upper ember
#

I never found them...

shy flicker
#

well I would suggest you do console.log(data) before making the embed and show the response if possible

upper ember
shy flicker
#

wrapper is not the problem, there is something wrong with your code

jagged plume
#

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.

earnest phoenix
#

so where is lifetimeStats? 😂

upper ember
#

idk

#

so data.username

#

will work?

jagged plume
#

yes.

shy flicker
#

whats below the stats object ??

upper ember
#

and data.solo.kills ?

shy flicker
#

i.e. get screenshot below it

jagged plume
#

lifetimeStats is part of the api

#

yeah that's correct

#

I'm using the fortnite api aswell, it's there

upper ember
#

can you show me how you did it? @jagged plume

shy flicker
#

I need to see more of the API response if you are fine with it @upper ember

#

cant help without that

jagged plume
#

I'm using a slightly different lib to you

upper ember
jagged plume
#

ahh

#

that response is different

shy flicker
#

there is no lifetimeStats in the response you sent 😕

jagged plume
#

lifetime instead of lifetimeStats

shy flicker
#

its rather data.stats.lifetime[]

jagged plume
#

yeah

upper ember
#

wait data.solo.kills will do fine?

shy flicker
#

like I said earlier lifetimeStats didnt exist

jagged plume
#

data.stats.solo.kills

shy flicker
#

^

upper ember
#

ok

#

it working

#

there's deaths on this api?

#

because I can't find and it sounds like a basic thing

#

@jagged plume

jagged plume
#

not sure, try googling it. not sure if they track deaths or not

upper ember
#

alright

rugged pond
#

Any idea to accept an invitation for a discord server, when the AccountType is a user and not a bot ? 🤔 I'm using JDA

restive silo
#

User Bots are forbidden

#

you shouldn't use them

#

wait did JDA not deprecated the User AccountType

fluid basin
#

Ripp

#

Userbots are against TOS

hot sleet
#

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

ruby dust
#

even bots are still limited to 1 voice channel per server

knotty steeple
#

can multiple shards be on one server?

#

just wondering mmLol

#

also ik seems like a stupid question

jagged plume
#

a server is allocated a single shard

knotty steeple
#

ok

quasi marsh
#

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

simple bramble
#

When making new shards for the first time on your bot, do any existing servers get a random shard or are they not affected

quasi marsh
#

And yes, your bot can connect to 1 voice channel per server

simple bramble
#

And need to be re invites to get one

quasi marsh
#

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

simple bramble
#

Ok

quasi marsh
#

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"

simple bramble
#

Make sense

#

So when sharding the existing servers just get a random shard, ok

quasi marsh
#

Yes but it doesn't really matter that much since shards can operate indepently of each other

simple bramble
#

Besides shard 0 does DMs is there a difference or reason why a server would get a specific shard

quasi marsh
#

No, it doesn't really matter which shard a server gets

simple bramble
#

Ok

quasi marsh
#

Unless for example, you want to DM a member from a server and listen for their response

simple bramble
#

Ok

quasi marsh
#

You can do this with js broadcasteval or discord.py internal sharding, latter which I use

simple bramble
#

I use .net

quasi marsh
#

Hmm, you would need to see the docs about that lang since I don't know anything about .net

simple bramble
#

I’ve been reading then

quasi marsh
#

But unless your bot relies on receiving DM's it's not a big issue

simple bramble
#

My bot doesn’t DM anything

quasi marsh
#

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

simple bramble
#

K

ruby dust
#

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?

quasi marsh
#

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

earnest phoenix
#

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

inner jewel
#

discord doesn't provide the content for deleted messages

#

you'll need to cache them yourself

earnest phoenix
#

ok i know

#

thanks

#

ah

#

d.js has a message cache

#

mb

inner jewel
#

it won't work

earnest phoenix
#

why?

inner jewel
#

MessageImpl.class.getDeclaredField("reactions")

earnest phoenix
#

ik

inner jewel
#

there's no MessageImpl class anymore

earnest phoenix
#

Yes

#

I'll make cache myself

restive silo
#

wait does JDA not provide the message object if cached on that event? 👀

native narwhal
#

Hue

inner jewel
#

JDA doesn't cache messages

restive silo
#

and there is no option to enable caching? 👀

inner jewel
#

no

restive silo
#

oof

inner jewel
#

but you can just implement one

#

it's not hard

#

¯_(ツ)_/¯

native narwhal
#

I mean it is not hard to make your own implementation of it

restive silo
#

sure thats what you can always do

inner jewel
#

JDA provides almost nothing that doesn't have a direct equivalent in the discord api

native narwhal
#

Yup

inner jewel
#

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

#

¯_(ツ)_/¯

native narwhal
#

Yeah

restive silo
#

oh jda-utils implements cache?

#

👀

inner jewel
#

not sure

#

it does commands, menus, event waiters

tribal hazel
#

How do you make a custom server prefix command?

tulip ledge
#

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 😛

tribal hazel
#

Oh.

#

What video is the best to use?

#

The Source Code, Plexi Development, or Evies Code?

#

Evie.Codes*

tulip ledge
#

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

tribal hazel
#

oK

#

Thanks.

tribal hazel
#
  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?

earnest phoenix
#

yes

tribal hazel
#

Ok.

night imp
#

I mean it is copied but yeah

tribal hazel
#

Ik

neat falcon
#

copied commands blobThonk

tribal hazel
#
    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?

night imp
#

Nothing I guess if it works ¯_(ツ)_/¯

tribal hazel
#

It doesnt.

#

(╯°□°)╯︵ ┻━┻

neat falcon
#

well

#

you need to integrate it with ur command handler

night imp
#

what is the error

#

also did you define the function clean

tribal hazel
#

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.

night imp
#

message.mentions

#

look for size

#

(on the docs)

tribal hazel
#

?

earnest phoenix
#

Ok

night imp
#

I see that you are trying to run your bot

tribal hazel
#

Nvm

#

Im good

night imp
#

Do you have the files on your computer?

earnest phoenix
#

Yep

#

es somewhere

tribal hazel
#

Nvm

night imp
#

Could you post a picture/snippet of your code?

tribal hazel
#

command wont

#

work

earnest phoenix
#

I have another one somewhere

slender thistle
#

R.I.P token

night imp
#

Ok you may want to watch a tutorial on YouTube

earnest phoenix
#

I saw it from this site

night imp
#

For this, just change untitled.txt to untitled.js

slender thistle
#

I recommend you deleting the screenshot and resetting your token

earnest phoenix
#

https://anidiotsguide_old.gitbooks.io/discord-js-bot-guide/content/getting-started/the-long-version.html

#

Sorry I ma on gogle crome

night imp
#

And if you have installed npm and node you can run it using node untitled

earnest phoenix
#

Is node affilated with discord

night imp
#

This should go over setup

inner jewel
#

no

neat falcon
#

thank 4 token

inner jewel
#

node is unrelated to discord

#

it's just a program that runs javascript code

night imp
#

No, node is a backend version of js

tribal hazel
#

Why wont my command work!

neat falcon
#

what command!!11

night imp
#

Panther error please

tribal hazel
#

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"
}
night imp
#

Error please

tribal hazel
#

Ok

neat falcon
#

it isn't displayAvatarURL afaik

night imp
#

Something I can see off the bat

neat falcon
#

oof

#

am detecting multiple errors

tribal hazel
#

Can you help fix my code?

night imp
#

Yeah we are saying what's wrong

tribal hazel
#

Done.

night imp
#

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

tribal hazel
#

Ik.

night imp
#

You need a user for avatarURL

tribal hazel
#

The avatar command works

#

but if someone

#

hasnt put in

#

a

#

mention

#

it doesnt work

night imp
#

Message.mentions

#

and look for size

tropic ridge
#

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?

rugged pond
#

@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

earnest phoenix
#

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

restive silo
#

@rugged pond thats against Discord ToS

#

you could get banned for that

tropic ridge
#

I want the ability to store data of up to 10k users

earnest phoenix
#

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

tropic ridge
#

So if I'm already with MySQL I shouldn't bother with switching?

earnest phoenix
#

why do you want to switch?

tropic ridge
#

I've seen many people use Mongo with Discord bots and none use MySQL

topaz fjord
#

mongo is a nosql

#

i use it on my bot

earnest phoenix
#

take a look at this

rugged pond
#

@restive silo
I already have an application running for 1 year and I'm not banned 🤔

restive silo
#

why would anyone use MySQL these days

#

@rugged pond i could get you banned by reporting it

earnest phoenix
#

why wouldn't they

rugged pond
#

No 😂

earnest phoenix
restive silo
#

postgres is like 5x faster and support NoSQL Types

earnest phoenix
#

it all depends on the application that you're building

inner jewel
#

anyway don't run bots on your account

rugged pond
#

I know many people who make this to filter advertisements in private messages like me

#

😂

earnest phoenix
#

you remember the bridge saying

#

if everyone jumps off a bridge

#

will you do it too?

rugged pond
#

Yes 😂

#

I gonna to ask to the discord support if that i'm doing is legal

#

😂

earnest phoenix
#

I'd advise not to

#

they already stated otherwise

rugged pond
#

hmm ok

#

🤔

#

So i'm going to delete my application

#

😂

tropic ridge
#

Thanks, Atlas

earnest phoenix
#

👍

sour dune
#

.infods

tribal hazel
#

Can someone help me with my avatar command? I've only fixed half of it.

quiet bobcat
#

Sure but we need more info

tribal hazel
#

My code?

quiet bobcat
#

yes

tribal hazel
#

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"
}
quiet bobcat
#

or like your problem

tribal hazel
#

The avatar bit works.

#

But if no one has mentioned a user and just done <avatar it doesnt do error message.

quiet bobcat
#

check if args[0] includes a mention?

tribal hazel
#

How?

tribal hazel
#

?

quiet bobcat
#

check if args[0] includes a mention

#

so like args[0].includes(mention thing)

tribal hazel
#

if(!args[0].includes msg.mentions.users.first(); return message.channel.send(`**<@${msg.author.id}>, Please insert a mention! :white_check_mark:**`);

#

?

tulip ledge
#

🤦

tribal hazel
#

Error on msg.mentions.first

#

?

tulip ledge
#

args[0].includes(msg.mentions.users.first)

tribal hazel
#

Thx

tulip ledge
#

With includes you always need () and inside the () you need to put the thing you want to check

quiet bobcat
#

also you could do size instead of first

tribal hazel
#

I got an error.

#

@quiet bobcat

spring ember
#

can you send code

quiet bobcat
#

the thing before displayAvatarURL is undefined

spring ember
#

also don't ping johans

tribal hazel
#
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"
}
spring ember
#

ok maybe someone didn't mention anyone

tribal hazel
#

I want to it to send an error if

#

it didnt

spring ember
#

if no mentions are present then first will be undefiened

#

why do you want an error though?

tribal hazel
#

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

spring ember
#

if (aTaged == null)?

tribal hazel
#

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

spring ember
#

no

#

aTaged is

tribal hazel
#

What do I do to make this work?

spring ember
#
if (aTaged == null) {
    // do whatever you want
}```?
tribal hazel
#

Im confused?

spring ember
#

it's basic JavaScript

tribal hazel
#

Whas the full code for me to use to make this work?

spring ember
#

I won't spoonfeed

tribal hazel
#

Im stuck.

#

I think Im dumb. lol

earnest phoenix
#

@tribal hazel you're not dumb, you just have a limited knowledge of JavaScript.

old glade
#

Is there a doc somewhere where I can find python example on how to add a vote command ?

brave lion
#

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

drowsy lily
#

Are you adding ids?

brave lion
#

Yes

drowsy lily
#

No idea

sick cloud
#

you need to separate them with a comma

#

id, id, id iirc

brave lion
#

Omg thanks man. I tried comma but not comma and a space

sick cloud
#

np

exotic wave
#

@tribal hazel use user.displayAvatarURL

quartz kindle
#

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)
restive silo
#

handle the error event

quartz kindle
#
   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' } } }
restive silo
#

just handle the error event and you are fine

quartz kindle
#

how do i handle it? process.on()?

restive silo
#

like every client event

#

client.on

quartz kindle
#

i was hunting for the exact event name, but apparently its simply .on('error') lol

earnest phoenix
#

now for the error itself its ECONNRESET which means the connection was abruptly terminated

#

like a network issue

slim heart
#

How do i copy ids of emojis prebuilt into discord such as 🇫

sullen path
#

you right-click it in the client (not the browser, it won't work)

slim heart
#

I cant its an asset not a png like a custom emoji for a server

sullen path
#

why do you need the ID?

slim heart
#

so theres the id in the link of thonkku but default discord ids do not have it

#

I need it to test for specific emojis

sullen path
#

huh

#

try testing the text for the emoji code like : regional_indicator_a:

slim heart
#

I did

inner jewel
#

they don't have ids

#

they're unicode

quartz kindle
#

you can google the unicode character and copy/paste it directly into your code

sullen path
#

there's a discord bot somewhere that gives you the unicode

inner jewel
#

discord itself gives you the unicode

slim heart
#

How do i get this oof

sullen path
slim heart
#

%emote 🇫

sullen path
#

the one in brackets

#

the bot isn't in this server

#

@slim heart

slim heart
#

oki

quartz kindle
#

you can also google the emoji, like "regional indicator f", and copy paste it into your code like if(emoji === "🇫")

slim heart
#

What would one do similar of a // in js file in json?

#

So like i can add notes without affecting the code

inner jewel
#

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"
}```
slim heart
#

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?

quartz kindle
#

why cant you add the emojis the same way as the words in the same check?

inner jewel
#

easier to just use fuzzy string match

slim heart
#

Cuz its really annoying cuz it just shows boxes instead of the actual character

quartz kindle
#

if your json file is utf-8 encoded, it would show unicode emojis correctly

slim heart
#

Im using notepad++ and it says encoding with utf-8 but i still dont see them

blazing star
#

use vscode

#

not notepad++

quartz kindle
#

idk here it works

slim heart
#

Im using windows 7 if that makes any difference

quartz kindle
#

ah

#

thats probably why

slim heart
#

Yeah

#

I need some microsoft package

#

I cant remember what tho

quartz kindle
#

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

inner jewel
#

probably system fonts

slim heart
#

No its a microsoft package

#

I did it before

#

But i reinstalled windows and have no idea

quartz kindle
#

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

slim heart
#

There

#

Yes

#

Thank u :)

shy rose
#

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?

quartz kindle
#

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

wintry bobcat
#

why doesnt this work

slim heart
#

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

shy rose
#

@slim heart its what you dont see

#

in that flag there is 3 characters

#

letter, joiner char , letter

slim heart
#

So how would i get rid of the joiner char

#

nvrm i see

#

theres no space in between i feel dumb

wet ferry
#

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?

keen anvil
#

what language

#

is your bot in

craggy bear
#

I believe we hooks don't work atm idk for sure tho

keen anvil
#

@wet ferry

craggy bear
#

Webhooks*

keen anvil
#

webhooks work fine

craggy bear
#

Then the documentation for node.js I outdated

#

Is*

#

Unless theyve fixed it since I tried

#

¯_(ツ)_/¯

keen anvil
#

you mean the node.js lib

craggy bear
#

Yeah

wet ferry
#

discord.js

#

@keen anvil

#

but it didn't work for me, because how do I get the user that upvoted?

keen anvil
#

its in the data

wet ferry
#

wdym?

#

I also get this error:
Error: listen EADDRINUSE :::3000

keen anvil
#

google

wet ferry
#

😦

tidal parrot
wet ferry
topaz fjord
#

EADDRINUSE means something is using the port 3000

#

so u need to use a diff port @wet ferry

hardy merlin
#

H

floral stone
#

in d.py, could you add an embed below an image

stray wasp
#

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.

hot sleet
#

how to check if someone voted for the bot or not ??????????

sick cloud
#

how many times can you change your activity per hour or something?

hot sleet
#

Unlimited times

sick cloud
#

so theres no ratelimits?

jagged plume
#

pretty sure there was

#

might be on the developer documentation page

sick cloud
#

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

quasi marsh
#

You could always replace .webp with .png in the string

sick cloud
#

i know theres a way to do it from discord

#

but i can

fervent oyster
#

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

mental solstice
#

U using vscode by chance?

fervent oyster
#

yes

mental solstice
#

Debug that function

fervent oyster
#

alright

mental solstice
#

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

fervent oyster
#

Vs code says it returns the hasPermission before it even finishes checking for permissions

mental solstice
#

Count your } brackets make sure you dont have too many or too few

fervent oyster
#

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;
    }```
mental solstice
#

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?

fervent oyster
#

I did place breakpoints, I am not stepping in during debug, and iirc y = ++y will increment it by one

mental solstice
#

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?

fervent oyster
#

Yep, and if any of them are undefined it ends the while

#

Only if it doesn't find it's match

mental solstice
#

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

left gazelle
#

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?

mental solstice
#

They need the same link you used to add your bot to your server

left gazelle
#

i did use the user id to add it

mental solstice
#

Client_id is your bot client id

#

It will not change if someone else uses it

left gazelle
#

so do i share the link with the client id i do have?

mental solstice
#

Yes. The same one you use

left gazelle
#

ok thanks

mental solstice
#

There is a link builder on your bot page.

earnest phoenix
#

how do i implement voting

mental solstice
#

Depends

#

What language? Are you using a database already?

earnest phoenix
#

java and i can set one up if i need one

mental solstice
#

Webhooks is your best bet

earnest phoenix
#

looking at the provided api theres no event triggered

#

guess i gotta do that myself then

mental solstice
#

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

earnest phoenix
#

so

#

does it also count how often they voted?

#

or can everyone just vote once?

mental solstice
#

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

earnest phoenix
#

wait lol

#

i can vote for my own bot

#

lmfao

mental solstice
#

Ifc

#

Ofc

earnest phoenix
#

every day?

#

man ive been missing out on votes

mental solstice
#

Yep

#

Yeh u coulda got 31 last month!

#

;)

earnest phoenix
#

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

mental solstice
#

Depends if the bot is worth it ;)

#

But i dont think its slimey..

earnest phoenix
#

mh

#

i have an idea

#

!bots

#

!luca

#

!help

mental solstice
earnest phoenix
#

i dident mea that

#

how do i hide nsfw

mental solstice
#

To late.. perm banned!!

earnest phoenix
#

😐

mental solstice
#

Lol

#

Idk if you can hide it.. but you can mute it so it doesnt turn white

earnest phoenix
#

did it

#

thx

#

and TO mutch dms from bots

mental solstice
#

Yeh i hate bot dms

earnest phoenix
#

i 2

#

i am still getting alerts

#

i deleted the dms and even then

slender thistle
earnest phoenix
#

i alreddy did

#

o sorry

#

😬

slender thistle
#

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)

earnest phoenix
#

Yes

#

no nsfw

mental solstice
#

Rule 11: You will be attacked if your topic != channel topic this should be added

earnest phoenix
#

who can help me with my !ping command?

mental solstice
#

What part do you need help with?

earnest phoenix
#

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

mental solstice
#

So you need help sending the time it takes for your bot to ping something and get a response?

#

What language?

earnest phoenix
#

my kick command doesn't kick

#

i am trying to fix mine

#

i can help you if mine works

mental solstice
#

First questions.. does it have permissions.. and is it higher role than the person its trying to kick?

earnest phoenix
#

i gave admin role

#

it has every permission

#

i made the role for EVERY permission

mental solstice
#

Admin role doesnt superseded hierarchy

earnest phoenix
#

can i send code

#

if its not forbidden

mental solstice
#

Ofc u can

earnest phoenix
#

do it in dm then

mental solstice
#

No.. just paste code in here.. use code blocks

#

Unless youre sending $1,000,000 usd. Plz dont dm :D

earnest phoenix
#

😄

#

gb!ChatClear 1

#

gb!ChatClear 3

#

NOO the bot dont have perms

mental solstice
#

Bots cant respond in this channel

earnest phoenix
#

o

mental solstice
#

Thats what testing channels are for

earnest phoenix
#

it dont work in the

#

it is a chatclear but no perms

#

i have to edit

#

so back

mental solstice
#

Gaming.. if you need to know how to send a ping and record the response time.. just google "ping request {yourprogramminglanguage}"

earnest phoenix
#

wye

#

!ping

#

like that command

mental solstice
#

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

earnest phoenix
#

the Or you need help sending the message of how long the ping took

mental solstice
#

Well i still dont know which language.. and im sure there are tons of examples on StackOverflow

earnest phoenix
#

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

mental solstice
#

Google "get ping response time (Javascript or Java or C#.... etc)

earnest phoenix
#

my kick code

#

discord.js

#

i just use the discord bot maker program

mental solstice
#

Thats written in Javascript

earnest phoenix
#

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

mental solstice
#

Where in your code do you actually .kick

earnest phoenix
#

its the problem

meager flower
#

How do I get the hide nsfw? @earnest phoenix

earnest phoenix
#

i watched a video to make that command

meager flower
#

oh thnx

earnest phoenix
#

lul

mental solstice
#

Try kUser.kick () or something.. idk what function is used to kick users im JS

earnest phoenix
#

this is js

meager flower
#

Ehhh that didn't work

earnest phoenix
#

my library is discord.js

mental solstice
#

Yeah, youll need to find the discord.js docs and check the Member object to see which function to use.

earnest phoenix
#

thanks

#

@meager flower do -nsfw

meager flower
#

tyty

mental solstice
#

You define kUser as the member you want to kick, so youll need to add that into your code

earnest phoenix
#

if you wanna see it (dont know if it works) do +nsfw

#

+nsfw

#

nope dont work

topaz fjord
#

+nsfw isnt a thing

#

you do -nsfw again to see it

earnest phoenix
#

only got a dm from @empty orchid

#

-12

topaz fjord
#

nope

earnest phoenix
#

-13

#

im sad now

#

-help

topaz fjord
quiet bobcat
earnest phoenix
#

TO MUTCH DMS

quiet bobcat
#

no shit

topaz fjord
#

@quiet bobcat no me

quiet bobcat
#

bots can still read messages

#

they just can't send them

left gazelle
#

what is the redirect for?

mental solstice
#

Page user gets sent to after adding your bot

#

I think

dim grove
#

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?

jagged plume
#

what bot requirements

#

and allow what in dms

dim grove
#

For the bot to be allowed on DBL, NSFW content.

#

In that order.

jagged plume
#

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.

dim grove
#

Ah, I get what you mean.

#

I had no idea, I myself am only 14.

tulip ledge
#

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

ruby dust
#

the usage of webhooks is the recommended option

#

note: not discord's webhooks, use your webserver for that

sick iron
#

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?

ruby dust
#

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

sick iron
#

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?

ruby dust
#

anything should work as long as the link redirects to the actual image

sick iron
#

k that's what I figured. Thanks

quartz kindle
#

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' }] });
sick iron
#

let me try that real quick.

earnest phoenix
#

hey anyone help me

quartz kindle
#

with what?

earnest phoenix
#

i can't set status of my bot

quartz kindle
#

show code

earnest phoenix
#

TypeError: Cannot read property 'setStatus' of null

#

setActivity or setStatus gives the same error

gilded plankBOT
#
Shura#1586
Bots

@thorn forge

quartz kindle
#

that means the variable before setStatus is empty

#

show code, not error

earnest phoenix
#

ok fixed

#

i didn't add ready step

quartz kindle
#

👍

tulip ledge
#

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

stable juniper
#

What do you mean export?

#

You mean export as in literally export to a .sql?

tulip ledge
#

🤦

#

Export to eventually import for use of my command handler

#

Is a raspberry pi wireless?

slim heart
#

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

tulip ledge
#

You would need to slice it then check how many there are and then paste it back together and replace it to just 1

uncut slate
#

@tulip ledge if you have a powerbank a pi can be 100% wireless yeah

#

make sure you aren't underpowering it though

tulip ledge
#

Can't you plug in into a wall outlet?

#

or just a normal outlet?

uncut slate
#

it wouldn't be wireless anymore at that point, lol

tulip ledge
#

Oh yeah 🤦

#

But I ment

#

Do you need to plug it into your pc?

#

To use it

uncut slate
#

no

slim heart
#

@tulip ledge How exactly would I scan for those multiple letters

inner jewel
#

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

tulip ledge
#

@slim heart You can also use regex to scan

slim heart
#

Thats what I was planning on using

inner jewel
#

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

tulip ledge
#

/[\da-z]+/.test(message.content.toLowerCase())

#

Pretty sure that's it

#

Or you could

#

/.+/

#

That's smaller XD

inner jewel
#

.+ matches literally everything

tulip ledge
#

Oh yeah he wants 2
or more

inner jewel
#

might just replace with true at that point

tulip ledge
#

How would you test if it has 2 time or more?

inner jewel
#

he wants eg fuuuck -> fuck

slim heart
#

Ye

sick cloud
#

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

tulip ledge
#

or fuuck -> fuck

inner jewel
#

don't use regex for that

#

use a proper way

#

it's easier and more readable

tulip ledge
#

MMmmh you might be right

#

I only use regex to check if it's a hex value

inner jewel
#

@sick cloud skip any bot mentions

#

or parse args to users

sick cloud
#

dunno how to do either of those

inner jewel
#

if users is an array

sick cloud
#

okay

slim heart
#

so hold on if i scan for fu.+ck it will scan for everything in between correct?

inner jewel
#

parsing args to users would just need an id->user function

#

.+ matches anything

#

and that won't match "fuck"

sick cloud
#

woo that worked, thanks :D

tulip ledge
#

@slim heart that's not how regex works

slender thistle
#

How would I go about getting anything after, for example, Hello in a text with regex?

inner jewel
#

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

slim heart
#

I see

#

Okay so heres one thing

inner jewel
slim heart
#

The regex i already sets up singles out every single word and splits by " "

tulip ledge
#

You would better normalize the user input and then scan it

inner jewel
#

if it splits by word

#

then i can do

slim heart
#
            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)
                }
            })
        })```
inner jewel
#

fuuuu ckk

#

also that's extremely inefficient

#

you do words.length * arg.length * messages regex compilations

slim heart
#

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)

inner jewel
#

yes

#

but fu.+ck

#

won't match fuck

slim heart
#

so what about f.+ck

inner jewel
#

fck

#

also that'd match eg fsck, an unix command

slim heart
#

and then i just add fsck to the bypass list

warped ruin
#

hmm

slim heart
#

and their

spring ember
#

What about flick

slim heart
#

it is bypasses aswell yes

#

fl.+ck

spring ember
#

flruck also does

slim heart
#

ye?

wintry bobcat
#
@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

sullen path
#

do you have 3 bot instances running?

wintry bobcat
#

its suppose to send 1 link, but it sends 3

left gazelle
#

when i use the command in my first bot it ignores it and says it doesnt exist, can i share the code there? -.-

wintry bobcat
#

yeah

left gazelle
#

how do i format it?

#

when it does reach sa it ignores it

crisp tide
#

how do you make a bot?

quiet bobcat
#

Look up a tutorial?

left gazelle
#

what does ctx stands for?

turbid gale
#

context

left gazelle
#

Ignoring exception in command None

#

discord.ext.commands.errors.CommandNotFound: Command "sa" is not found

turbid gale
#

@left gazelle

  1. 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
  2. @bot.command should be @bot.command()
  3. await ctx.send_message("Hola") should be await ctx.send("Hola")
quartz kindle
#

rip

left gazelle
#

also () for events?

orchid horizon
#

no, just commands

left gazelle
#

ok

#

!thanks

earnest phoenix
#

How to make custom photos

#

Like level card of mee6

zealous hazel
#

hello please help for code script javascript thx

#

? 😟

zealous hazel
#

hello I have a javascript code but can you help me I have a problem with thank you 😭 🔫

orchid horizon
#

I don't speak js, but if you post the error and your code someone else can help you

zealous hazel
#

😭 🔫

orchid horizon
#

what code returns the error

zealous hazel
#

pv

#

in pv code i'ts privacy