#development

1 messages Β· Page 976 of 1

timber linden
#

I'm trying to play

#

But it doesn't work

misty sigil
#

so i made the vote command

#

how do i make it show name and not ID

timber linden
#

No helpers on.

weary ridge
#

hey

#

so i want a cmd to send a random pic everytime the cmd i sent

#

i found this link that gives a random link

#

but it doesn't update everytime you use the link

timber linden
#

Do you know how to play a bot

#

?

#

If your on mobile you can add to home screen and it saves

lyric mountain
#

errr.....play a bot?

hoary lily
#

Wait wh-- I'm confused

ancient lichen
misty sigil
#

Anyone know how to get the avatar URL

timber linden
#

O

#

K

sudden geyser
#

Jeremy what library

misty sigil
#

djs

timber linden
#

Set or sent

hoary lily
#

if yourself
message.author.avatarURL

#

if mentioned user
message.mentions.users.first().avatarURL

sudden geyser
timber linden
#

Still doesn't work

#

I did set at end and top.

sudden geyser
#

There are options to go along with it.

hoary lily
#

@timber linden I'm confused with your codes what language is that

timber linden
#

I used spck editor

#

A mobile app.

lyric mountain
#

that code is clearly copy-pasted from somewhere

timber linden
#

My brother helped me make it is why

lyric mountain
timber linden
#

Idk if he copy and pasted a script

#

.

#

He did not copy a script

#

Omfg

lyric mountain
#

he did

hoary lily
#

It's ok just edit it

timber linden
#

Ye imma make a different bot

earnest phoenix
#

??

#

why

hoary lily
#

It's open-source

lyric mountain
#

like, you don't need to make another bot, just don't blatantly copy example code

timber linden
#

What is the easiest type of bot to script

lyric mountain
#

you gotta learn from it, not copy-paste it

hoary lily
#

read discord.js guide

#

I learned through that @timber linden

timber linden
#

Oh

hoary lily
timber linden
#

I'll just use yt

misty sigil
#

is there a way to add commands to my bot

#

without restarting it?

hoary lily
#

Goodluck with yt

#

You need to restart everytime you load commands

timber linden
#

A series*

lyric mountain
misty sigil
#

mkay

lyric mountain
#

just give it a read, try to understand

#

not u @misty sigil

#

you need to restart it everytime

hoary lily
#

You can't just learn just by watching @timber linden you need to read it step by step

misty sigil
#

i was saying that to

#

setting

lyric mountain
#

btw, ain't js dinamically loaded?

#

like, you could update the command file and have it updated in realtime

misty sigil
#

yea

lyric mountain
#

without shutting down the bot

hoary lily
#

In my host I do that

misty sigil
#

but i use reload for that

hoary lily
#

But on my device I restart everytime

#

loading the node index.js

weary ridge
#

Bruh I was coding and 2 hours felt like 10 mins no lie

lyric mountain
#

welcome to programming club

hoary lily
#

Yeah same when you like what you're doing

lyric mountain
#

coffee machine is in the room to the right, stackoverflow to the left

weary ridge
#

But its 2:27 am and guess who has school at 7am

#

Lol

hoary lily
#

Sleep for 3 hrs. then

weary ridge
#

Reeee

#

I’m gonna actually go to bed

hoary lily
#

Goodnight !

weary ridge
#

And coffee will never work

#

Lol gn

hoary lily
#

Kk

timber linden
#

Mk I'll read it

hoary lily
#

Uhm I'm confused on webhooks

#

What webhooks are for?

timber linden
#

I'll just use other ppl bots

hoary lily
#

Wth

#

Hahahaha

cinder patio
#

Webhooks allow you to post messages with a different pfp and username, and also send multiple embeds

#

And I think the API limits are less strict

hoary lily
#

Oh I get it

#

Thankss

#

Also Partials

#

What are they

lyric mountain
#

webhooks don't require the bot to be in a server also

#

and they can't listen to events, only send messages

hoary lily
#

Woah they're like notification senders

cinder patio
#

they're a thing made up by discord.js, they are objects which are guaranteed to have only an id property

hoary lily
#

Nice I think I'll create one

#

@cinder patio what partials can do?

#

Sorry too many questions I want to learn :<

lyric mountain
#

that's good, don't be shy to ask

cinder patio
#

nothing really, they are used for "raw" events, where there's not enough information about an object

hoary lily
#

Nice nice I'll come here everytime I'm having a hard time thanks!

#

Thanks bro Google!

#

Thanks for the intel guys

misty sigil
#

how do i check if my bot has permission in a channel

hoary lily
torn ravine
#

^

hoary lily
#

Sorry bro I don't do code that check my bot perms :<

#

I can help you with that link

misty sigil
#

i seen that, maybe i just didn't pay enough attention

hoary lily
#

wait I'll help ya

#

client.roles.cache.map()
Maybe

#

I'm not yet pro but you can try that

misty sigil
#

hhm

hoary lily
#

@misty sigil what check

#

Like check for admin perms?

quartz kindle
#

channel.permissionsFor(user).has(permissions)

hoary lily
#

Nice there ya goo

misty sigil
#

how would i do that for my bot?

hoary lily
#

if(channel.permissionsFor(user).has("ADMINISTRATOR") {
        return message.reply("You have administrator privileges");
earnest phoenix
#
if (!muteRole) {
    message.guild.roles.create({
        data: {
            name: 'Muted',
            color: '#bdbdbd',
            hoist: false,
            position: 0,
            permissions: [],
            mentionable: false,
        },
        reason: 'No role for mutes found, hence this was created.',
    }).catch(console.error);
}

message.guild.channels.cache.forEach(async (channel) => {
    await channel.overwritePermissions([
        {
            id: muteRole.id,
            deny: ['SEND_MESSAGES', 'CONNECT', 'ADD_REACTIONS'],
        },
    ], 'Mute role permissions');
});``` Anyone know why this resets the @[everyone] perms
#

and allows the muted user to see channels that are privated

timber linden
#

Idk

misty sigil
#

Cannot read property 'me' of undefined

timber linden
#

Cannot read property 'me' of undefined🀑 🀑 🀑

#

Es

hoary lily
#

pls wait

#

Only channel perms really?

#

I create server perms :(

timber linden
#

Who here made anti raid

#

Lock bot

#

V2

#

🀑 it works

earnest phoenix
hoary lily
#
const Permission = message.member.permissions;

if (!message.member.hasPermission("ADMINISTRATOR", { checkOwner: true })) {
         message.reply("You don\'t have enough Permission!");
}
#

Like that

quartz kindle
#

that doesnt account for channel permission overwrites

hoary lily
#

yes I was hoping he can get a grasp

earnest phoenix
#

found my answer

quartz kindle
hoary lily
#

What is ittt??

quartz kindle
#

client.guild doesnt exist, but client.guilds does, it holds all guilds the bot is in

hoary lily
#

Oh that "s"

#

Noted

quartz kindle
#

so you either do client.guilds.cache.get(guildid) or you get the relevant guild from the message, message.guild

hoary lily
#

Thanks thanks I learn new things

spark breach
#

I have a little problem, So I have a command which should be 'Beaver poll question' but the bot also responds to 'Please poll question'.
Is there a way I could fix this? The code:

    let args = message.content.substring(PREFIX.length).split(" ");

    switch(args[0]) {

                //poll
                case 'poll':
                    if(!message.member.hasPermission("ADMINISTRATOR", explicit = true)) return message.channel.send("You don't have permissions, sorry!")

                    const EmbedPoll = new MessageEmbed()
                    .setTitle("Error:")
                    .setColor(0xff0000)
                    .addField("Error:", 'Please add a yes or no question for the yes or no poll to work.');
            
                    if(!args[1]){
                        message.channel.send(EmbedPoll);
                        break;
                    }
            
                    let msgArgs = args.slice(1).join(" ");

                    message.channel.send("πŸ“‹ " + "**" + msgArgs + "**").then(messageReaction => {
                        messageReaction.react("πŸ‘");
                        messageReaction.react("πŸ‘Ž");
                        message.delete({ timeout: 100 }).catch(console.error);
                    });
                    break;```
halcyon ember
#

anyone know why this aint catching error

#
        message.channel.send(embed)
    } catch (error) {
        message.author.send(embed)
        message.channel.send("I wasn't able to send the help embed in this channel, please notify a server admin. I've sent the embed to your DMs instead")
    }```
quartz kindle
#

it will catch them if you await them

halcyon ember
#

await message.channel.send(embed)

#

oh wiat i need to put async function run() { message.channel.send(embed) } and then await run()

quartz kindle
#

await message.channel.send

halcyon ember
#

oh

quartz kindle
#

@spark breach you dont have any code that checks for prefix

spark breach
#

ohhhhhhhh

#

const PREFIX = 'Beaver '; that is the prefix code, do you know how I can make it check if the prefix is being used?

quartz kindle
#

check if the message starts with your prefix

spark breach
#
    let args = message.content.startsWith(PREFIX.length);```
#

so like that?

quartz kindle
#

no

spark breach
#

Oof how then? (sorry I am new to coding xD)

quartz kindle
#

startsWith returns true or false

#

if you do that, then args becomes either true or false

spark breach
#

ohhhh

#

What would I need to do then for it to check it?

quartz kindle
#

use an if

spark breach
#

oh oki

lyric mountain
spark breach
#

oh oki

#
    if (message.content.startsWith(PREFIX));
    
    switch(args[0]) {

                //poll
                case 'poll':
                    if(!message.member.hasPermission("ADMINISTRATOR", explicit = true)) return message.channel.send("You don't have permissions, sorry!")

                    const EmbedPoll = new MessageEmbed()
                    .setTitle("Error:")
                    .setColor(0xff0000)
                    .addField("Error:", 'Please add a yes or no question for the yes or no poll to work.');
            
                    if(!args[1]){
                        message.channel.send(EmbedPoll);
                        break;
                    }
            
                    let msgArgs = args.slice(1).join(" ");

                    message.channel.send(":clipboard: " + "**" + msgArgs + "**").then(messageReaction => {
                        messageReaction.react(":thumbsup:");
                        messageReaction.react(":thumbsdown:");
                        message.delete({ timeout: 100 }).catch(console.error);
                    });
                    break;```
I am guessing the "switch(args[0]) {" needs to go away because there is nothing with 'args'?
quartz kindle
#

.length returns the length of the text, so if prefix is Beaver its length is 7, so if you do that, you're checking if the message starts with7

spark breach
#

Ah ty

quartz kindle
#

thats not how you use an if

spark breach
#

oh ._. xD

quartz kindle
#

you have other ifs in your code

#

look at them

spark breach
#

oki ill look

#

I mean most of my other ifs are like if(!message.member.hasPermission("ADMINISTRATOR", explicit = true)) return message.channel.send("You don't have permissions, sorry!")Or if(!args[1]){

quartz kindle
#

yes

#

there are two ways to use an if

#
if(something) do something

or

if(something) {
  do something
}
spark breach
#

oh oki

quartz kindle
#

you did ```js
if(something);

spark breach
#

ooooh i see

#

so would it need to be like bot.on('message', message=>{ if(message.content.startsWith(PREFIX)) { (Lines of code) }

quartz kindle
#

thats one way to do it yes

restive furnace
#

i like keeo my commands in different files

quartz kindle
#

another way to do it would be to return if it does not start with prefix

#

for example

spark breach
#

I'm guessing you mean this with that if(!message.content.startsWith(PREFIX)) return;

quartz kindle
#

yes

spark breach
#

Ah ty πŸ˜„

#

ill try if it works then

quartz kindle
#

you deleted the line that creates the args variable

spark breach
#

oh yeah makes sense that it wouldn't work then xD

north hollow
#

i need help how to make a logs system for discord.js

quartz kindle
#

explain

#

what kind of logs, where/how?

spark breach
#

I am guessing I do need to add something here, and I think I can't leave it like how it was before

    if(!message.content.startsWith(PREFIX)) return;
    let args
    
    switch(args[0]) {
earnest phoenix
#

Oof

quartz kindle
#

you need to define args

#

what should args contain? what kind of data?

spark breach
#

I think how many arguments there are in a sentence

#

I think the first word is 0 the second is 1 and so on right?

quartz kindle
#

yes, then you need to define it as that

#

extracting the content from the message

#

like you were doing before

spark breach
#

oh oki

#

this is what I think should be right (which is probably wrong):

bot.on('message', message=>{
    if(!message.content.startsWith(PREFIX)) return;
    let args = message.content.substring.split(" ")

    switch(args[0]) {```
north hollow
#

i need help how to make (!warn [member] (optional reason))

earnest phoenix
#
        if (!message.member.hasPermission(["CREATE_INVITE"])) return message.channel.send("You dont permission to use this command");
        if(!message.guild.me.hasPermission("CREATE_INVITE")) return message.channel.send("I dont have permission to create Invites. Sorry");
        let age = args.slice(0);
        if (!age) return age = 0;
        let max_age = age[0];
        max_age = parseInt(max_age);
        let uses = args.slice(1);
        if (!uses) return uses = 0;
        let max_uses = uses[0];
        max_uses = parseInt(max_uses);

        message.channel.createInvite({ unique: true, maxAge: max_age, maxUses: max_uses }).then((invite) => {

            message.channel.send(
                "Your new invite link is: https://discord.gg/" + invite.code
            );
        }).catch(e => {
            message.channel.send("Oops, there is a error ! Please report to the dev `/esq-report <text>` !");
            return console.log(e);
        });

OUTPUT :

(node:136753) UnhandledPromiseRejectionWarning: RangeError: Invalid bitfield flag or number.

Pls help me, sad :((

woeful pollen
#

Ah

spark breach
#

I don't think you need the (see command line) twice, however I think that wouldn't fix it if (!message.member.hasPermission(["CREATE_INVITE"])) return message.channel.send("You dont permission to use this command"); if(!message.guild.me.hasPermission("CREATE_INVITE")) return message.channel.send("I dont have permission to create Invites. Sorry");

prime cliff
earnest phoenix
#

:0

#

thx my false

#

how i fix this

#

my bot are robed

prime cliff
#

Nice ads for sketchy server too

slender thistle
#

Are you SURE you didn't leak your bot's token anywhere

earnest phoenix
#

fuck fuck fuck

spark breach
#

go change your token if you didd

#

click on your bot

#

the tab 'bot'

#

and regenerate the token

earnest phoenix
#

ok i thanks

spark breach
#

This is what I want my args to contain:
how many arguments there are in a sentence
the first word is 0 the second is 1 and so on right?

this is what I have which doesn't work, could anyone help me and say what I need to change?

    if(!message.content.startsWith(PREFIX)) return;
    let args = message.content.substring.split(" ")

    switch(args[0]) {```
quartz kindle
#

it would help you a lot if you leaned some javascript basics

#

message.content is a string

#

strings have a substring function

#

its a function, not a property

#

something.property this is a property
something.function() this is a function

spark breach
#

ohh ok, Yeah I haven't used javascript aswell I am new to javascript

#

oh oki

wet iron
#

I need help

spark breach
#

Do you know what I need to change it to for it to work? xD

wet iron
#

and Im using the uptime robot to keep it up

#

but

#

everytime

#

It needs to install node

quartz kindle
#

what

wet iron
#

yea

spark breach
#

That is weird

wet iron
#

everytime

#

it just

#

in console

#

installing node

quartz kindle
#

do you have node in your dependencies?

#

in package.json

#

if so, remove it

wet iron
#

no

#

in dependencies nop

#

on start

quartz kindle
#

show your package.json, also show the logs that say its installing

wet iron
#
{
  "//1": "describes your app and its dependencies",
  "//2": "https://docs.npmjs.com/files/package.json",
  "//3": "updating this file will download and update your packages",
  "name": "Mari0",
  "version": "0.0.2",
  "description": "Discord bot Mari0!",
  "main": "index.js",
  "scripts": {
    "start": "node index.js"
  },
  "dependencies": {
    "@discordjs/opus": "^0.3.2",
    "discord.js": "^12.2.0",
    "dotenv": "^8.2.0",
    "express": "^4.17.1",
    "ffmpeg": "0.0.4",
    "ffmpeg-static": "^4.2.2",
    "fluent-ffmpeg": "^2.1.2",
    "moment": "^2.26.0",
    "opusscript": "0.0.7",
    "random-puppy": "^1.1.0",
    "ytdl-core": "^2.1.6"
  },
  "engines": {
    "node": "12.x"
  },
  "repository": {
    "url": "https://glitch.com/edit/#!/hello-express"
  },
  "license": "MIT",
  "keywords": [
    "node",
    "glitch",
    "express"
  ]
}
quartz kindle
#

looks fine, can you show your logs?

wet iron
#

the logs are too long

earnest phoenix
#

How can I pass my glitch project to Visual studio code

quartz kindle
#

looks fine

timber linden
#

Before I make my bot

quartz kindle
#

is that happening every time your uptimerobot pings? @wet iron

earnest phoenix
#

How can I pass my glitch project to Visual studio code
@earnest phoenix I don't want to use glitch anymore I want to move to another platform

timber linden
#

As I try to put it online

#

I have the auth token

quartz kindle
#

@earnest phoenix visual studio is just a code editor, not a hosting service

earnest phoenix
#

@earnest phoenix visual studio is just a code editor, not a hosting service
@quartz kindle i want to host my bot with heroku

wet iron
#

is that happening every time your uptimerobot pings? @wet iron
@quartz kindle I just see the bot offline, and then I check glitch and it says node installing, I check the uptimerobot and it says "Monitor down"

quartz kindle
#

your main bot file is named index.js?

wet iron
#

yes

quartz kindle
#

@earnest phoenix never used heroku but i think they use github no? so you would need to copy all your code files to your pc, then upload them to a github account

spark breach
#

Tim heroku does use github yes

timber linden
spark breach
quartz kindle
#

@wet iron so the logs basically just get stuck in "total install time"

#

and nothing ever happens?

timber linden
#

What's wrong with making my bot online?

wet iron
#

the bot boots

#

normaly

timber linden
#

Did I script it right tho?

quartz kindle
#

@timber linden that looks like a package.json file

timber linden
#

Not showing my token*

#

OHH it is

earnest phoenix
#

@quartz kindle heroku uses github

spark breach
#

tim do you know what I need to change for the args it to work? I've tried a few things they didn't work tho

quartz kindle
#

i do know yes, but you should learn and figure it out

#

what did you try?

spark breach
#

Oh ok

quartz kindle
#

@wet iron so the bot is working?

spark breach
#

lemme check again

#

let args = message.content.split(" ")- (either way this didn't work)

#

wait-

#

i didnt use a ';' aswell

timber linden
#

It still does not show online

quartz kindle
#

@timber linden package.json files are just control files, not actual code

wet iron
#

@wet iron so the bot is working?
@quartz kindle yes but then when i close the tab and leave it for the uptime robot to do its thing it never boots and when I open the glitch again it installs node again

timber linden
#

Ohh

quartz kindle
#

@wet iron so if you close glitch, it goes offline? and if you keep glitch open it stays online?

wet iron
#

yes

quartz kindle
#

if you keep glitch open for a long time, does it stay online all that time?

wet iron
#

and the uptime robot just says unsuccessful boot

#

like error 403

timber linden
#

Ugh

wet iron
#

yes its still online

timber linden
#

Discord.dev doesn't help

#

Not discord dev

#

The website I used tho

quartz kindle
#

well, then either something is wrong with glitch, or with uptime robot. without proper logs we cant know whats going on

#

try keeping it open to see if it ever crashes

wet iron
#

ok

timber linden
#

Might as well just quit this

quartz kindle
#

@timber linden are you trying to make a bot in your phone?

#

what tools are you using?

timber linden
#

I'm using

#

Spck editor

#

The app

#

It has type of files on it

quartz kindle
#

thats just a code editor, its not enough to run a bot

timber linden
#

Oh

#

Is there any mobile app

rapid dawn
#

My friend codes on his phone

#

repl

quartz kindle
#

if you want to actually code a proper bot, no

#

but there are some "bot maker" apps

#

with limited functionality

rapid dawn
#

bruh, trust me

#

you can use repl

timber linden
#

Oh

#

I used grasshopper to lesrn

quartz kindle
#

repl.it is an online micro-hosting service

timber linden
#

I'll try repl

quartz kindle
#

same as glitch and heroku

rapid dawn
#

yeah, and it works on phone

#

and has an IDE

quartz kindle
#

its an online app, so it works on any browser

#

doesnt save any file on your phone

timber linden
#

It works on phone

quartz kindle
#

its all online

timber linden
#

Ohh ye

#

It can tho

#

If I add it to my home screen

#

It saves

quartz kindle
#

i mean your coding files

#

your code is not saved in your phone

#

the code you write is kept in their platform

#

from where it also runs

timber linden
#

Oh.

quartz kindle
#

its kind of a google drive

#

but for coding

#

and running apps

timber linden
#

I'll be on PC later

quartz kindle
#

and websites

clever wing
timber linden
#

Well on the app

#

It has a run button

quartz kindle
#

which app

timber linden
#

Spck editor

#

But if I run it it says null

paper phoenix
#

i need help when i try this showing me message is not defined
@clever wing - bot probably contains your message.

quartz kindle
#

@timber linden i dont know anything about spck, but it looks like it runs browser javascript

timber linden
#

K

quartz kindle
#

javascript bots are usually run using node.js

#

which is a non-browser javascript interpreter/runtime

#

micro-hosting services such as repl.it, glitch and heroku have node.js built in

#

or you can also install node.js on your pc and run it from home

timber linden
#

When I'm on PC I can do this.

quartz kindle
#

but node.js doesnt work on phones afaik

mossy vine
#

dont they literally distribute android builds

quartz kindle
#

last time i checked it required rooted android

#

but idk, havent looked in years

hoary lily
#

I programmed my bot using Android Phone which is not rooted via termux

quartz kindle
#

last i heard, the termux method had issues with installing modules from npm

#

but if its fixed now, awesome

hoary lily
#

Yup yup gladly it's fixed

earnest phoenix
#

TIM

#

I managed to launch the bot without removing any .js, it was as easy as uploading it to github.com and with heroku hosting it

hoary lily
#

I use heroku too.

wet iron
#

@quartz kindle the bot is still online

#

it didnt crash

#

and the uptime robot says the bot is down

#

error code 403

lyric mountain
#

403 means forbidden

#

where are you getting the error?

slender thistle
#

Ping services are disallowed and blocked by Glitch now

wet iron
#

well frick

round garden
lyric mountain
#

did you get it from official top.gg docs?

slender thistle
#

"official" except not official

earnest phoenix
#

you're better off just manually making requests lol

round garden
#

it's just a fork

earnest phoenix
#

most of the libs are really trash, well the .net one is cause cough veld code

slender thistle
#

It's not official enough to be really relied on

#

dblapi.js is official

round garden
#

it's a fork of it

slender thistle
#

An outdated fork

summer torrent
#
quartz kindle
#

people fork stuff, make some minor changes, release it on npm then proceed to abandon it

#

most of npm is basically that

hushed jungle
#

Fork > add one line of code > ? > profit

round garden
#

profit from a fork?

#

huh lol

slender thistle
#

If it sounds attractive

quartz kindle
#

it gives you popularity points to have libs on npm

pure lion
#

How would I write an eval command?

timber linden
#

make me a bot for nothing.

#

and give me the token

earnest phoenix
#

I use heroku too.
@hoary lily what to do so that the bot does not disconnect you

sudden geyser
#

Ton what language.

pure lion
#

Ohshit

#

Discord.js

sudden geyser
#

That's not a language, but JS I can infer. Make a command like you usually would (if you have) and use JavaScript's eval() function and pass the user input. Make sure only people you trust (like yourself) can use it.

#

eval evaluates a string as js code

pure lion
#

Alright

sudden geyser
#

You should also take a look at the util module's inspect function. It'll help you in displaying the result.

round garden
#

What should I put the hostname as for my express server?

#

same with port

earnest phoenix
#

probably localhost

#

correct me if I'm wrong

round garden
#

your wrong

earnest phoenix
#

thanks

round garden
#

it needs to be an ip

spark breach
#

what is the common localhost ip?

#

You can try and use that one

round garden
#

it needs to be the IP of the vps right?

summer torrent
#

what is the common localhost ip?
127.0.0.1 iirc

spark breach
#

idk, i just saw something with localhost xD

#

ill read up to check

#

127.0.0.1 iirc
Yup that's the most common one

#

it needs to be the IP of the vps right?
Idk, probably I might be wrong tho

earnest phoenix
#

i dont understand these docs at ALL

zenith citrus
#

hello guys, can you help?
how to make a count of mentioned in the message?

for example, user1 hugs user2.
User1 hugged N times
User2 has been hugged N times

i`m new with coding, sorry for the stupid question
i use discord.js 12

#

how can i make count how many times the message author hugs users?
I tried to insert the count into my finished code, but it only takes into account the mentioned user.
Even if i dont mention anyone, the bot thinks i mention myself..
i tried differently, but my brain is already exploding.. 2 days i cant understand my mistakes Suicidekanna Suicidekanna Suicidekanna

lyric mountain
#

you'll need a database

zenith citrus
#

have it

#

dont laugh much, i try(

const Discord = module.require("discord.js");
const fs = require("fs");
const config = require(`../config.json`)
const hugs = require('../db.json');


module.exports.run = async (bot, message, args) => {
 let member = message.mentions.members.first() || message.guild.members.cache.get(args[0]) || message.member;
    let msg =
      member === message.member
        ? `${message.author} hugs everyone`
        : `${message.author} hugged ${member}`;
    let gif = [
      "IRUb7GTCaPU8E",
      "u9BxQbM5bxvwY",
      "3EJsCqoEiq6n6", 
    ];
    let selected = gif[Math.floor(Math.random() * gif.length)];
    
    let id = member.id || message.author.id
    let hugCount = hugs[id];
  
    if (!hugCount) {
      hugs[id] = 1;

    let embed = new Discord.MessageEmbed() 
    .setDescription(`${msg}`)
      .setColor("RANDOM")
      .setFooter(`${member.user.username} hugged for the first time.`) 
      .setImage(`https://media.giphy.com/media/${selected}/giphy.gif`);
      

      message.channel.send(embed);

    } else {
      hugCount = (hugs[id] = hugs[id] + 1);

      let embed = new Discord.MessageEmbed() 
      .setDescription(`**${msg}**`)
        .setColor("RANDOM")
        .setFooter(`${config.prefix}${module.exports.help.name} | ${member.user.username} has been hugged ${hugCount} times.`) 
        .setImage(`https://media.giphy.com/media/${selected}/giphy.gif`);
         
        message.channel.send(embed);
      return message.delete()
  }

fs.writeFileSync(
  "./db.json",
  JSON.stringify(hugs),
  (err) => console.log(err)
);

}

module.exports.help = {
  name: "hugg"
};
hushed jungle
#

How do you get such nice code blocks

lyric mountain
#

anyway, what's the expected output?

final swift
#

hello

hushed jungle
#

When we are on db is it possible to use SQL?

#

I googled it but could not find anything useful 😦

lyric mountain
#

errrr....what?

earnest phoenix
#

that doesnt even make sense, Database language is SQL

lyric mountain
#

no

#

SQL is a database language

#

but database language ain't SQL

earnest phoenix
#

yes there are more than one

hushed jungle
#

Use a SQL server I mean

zenith citrus
#

in general i managed to get a count of user mentions but i want to simultaneously get a count of messages from the message author
i changed let member to different values but it works adequately only all at once.. -_-

lyric mountain
#

there're 4 kinds of dbs (afaik): NoSQL, SQL, Non relational and JSON-based

#

latter is the worst possible db kind

slender thistle
#

There's no way to get a count of messages from a message author unless you save all messages in a DB

#

you can't fetch X user's messages separately

hushed jungle
#

Guess I need to phrase my questions better rereading it I understand the confusion

#

I am thinking about liteSQL or a normal SQL server but not sure what is better.

north hollow
#

i need help how to make a welcomer bot in discord.js

lyric mountain
#

all SQL-based dbs are SQLs

#

be it mySQL, SQLite, postgreSQL or whatever

hushed jungle
#

But SQlite is a different type of db right?

lyric mountain
#

yes, it's an embedded db

#

but still SQL

hushed jungle
#

I can host a SQL server on my domain but the bot generates a SQLlite server.

north hollow
#

i need help how to make a Server Greeting for discord.js

lyric mountain
#

SQLite IS the server on its own

hushed jungle
#

Everything is SQL except NoSQL

lyric mountain
#

sqlite is file-based, not service-based

#

Everything is SQL except NoSQL
@hushed jungle nosql IS sql

hushed jungle
#

Guess I have a lot of reading to do

#

But not 100%

lyric mountain
#

nosql stands for Not Only SQL

hushed jungle
#

It's partly SQL

lyric mountain
#

it's SQL+

north hollow
#

i need help how to make a Server Greeting for discord.js

zenith citrus
#

that is, i dont need change anything, just add another 1 json database file?.. (i have 200 iq, yes)

hushed jungle
#

I know what it stands for and understand it's SQL and then some extra

round garden
#

What is the IP that the vote is sent to on my VPS?

lyric mountain
#

anyway, back to original question

#

sqlite is file-based, you'll need some database manager to deal with it

#

sqlite studio is a great one

#

some ides also have built-in database managers

small prairie
#

Can args type be 2 different?
For example
type: "role"||"member"
??
discord.js commando

lyric mountain
#

arg type?

#

all args are strings

small prairie
#

Discord.js commando

lyric mountain
#

idk what d.js commando is

small prairie
#

Thought so

#

ignore me

lyric mountain
#

but you just need to check for both matches

#

literally found it on my first try

small prairie
#

Hey.
U dont know about this
this isnt what i am asking
Ignore me.

lyric mountain
#

if you say so...

round garden
#

How do I make the webhook?

lyric mountain
#

just note that the docs has everything you need, and not explaining your issue despite I stating that I don't know about d.js commando won't make your help appear from thin air

north hollow
#

i need help how to make a Server Greeting for discord.js

lyric mountain
#

@north hollow put your message inside a guildmemberjoin event

#

@round garden webhook for top.gg votes or normal discord webhooks?

round garden
#

votes

#

docs ain't useful at all

lyric mountain
#

have you setup a webserver (like express.js)?

round garden
#

What is the port and hostname?

#

yeah

lyric mountain
#

where is the bot hosted?

round garden
#

vps

lyric mountain
#

so it's http://yourip:port/endpoint

#

yourip would be your vps's ip

round garden
#

ok thanks

lyric mountain
#

the port will need to be forwarded to allow external connections

round garden
#

how do I do that?

lyric mountain
#

and the endpoint would be where dbl should attempt to connect to (default is dblwebhook)

#

sudo ufw allow PORT/tcp

round garden
#

windows 😭

lyric mountain
#

a windows vps?

#

go to firewall settings and allow the port there

round garden
#

ok thanks

lyric mountain
#

note that 80 and 8000 will mostly conflict with other stuff, so avoid those

round garden
#

is 42069 ok?

lyric mountain
#

probably

round garden
#

alright sweet

#

thank you

lyric mountain
#

yw

north hollow
#

@lyric mountain wtf is guildmemberjoin event and where is that

lyric mountain
#

it's guildMemberAdd actually

#

this will trigger whenever someone join the server

north hollow
#

o ok

#

@lyric mountain so like this

#
client.on('guildMemberAdd', member => {
  // Send the message to a designated channel on a server:
  const channel = member.guild.channels.cache.find(ch => ch.name === 'member-log');
  // Do nothing if the channel wasn't found on this server
  if (+channel) return;
  // Send the message, mentioning the member
  channel.send(`Welcome to the server, ${member}`);
});
#

@lyric mountain hello

earnest phoenix
#

try it

lyric mountain
earnest phoenix
#

how to restrict some commands to nsfw channels only?

quartz kindle
#

check if channel is nsfw

earnest phoenix
#

what

quartz kindle
#

most libraries should have a channel.nsfw property

earnest phoenix
#

Channels have a property of nsfw which is true or false

#

if(!message.channel.nsfw){ message.channel.send("This command can only be used in channels marked nsfw."); return; }

#

this is good?

#

how do i verify my bot?

#

yes

#

Verify for who?

#

my bot

quartz kindle
#

if you submitted your bot to top.gg you need to wait for it to be verified by the moderators

#

verification can take up to 2-3 weeks

earnest phoenix
#

nevermind i found

#
if (!message.channel.nsfw) return message.channel.send('TEXT')```
quartz kindle
#

literally the same thing lul

earnest phoenix
#

there u go

#

:)

digital oyster
#

Hii, I'm currently looking for a gif like this one(https://mrsheldon.me/files/785375.gif), but without the Discord application, only with this little sparkles. Is there something like that?

earnest phoenix
#
  1. I'm pretty sure that's trademarked/copyrighted or whatever(Don't take my word for it, I haven't been to law school)
  2. I don't believe that has anything to do with bot development. You should be asking that in #general or #memes-and-media probably
quartz kindle
#

you might find similar gifs if you google it, but that one was probably custom made for discord, so you wont find anything with those exact same sparkles

earnest phoenix
#

You could probably remake it with an HTML5 canvas

digital oyster
#

Well that's an Idea

#

Thx

round garden
#

@lyric mountain can I use dblapi.js to make the webhook?

loud hollow
#

Hey, I'm making my first bot, just trying to check if the user passed in from a command exists in the server or channel (doesn't matter which in this case, though server is preferable - code snippet gets members from channel).

The command looks like !win @username. It's getting to the correct if statement from the !win part of course, but I'm not sure how to check if @username is in the server.

Here's a code snippet of something I've tried, though I've spent about 4 hours trying various things to get the comparison to work. The arguments[0] is the @username part, a userID# from what I can tell. I've tried using a substring to get just the ID# from it, but no combination of that and the comparison methods I've tried have worked.

I'm available to hop into VC if that'd be easier, thanks for any help!

magic jackal
#

bro stop advertising

quartz kindle
#

@loud hollow you will need to fetch it as members are not guaranteed to be cached

#

unless you use the fetchAllMembers option

#

but thats a huge waste of resources and generally not recommended

#

also, for mentions its preferable to use message.mentions instead of parsing the id from message.content

#

unless you want to allow for both mention and id

white drum
#

Hey can anyone help me code a custom prefix thing, so people in any server can just user !prefix set (thierprefix) and it changes the prefix for their server on my bot

#

ping me if someone responds

round garden
#

can I use dblapi.js to make the webhook?

white drum
#

@earnest phoenix thx

knotty steeple
#

@earnest phoenix please dont tell people to watch random videos to spoonfeed lmao

slim hollow
#

can i write turkish?

lyric mountain
#

@lyric mountain can I use dblapi.js to make the webhook?
@round garden sorry for disappearing. No webhooks require a listening server to be setup

#

The farthest you can go with the lib is checking for user votes or posting server count

quartz kindle
#

you can, dblapi creates a webserver for you

round garden
#
const server = createServer((req, res) => {
  console.log(1)
})
server.listen(5000)``` How comes this isn't logging?
#

I'm port forwarding as well

quartz kindle
#

what is createServer?

#

thats not a built in function

round garden
#

import { createServer } from 'http'

quartz kindle
#

ah

#

is it a home computer or a vps?

round garden
#

home

quartz kindle
#

you may need to port forward port 5000 in your router/modem

round garden
#

damn I'll try it on my vps

indigo flax
#

how do u ban everyone with eval

#

java or python

#

im doing an experiement

#

in a test server

empty owl
#

Am I using .sort right?

  async getTopMargins() {
       let products = await apiFetch(this.apikey, "skyblock/bazaar")
       let array = Object.keys(products["products"]).map(i => products["products"][i]["quick_status"])
       let list = array.sort(function (a, b) {
           let aMargin = a.buyPrice*0.99 - a.sellPrice
           let bMargin = b.buyPrice*0.99 - a.sellPrice
           return bMargin - aMargin
       })
       console.log(list[0].buyPrice*0.99 - list[0].sellPrice)
       return list.splice(0, 5)
   }```

list[3].buyPrice*0.99 - list[3].sellPrice is higher than list[2]
indigo flax
#

um

#

@empty owl

#

thats not eval

quartz kindle
#

hes asking another question, not answering yours

indigo flax
#

can anyone answer mie

#

mine

quartz kindle
#

i dont use java nor python

#

i use javascript

#

so i cant help you

#

@empty owl you're comparing a with a, then b with a again, is that intended?

winged mulch
#
def start_server():

    listener = socket.socket()

    listener.bind(("192.168.1.124", 65))

    listener.listen()

    client, address = listener.accept()

    while True:
        data = client.recv(6000)
        print(data)
#

When I press the Test button on the webhook section of the page, this code doesn't receive anything. Would anyone know why?

brisk surge
#

@winged mulch you've bound to a private ip

winged mulch
#

I port fowarded though.

#

Its set to my public IP and its suppost to port foward

brisk surge
#

no, 192.168.0.0/16 is private

winged mulch
#

I have to set it to my public IP?

brisk surge
#

bind to 0.0.0.0 for all interfaces

#

or your public ip

empty owl
#

@quartz kindle huh

brisk surge
#

also you probably want an http server

#

rather than a raw tcp socket

empty owl
#

ioh shoot

#

ty

winged mulch
#

Thanks @brisk surge

brisk surge
#

np πŸ‘

winged mulch
#

Its saying it can't assign to the requested address.

#

Maybe I should try a diffrent port?

empty owl
#

@quartz kindle okay I fixed it

#
    async getTopMargins() {
        let products = await apiFetch(this.apikey, "skyblock/bazaar")
        let array = Object.keys(products["products"]).map(i => products["products"][i]["quick_status"])
        let list = array.sort(function (a, b) {
            let aMargin = a.buyPrice*0.99 - a.sellPrice
            let bMargin = b.buyPrice*0.99 - b.sellPrice
            return bMargin - aMargin
        })
        console.log(list[0].buyPrice*0.99 - list[0].sellPrice)
        return list.splice(0, 5)
    }```
#

is there anything wrong with this

north hollow
#

Look at my cable management

sudden geyser
#

table

north hollow
#

Ha

#

That it

winged mulch
#

@brisk surge I think I'm doing something wrong on top.gg because I can POST to it from inside my network using my external IP.

brisk surge
#

nae

#

your router will just route packets back in straight away

#

nat hairpinning

#

see if your port is actually open first

winged mulch
#

It is

brisk surge
#

through a site like canyouseeme

winged mulch
#

Ok

#

It says its open.

brisk surge
#

ok sick

#

send your code

winged mulch
#
def start_server():

    listener = socket.socket()

    listener.bind(("0.0.0.0", 165))

    listener.listen(6)

    client, address = listener.accept()

    while True:
        data = client.recv(6000)
        if data == None:
            return
        print(data)
round garden
twin pendant
#

is there any good reasons to upgrade from discord.js v11 to v12? i'd rather not have to change up things in my bot but if theres a good reason to do it i probably will

amber fractal
#

in a couple months v11 just wont work

twin pendant
#

oh damm ok

#

thanks

earnest phoenix
#

What is the rate limit for changing a voice channel's name?

#

rate limits are dynamic

#

they adapt to you if you spam the endpoint

#

however the current know ratelimit for that is 2/10min

#

@slender thistle once check ur dm sir

subtle osprey
#

ok hi

#

i need help with this thing

#

but it return undefined

earnest phoenix
#

k

winged kelp
#

Ummm so top.gg images working for anyone?

hoary lily
#

Uhm I think that's

const playingTime = client.voice.dispatcher.streamTime.fetch();
#

Maybe but wait for the real devs haha

halcyon ember
#

whats the easiest way to call a function inside another file

#

i was looking at another bot's code on github and it did process.directory.file.function() but it says undefined for me

earnest phoenix
#

from DiscordAPI.raincord import Discord

#

@winged mulch

#

Know about this

#

Module

winged mulch
#

@halcyon ember You want to call a function from another file?

halcyon ember
#

yea

winged mulch
#

Python?

halcyon ember
#

js

winged mulch
#

Oh sorry, I only know Python. I would assume you would use an import statement and treat the file like a package?

halcyon ember
#

i saw somebody do process.directory.file.function()

#

but that doesnt work

winged mulch
#

You might want to ask in one of their support servers.

#

@earnest phoenix You may have pinged the wrong person, I don't know anything about Javascript.

lusty quest
#

i think its enought to export the module

#

then call it in the file where you want to use the function

#
module.exports = function(owner) {
    ...
}
```as example
halcyon ember
#

huh

#

ill see

lusty quest
autumn summit
#

how do i make the display role members seperate from online members true using discord.py? my code: py server = ctx.message.server perms = discord.Permissions(display_role=True, allow-mentions=True) await client.create_role(server, name='thing', permissions=perms)

steel drum
#

@halcyon ember ive enver seen "process.directory.file.function()" but i have seen


// module.js

module.exports = {
  hi() {
    console.log("hi!");
  }
};

// file you want to import 

let { hi } = require('./module');

hi();
autumn summit
#

how do i make the display role members seperate from online members true using discord.py? my code: py server = ctx.message.server perms = discord.Permissions(display_role=True, allow-mentions=True) await client.create_role(server, name='thing', permissions=perms)

halcyon ember
#

oh ok

autumn summit
#

does anyone know the role settings

spark breach
#

Wdym with that?

autumn summit
#

like you know in role settings

#

there is the display members separate from online members

#

i have no idea how to call that

#

@spark breach

spark breach
#

Hmm, idk how to call that either sorry

autumn summit
#

ahh ok

earnest phoenix
#

hoisting

#

@earnest phoenix You may have pinged the wrong person, I don't know anything about Javascript.
@winged mulch it's an python

#

Dude

#

from DiscordAPI.raincord import Discord

#

These is module or library

#

U know this

soft wind
#

anyone know if image manipulation is possible with dsharpplus or discord.net?

devout wagon
#

The answer to this question is the same as to "is image manipulation possible with c#"

#

Which yes it is

soft wind
#

do you have an example of how i would start that i see canvas is used with discord.js but i havent seen any examples or even information on how to do so with discord.net or dsharpplus

devout wagon
#

Even though the focus is on resizing, they should all be capable of drawing and such

soft wind
#

awesome thank you

wide sage
#

hello, i'm learning js atm.. can anyone help me fix my mistake?

#
    {
        if (arguments.length == 0) { return receivedMessage.channel.send("Invalid")}
        const name = arguments;
        msc = malScraper.getInfoFromName(name)
       .then((data) => console.log(data))
       .catch((err) => console.log(err))
        receivedMessage.channel.send(msc)
    }``` i did this thing and the error i'm getting is ```Error: [Mal-Scraper]: Invalid name.
    at C:\Users\7thghoul\node_modules\mal-scraper\src\info.js:189:14
    at new Promise (<anonymous>)
    at Object.getInfoFromName (C:\Users\7thghoul\node_modules\mal-scraper\src\info.js:187:10)
    at anifoCommand (C:\Users\7thghoul\Documents\Syden\sydenii.js:32:26)
    at processCommand (C:\Users\7thghoul\Documents\Syden\sydenii.js:26:9)
    at Client.<anonymous> (C:\Users\7thghoul\Documents\Syden\sydenii.js:16:9)```
soft wind
#

hopefully i should be able to use this along side dsharpplus im trying to place 2 member avatars ontop of a single image

wide sage
#

it shows the data when the name is predefined

hoary lily
#

You forgot the semicolon on line: receivedMessage.channel.send haha

wide sage
#

You forgot the semicolon on line: receivedMessage.channel.send haha
i added that and still seeing the same error Error: [Mal-Scraper]: Invalid name. at C:\Users\7thghoul\node_modules\mal-scraper\src\info.js:189:14 at new Promise (<anonymous>) at Object.getInfoFromName (C:\Users\7thghoul\node_modules\mal-scraper\src\info.js:187:10) at anifoCommand (C:\Users\7thghoul\Documents\Syden\sydenii.js:32:26) at processCommand (C:\Users\7thghoul\Documents\Syden\sydenii.js:26:9) at Client.<anonymous> (C:\Users\7thghoul\Documents\Syden\sydenii.js:16:9)

hoary lily
#

Oh ok

wide sage
#

when i predefine the input

#

it shows this

#
    at RequestHandler.execute (C:\Users\7thghoul\node_modules\discord.js\src\rest\RequestHandler.js:170:25)```
#

is it because the output is too big?

hoary lily
#

Client.<anonymous>

#

try message.channel.send(msc)

wide sage
#

Client.<anonymous>
?

hoary lily
#

Nvm that I'm thinking hha

wide sage
#

no that wont work

#

i have set it like receivedMessage

hoary lily
#

Have you defined msc?

wide sage
#

yes

soft wind
#

Anyone know how to fix this with dsharpplus?

#

Says x doesnt exist in context in namespace

hoary lily
#

I'm confused demn

#

Hey certified devsss

#

Come'ere he needs help haahha

soft wind
#

Lol?

restive furnace
#

@soft wind i dont think you can nest functions with &&

#

using (func) in each function may help a bit

#

it might solve the error

soft wind
#

I'm not completely sure what you mean by that

restive furnace
#

i meant like this (x => ..) && (x => ..) || (x => ..) or something like that.

soft wind
#

I tried that it gave me same error :/

mossy vine
#

ok what

restive furnace
#

whats the error

#

oh yea

pale vessel
#

x => x == y || x.includes(t) works if you meant this

soft wind
#

I think I fixed it

#

Yes that's the fix like @pale vessel just pisted

#

Posted

#

Thank you

#

I was trying to define x each time

#

Now I'm off to figure out drawing with .net core gonna be fun panblush

coarse apex
#

Is there anyone here that can make bots in C# and you're good at it?

mossy vine
#

do you have a question or?

soft wind
#

it sent the embed then throws this

soft wind
#

@pale vessel any idea on this one?

wet iron
#

can someone help me?

#

I deployed my bot on heroku

#

and

#

it won't read the procfile which says worker: node bot.js

#

it just makes it as web

#

which leads to an error with port

#

cause there is no port

#
2020-06-17T09:29:29.631430+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-06-17T09:29:29.648404+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-06-17T09:29:29.730388+00:00 heroku[web.1]: Process exited with status 137
2020-06-17T09:29:29.769100+00:00 heroku[web.1]: State changed from starting to crashed
slender thistle
#

137 iirc says "not enough memory"

wet iron
#

I searched on the internet

#

and they said its cause that web start

#

dyno

#

with web: npm start

#

so I need a procfile which says worker: node bot.js

high geode
#

sry for ping

earnest phoenix
#

any idea how to make this badge system :

.addField('Badges', `${owner}\n ${nitrosubs}\n ${botowner} : '**No Badges**'`)``` to show No badges text when there is no badge
#

because right now if there is no badge userinfo not wokring

#

im broke

earnest phoenix
#

ternary operator easy

fleet mason
#

Well check if they have any badges if not type no badges

earnest phoenix
fleet mason
#

you could use condition ? true : false

earnest phoenix
#

@earnest phoenix Can you ask a more specific and more detailed question? Like what you mean by badges?

#

right now if you write wi-userinfo dont work because there is no badges option set

#

and i dont know how to set it

#

i have badges but for example if you write wi-userinfo , userinfo dont show because there is "No Badges" text

#

any idea?

#

@earnest phoenix

#

Still no clue what you mean by badges, but

#

Assuming that since you're using badges plural, you're talking about an array

#

i mean if there is no badge on profile

#

to say "No badges"

tight plinth
#

check if user has badge or not

earnest phoenix
#

You can do

.addField(badges.length ? `${owner}\n ${nitrosubs}\n ${botowner}` :  '**No Badges**')
tight plinth
#

lol

#

and wtf is bot owner

#

You can do

.addField(badges.length ? `${owner}\n ${nitrosubs}\n ${botowner}` :  '**No Badges**')

@earnest phoenix lol

earnest phoenix
#

who knows? Β―_(ツ)_/Β―

#

tried

tight plinth
#

but yea thats the idea

earnest phoenix
#

no working

#

It was in their example so I included it

tight plinth
#

show your code

earnest phoenix
#

@tight plinth its a badge

tight plinth
#

show your code

earnest phoenix
#

@tight plinth I have no idea what they're trying to do specifically, but I have a general idea of what their problem is based on their question

#
          .addField('Badges', `${owner}\n ${nitrosubs}\n ${botowner} : '**No Badges**'`)
#
  let owner = await db.fetch(`owner_${user.id}`) || "";
  let botowner = await db.fetch(`botowner_${user.id}`) || "";
  let nitrosubs = await db.fetch(`nitrosubs_${user.id}`) || "";
  let nothing = await db.fetch(`nothing_${user.id}`) || "";
  if(owner) owner = `${owner}`
  if(nitrosubs) nitrosubs = `${nitrosubs}`
  if(botowner) botowner = `${botowner}`
tight plinth
#

what the fuck

#

why

earnest phoenix
#

They want to list the badges if there are some, and if not, then they want it to print "No badges"

#

yes

#

but if i write that is not working

tight plinth
#

what the ufck are you doing

#

youre trying to fetch badges from a local db?

#

why

earnest phoenix
#

bruh

tight plinth
#

man

earnest phoenix
#

i just said

tight plinth
#

this sucks

earnest phoenix
#

How to make "No badges"

#

thing

#

thats al

#

l

tight plinth
#

erm

earnest phoenix
#

You should see the official discord.js support channels. They're hell. People ask about typeerrors

tight plinth
#

with your current code u cant lol

earnest phoenix
#

Okay, so I'm not really following at all anymore. I don't think that you should be storing a user's badges in a database

#

According to a quick google search, there is no way to learn of a user's badges through the discord API

pale vessel
#

i see people doing if (array.length) but i usually do if (array[0]) because it's shorter lul

white anvil
#

@earnest phoenix you can

#

just not all of them

earnest phoenix
#

@pale vessel do u r have rart? that only works if the first value of an array is a truthy value

#

such as [0, 1, 0, 0, 1, 1, 0, 0][0] would return false

#

because 0 is a falsey value

#

It's more uniform and reliable to use array.length

pale vessel
#

@pale vessel do u r have rart? that only works if the first value of an array is a truthy value
@earnest phoenix which is what i always need

#

so yeah

restive furnace
#

^

earnest phoenix
#

that's not universally true for every person, and is not good advice to give to use a method like that to determine whether an array has elements inside it

pale vessel
#

i didn't give any advice did i

earnest phoenix
#

Saying "I do x because it's easier" in a channel full of impressionable young devs is tantamount to advising it in general(bad wording, i know, but I hope the point still goes across)

pale vessel
#

i'll take it

restive furnace
#

i dont always use easiest methods tho, like in loops, nowdays i use for(let i = 0...) loop.

woeful pollen
#

Hey

#

Can you use a ban commands for hackban?

earnest phoenix
#

Care to elaborate on your issue?

restive furnace
#

try Date().now() also if still wont work try (new Date(Date.now()))

white anvil
#

@low orbit it has been 50 years since 1970

#

which is when Date.now() was 0

#

its a unix timestamp

#

yes because its unix

#

use new Date().toLocaleString()

earnest phoenix
#

fixed

quartz kindle
#

what do you want to do?

#

if you want to know how much time passed from one timestamp to another timestamp, you need to subtract them

#

why +?

#

i dont get it

#

if you have a stored timestamp, and want to know how much time has passed, then you do Date.now() - storedTimestamp

#

then your stored timestamp is wrong

#

or is not a timestamp

#

yeah thats not a timestamp

#

how are you storing that?

golden condor
quartz kindle
#

then you need to do this

#

Date.now() - (Date.now() - duration) or Date.now() + duration - Date.now()

#

i mean, depends what you want to use it for

#

the problem is

#

that wont work

#

you need a starting point

#

when the mute happened

#

it has to be a timestamp

#

ah

#

then this Date.now() - (timestamp + duration)

#

console log the timestamp

golden condor
#
import Eris from "eris"
import config from "./config"
const client = new Eris(config.token)```This is my code
#

I'm confused

quartz kindle
#

isnt it import Client from eris?

golden condor
#

iirc it's new Eris

#

Unless it's different in typescript

grizzled raven
#

show your code

#

wait no scratch that, use tumestampt.getTime()

quartz kindle
#

@low orbit thats a timestamp as a string, not as a number

golden condor
#

@quartz kindle Yeah Client worked, in js it was always new eris so

#

Β―_(ツ)_/Β―

quartz kindle
#

@golden condor the source code shows Eris as function

#

so you can use either client = new Eris.Client(opts) or client = Eris(opts)

#

the Eris version should work without the new keyword, because it returns an already instantiated client

#

@golden condor the reason new Eris works in js, is because js doesnt care if you use the new keyword on non-classes, while ts does care lmao

mental furnace
#

Does someone know a better IDE then glitch cause all my bots keep reinstalling the npm’s for no reason which means I have to start my bot manually which means it’s never online anymore

quartz kindle
#

i heard that glitch blocked uptimerobot

mental furnace
#

Wot

#

Since when?

#

Cause that’s new

quartz kindle
#

@low orbit now do the math from before, and it should give you the time difference correctly

mental furnace
#

Any other websites like uptimerobot that work for glitch?

quartz kindle
#

@low orbit then you're still doing something wrong

#

console.log all values

#

so it should work

#

unless your modlogs are still being saved as strings

#

wait

#

you're doing modlogs.time in one, and modlogs.timestamp in the other?

golden condor
#

Any other websites like uptimerobot that work for glitch?
@mental furnace status cake

mental furnace
#

Thx

#

Works for now....

pale vessel
#

ikr don't they recommended it

mental furnace
#

Idk but this didn’t make my bot go down immediately so that’s good

earnest phoenix
#

How to make my bot wait for user input?
Like the person does C!test and the bot asks Type your name bro

split hazel
#

They made a thread for it

quartz kindle
#

@earnest phoenix which library

#

here`s more info about the pinging block from glitch:

One of our big challenges is dealing with third-party services that ping Glitch to keep apps awake. Not all of these services are as reliable as we’d like, and sometimes when there are problems they can cause as much load on our systems as a malicious attack would. We’re not banning the use of pinging (or β€œuptime”) services on Glitch right now, and we’d like to not have to. So, if you use these services, disable or turn off any pinging services you don’t need or that aren’t absolutely necessary. (You definitely don’t need to ping more than once every 5 minutes or so β€” more than that just adds load to the system but doesn't make any difference for your app.)

digital ibex
#

hi, i have ```js
const eris = require('eris');

class Client extends eris.Client {
constructor(token, options) {
super(token, options);
}
test() {
console.log('e');
}
}
``` when i do client.test() is says its not a function, how can i fix this? im trying to learn classes again idk if this is wrong

cinder patio
#

what's client? an instance of your Client class?

digital ibex
#

just the normal eris client

cinder patio
#

That's why you get the error

earnest phoenix
#

how to make my bots status be PLaying SOMETHING

cinder patio
#

You need to instantiate the Client class you declared, not the eris class

digital ibex
#

oh

#

what would i define this client as?

#

like what it is this client?

cinder patio
#

The Client class you declared above has all the functionality of the eris.Client, plus the test function. Instead of doing client = new eris.Client() you would do client = new Client()

earnest phoenix
#
let prefix;
con.query(`SELECT * FROM data WHERE guildID = '${msg.guild.id}'`, (err, rows) => {

    if (err) throw err;

    if (rows.length < 1) prefix = bot.PREFIX;
    else prefix = rows[0].prefix;

});

console.log(prefix)
return;

Problem: prefix returns undefined.

digital ibex
#

oh right, ok

earnest phoenix
#

just to let you know, you can do client.user.setActivity("sometext"); to make your bot show up as Playing sometext

cinder patio
#

The callback function doesn't execute immediately, that's why it's called callback

#

You will have to put any code that uses the prefix variable inside the callback

earnest phoenix
#

can't i put the prefix into a variable and use that prefix in the rest of the code ?

digital ibex
#

so this is what i have as my client now, const client = new eris.Client(require('./config/passwords').token); and i need to change that to const client = new Client(require('./config/passwords').token); ?

cinder patio
#

no, because the rest of your code executes before the callback function

digital ibex
#

what do i define Client as? this is my index.js file btw

earnest phoenix
#

how can i make sure this happens first ?

cinder patio
#

Lost, you defined it in the code you gave above

class Something {}

const smth = new Something()
#

wolfy, put the code inside the callback function

earnest phoenix
#

okee, thanks πŸ˜„

digital ibex
#

they're in different files

cinder patio
#

Then export the class, then import it (Like any other object)

#
class A {}

module.exports = A;
// Then import it in another file

const TheAClass = require("..path to A class");

const a = new TheAClass()
digital ibex
#

oh right

#

i done js // class file module.exports = Client; and then in my index.js file i done js const Client = require('./classes/Client'); const client = new Client(); and in my eval command i done client.test() and it errors, same error

#

@cinder patio any ideas?

cinder patio
#

Do you use the client variable and not the eris one?

#

You need to provide a token as the first parameter as well

digital ibex
#

i use the client variable

#

oh yeah, i done that

#
const Client = require('./classes/Client');
const client = new Client(require('./config/passwords').token);
cinder patio
#

How do you access the client in the eval command?

digital ibex
#

parameters

#

even in the index.js file when i do client.test() right underneath where i define client

#

oh wait nvm, i fixed it

#

thanks for the help

#

hmm, why am i getting this error? Error: ENOENT: no such file or directory, scandir '../commands/'

earnest phoenix
#

you do not have a folder named commands

#

double check the spelling of folder

#

or maybe u wrote the path wrong

digital ibex
#

i do, the path is correct

#

all i did was add an extra . onto it

#

didn't change the spelling or anything

earnest phoenix
#

your code is inside a folder?
like, for example if your bot's file is inside a folder named bot :-
bot/folder1/test.js

#

is it something like this?

digital ibex
earnest phoenix
#

hmm

#

then therr is no folder inside commands

digital ibex
#

there is

earnest phoenix
#

acc to ur code, u r searching for another folder inaide commands folder

digital ibex
#

wym

pale vessel
#

try __dirname + "/../commands"

digital ibex
#

oki

pale vessel
#

lower cased, sorry

digital ibex
#

same error

earnest phoenix
#

van u send ur code once?

#

can*

digital ibex
#

oh wait, its Error: Cannot find module './commands/admin/eval.js'

#

where u wanna see?

pale vessel
#

didn't you put ../, not ./

digital ibex
#

yeah

pale vessel
#

delete that shit lol

#

@coral trellis

digital ibex
#

um

slender thistle
#

sigh

pale vessel
#

sigh

spark breach
#

if I use this i get an error let user = message.mentions.users.frst()
Let user = message.mentions.users.frst() || message.author;
^
TypeError: message.mentions.users.frst is not a function

#

Wait-

#

I spelled it wrong TvT

dreamy breach
#

There is no users mentions, only roles/channels/members

vale garden
#

yo

#

how do you make a command where

#

like after a command you can respond with normal words

#

i forgot what its called