#development

1 messages · Page 1505 of 1

earnest phoenix
#
    async def on_ready(self):
        print("Level Sys Loaded up")
        leaderboard.start()```
#

it's not working 😭

solemn leaf
#

What do you want

#

Just to cry about it

#

Use codeblock

earnest phoenix
#

codeblock?

#

self.leaderboard.start(ctx)

#

why does a leaderboard be a loop though

tawdry mica
#

Slowmode code!
module.exports = ({
name: "slowmode",
code: Set the channel slowmode to \$messages`
$slowmode[$channelID;$messages]

`
});
console.log('slowmode.js is working')

Types
module exports
dbd.js

#

How?

slender hamlet
#

I am very confused

#

what are you asking?

solemn leaf
#

Anyone got a distort command using canvas-js

mellow kelp
#

yeah whats the problem

solemn leaf
#

Can you walk me through it

#

Pls

mellow kelp
#

i mean its pretty straightforward

#

you create a canvas with createCanvas

#

you get its context with .getContext('2d')

solemn leaf
#

I meant the .draw image stuff

mellow kelp
#

for that you need an image

solemn leaf
#

Image can be anything

mellow kelp
#

you can use loadImage('url-or-image-path')

solemn leaf
#

Ik

#

The basics like loading image

mellow kelp
#

so um

#

whats your problem

solemn leaf
#

Just not like how to imagedraw

mellow kelp
#

ctx.drawImage(image, x, y, width, height)

solemn leaf
#

Yeah what should I do to get a good distort

mellow kelp
#

oh um

#

you probably need to use pixel data

#

havent done one, but shouldn't be too hard

solemn leaf
#

Ok

mellow kelp
#

use .getImageData()

#

it returns an array of numbers for the RGBA data of each pixel

#

you can modify it and use putImageData(data)

solemn leaf
#

1 sec

#

On phone

mellow kelp
#

k

solemn leaf
#

So

#
let image = await canvas.loadImage(URL);
            let Canvas = canvas.createCanvas(image.width, image.height);
            let ctx = Canvas.getContext("2d");
let imageData = ctx.getImageData;
#

@mellow kelp

mellow kelp
#

yea

solemn leaf
#

So

#

Ctx.getimagedata

mellow kelp
#

yeah

solemn leaf
#

There

#

Now?

mellow kelp
#

wait

mellow kelp
solemn leaf
#

No

#

I'm on my phine

mellow kelp
#

hmmkay

#

so you got your context

solemn leaf
#

Once done imma eval a file and write it

mellow kelp
#

and separately, the pixel data

#

ight?

solemn leaf
#

You want me to do 2

#

1 sec

mellow kelp
#

k

solemn leaf
#

There

mellow kelp
#

wat

solemn leaf
#

?

mellow kelp
#

nvm

#

anyways

#

getPixelData returns an array of numbers

solemn leaf
#

Bytes?

mellow kelp
#

nope

#

rbga values

solemn leaf
#

Ok

sacred trout
#

Is there anything like spotify dl?

mellow kelp
#

each 4 of them are the values for 1 pixel

solemn leaf
#

Okay

sacred trout
mellow kelp
#

so if you got 🟥🟩🟦 (Imagine those are red, green and blue pixels)

#

you would get something like

#

[255, 0, 0, 255, 0, 255, 0, 255, 0, 0, 255, 255]

solemn leaf
#

Ok

#

So

mellow kelp
#

so that's where you start from

solemn leaf
#

I need to do like

#

imageData[idx] = 0-255

mellow kelp
#

pretty sure that doesn't work

#

a pixel can have a value of 0-255

solemn leaf
#

?

mellow kelp
#

oh okay you meant any value between those

#

thought you said -255 lmao

solemn leaf
#

Oh

mellow kelp
#

but yeah you can do that

#

maybe map the array into a 2d array or something and work it out from there

solemn leaf
#

How

#

Array.map

mellow kelp
#

idk, use array.reduce

solemn leaf
#

O

mellow kelp
#

i'd say first group the numbers into arrays of 4

solemn leaf
#

For each?

mellow kelp
#

i mean something like

#

[[255, 0, 0, 255], [0, 255, 0, 255], [0, 0, 255, 255]]

#

then you could use the image's width to split the array into rows and map the thing

solemn leaf
#

What about shifting lines of an image

#

Maybe like glitch effect

mellow kelp
#

idk

#

after mapping the rows and stuff, you could "move" them

solemn leaf
#

Like mix the array

mellow kelp
#

maybe

#

you would have to work that out yourself

solemn leaf
#

I can

#

Just making the array I cant

#

Lol

mellow kelp
#

use Array.reduce

solemn leaf
#

let image = await canvas.loadImage(message.author.displayAvatarURL({format: "png"}));
let Canvas = canvas.createCanvas(image.width, image.height);
let ctx = Canvas.getContext("2d");
let imageData = ctx.getImageData;
console.log(imageData.reduce())

mellow kelp
#

um that's not how Array.reduce works

solemn leaf
#

Array.reduce(array)

mellow kelp
#

check this out

#

wait

#

thats spanish lmao

solemn leaf
#

Hard on mobile

mellow kelp
#

freakin google KEKW

solemn leaf
#

And I cant read Spanish only German and english

mellow kelp
#

yea

#

here it is

earnest phoenix
#

wait is there no german mozilla dev

#

i feel scammed

mellow kelp
#

cuz the url is still in spanish

earnest phoenix
#

KEKW im a dumbass

solemn leaf
#

Lol

#

El

#

So

#

Wait

#

What would acce thing be

#

It's hard to read on mobile

mellow kelp
#

you pass a function

#

that takes in 2-4 params

#

accumulator, current, index, and the array

#

you probably just need the first 3

#

you do stuff and return the accumulator in the function

#

and it'll return the final accumulator value after executing the function on every element

earnest phoenix
#

wait so .reduce basically is doing something to an array but having the last returned variable provided?

mellow kelp
#

like

#

you got an initial value

#

if it's not provided, it will be the first element of the array

#

then, the function you passed will be executed on every element of the array

#

and will result on the final accumulated value

#
const nums = [2, 5, 3, 6];

const total = nums.reduce((acc, num) => acc + num);

console.log(total); // 16
earnest phoenix
#

so you can basically do eval(\${array.join("+")}`)` without having to use eval

mellow kelp
#

you can do that

#

or lots of other stuff

solemn leaf
#

So

#

Wait

#

Why would Inneed this

mellow kelp
#

you could use it to group the pixels into an array of arrays of 4

solemn leaf
#

Ok

#

What would acc be

#

acc isn't a value or string

mellow kelp
#

you can set its initial value to an empty array

solemn leaf
#

Wha

mellow kelp
#

or you know what

#

just do it the old way

#

make an empty array and add the pixels in groups to it

solemn leaf
#

let grouped = Array.reduce(function (obj, item) return; });

#

@mellow kelp

#

That close

mellow kelp
#

um thats not how it works

solemn leaf
#

Ok

#

Got examples

solemn leaf
#

I didn't understand that

mellow kelp
#

you got an array of numbers

#

you use reduce on the array

#

passing a function that returns the accumulator plus the current number

#

the result is the final accumulated value

solemn leaf
#

so accumulated would be the new array

#

Whay

mellow kelp
#

accumulated is the number 16

#

it starts with the first element of the array, 2

#

and the function i passed adds each element to it

solemn leaf
#

First element on array is 0

mellow kelp
#

its 2

solemn leaf
#

Wa

mellow kelp
#

you're referring to the index

#

i mean the actual element

solemn leaf
#

Ok

mellow kelp
#

anyways i got to go

solemn leaf
#

K

odd stratus
#

Hello, does anyone know the Regex for how to allow Spotify links in this format too?: spotify:playlist:playlistID

earnest phoenix
earnest phoenix
pale vessel
blazing edge
#

Hii

#

Please help me

#

;p

#

P!p

earnest phoenix
#

whats the issue

pale vessel
#

life

odd stratus
#

None of the Regex's from online seem to work

pale vessel
#

only playlists or what

odd stratus
#

It supports albums and individual song links too but I'm only trying to do it with the playlist right now to see if it'd work

pale vessel
#

why regex

#

to make sure it's valid?

odd stratus
#

Ye

pale vessel
#

why not something like this ```js
const str = "spotify:playlist:playlistID";

str.match(/^spotify:(.+?):(.+)$/) ? str.replace("spotify", "https://open.spotify.com").split(":").join("/") : "invalid";

lyric mountain
#

That'll create https///open.spotify.com/playlist/playlistID

#

Gotta add https:// after the split

ancient nova
#

kinda offtopic but can you force kill or change other apps permission while it's running? (java)

urban pelican
slim void
#

These are vars people use for suggestions/logs etc. Any suggestions on what other vars I could add???

true ravine
#

People might want a separate name and tag variable for users? Other than that it looks good

boreal pewter
#

Does anyone know how to get the specific user who invited the bot? (discord.py preferably)

#

and does that require privileged intents

sacred trout
#

class fun(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    Reddit = praw.Reddit(client_id='bruh',
                         client_secret='hehe',
                         user_agent='hehe')

# meme

    @commands.command()
    async def meme(ctx, self, subred="memes"):

        subreddit = Reddit.subreddit(subred)
        all_subs = []
        top = subreddit.top(limit=50)

        for subbmission in top:
            all_subs.append(subbmission)

            random_sub = random.choice(all_subs)
            name = random_sub.title
            url = random_sub.url

            embed = discord.Embed(title=name)
            embed.set_image(url=url)

            await ctx.send(embed=embed)


def setup(bot):
    bot.add_cog(fun(bot))```
#

Command raised an exception: NameError: name 'Reddit' is not defined

boreal pewter
sacred trout
#

bruh

boreal pewter
#

wait actually?

sacred trout
#

is reddit even a module?

boreal pewter
#

lol it seems to be

sacred trout
#

it's praw

boreal pewter
#

or a class somebody wrote

#

its likely a module

sacred trout
#

nop3

boreal pewter
#

that u need to pip install

sacred trout
#

praw is a module

boreal pewter
#

yea w/e

#

but u still need to import Reddit from it

sacred trout
#

ll

#

lol

#

lemme try

#

NameError: name 'praw' is not defined

#

bruh

boreal pewter
#

dude

#

just figure ur imports

#

look at the docs

>>> import praw
>>> r = praw.Reddit(user_agent='my_cool_application')
>>> submissions = r.get_subreddit('opensource').get_hot(limit=5)
>>> [str(x) for x in submissions]
#

seems like ur code requires from praw import Reddit

#

and u need to pip install praw first

#

python -m pip install praw

#

gl hf

slender thistle
#

For fuck's sake

#

Put self.reddit = praw.Reddit(...)

#

Then use self.reddit

#

There, solved within seconds

boreal pewter
#

NameError: name 'praw' is not defined

slender thistle
#

Either that or he didn't import it

#
>>> import praw
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'praw'

>>> prew.asd
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'prew' is not defined
sacred trout
#
    @commands.command()
    @commands.has_permissions(kick_members=True)
    async def kick( ctx,self,member: discord.Member,*, reason=None):
        try:
            embed = discord.Embed(title=f"User Kicked!",colour=discord.Colour.green())
            embed.set_thumbnail(url=member.avatar_url)
            embed.add_field(name="**user Kicked**",value=f"**{member}**", inline=False)
            embed.add_field(name="**Kicked by**" ,value=f"**{ctx.author}**", inline=False)
            embed.add_field(name="**Reason:**",value=f"**{reason}**", inline=False)
            await ctx.send(embed=embed)
            await member.send(embed=embed)
        except:
            pass

        await member.kick(reason=reason)```
#

it's not sending the embed please help

#

please help

void vale
#

Hi. https://discord.com/developers/docs/topics/oauth2

const app = require('express')()
const axios = require('axios');
const oauth = require('axios-oauth-client');

app.get('/login', async (req, res) => {
    console.log(req.query.code)

    var data = {
        client_id: "id",
        client_secret: "secret",
        grant_type: "authorization_code",
        code: req.query.code,
        redirect_uri: "http://127.0.0.1:8081/login",
        scope: "identify"
    }
    var  headers = {
        'Content-Type': 'application/x-www-form-urlencoded'
    }

    var auth = await axios({
        method: 'post',
        url: 'https://discord.com/api/oauth2/token',
        data: data,
        headers: headers
    })
    console.log(auth)
})

app.listen(8081)
(node:7188) UnhandledPromiseRejectionWarning: Error: Request failed with status
code 400
pale vessel
#

Since that's an Asset by default

#

url=str(member.avatar_url)

sacred trout
#

bruh'

earnest phoenix
#

@void vale woah woah woah did you just send your oauth token

sacred trout
void vale
#

@earnest phoenix It's disposable

earnest phoenix
summer torrent
earnest phoenix
#

Thanks I guess

#

@earnest phoenix uh why are you not checking if the user has permission to do that

quartz kindle
#

you still didnt fix the deleteCount error?

earnest phoenix
#

that just means people using your bot to raid servers

#

@quartz kindle yea I figured it out

#

@earnest phoenix no you havent

#

the spelling is wrong

#

Bruh then how is my bot working?

#

Where?

#

line 15

#

bulkdelete

#

?

#

no

#

deletecount is written with a capital C

#

delete count?

#

No

rustic nova
#

it is lol

earnest phoenix
#

it is written like that in the screenshot

#

That’s just a old picture lol

#

ah k

#

also you should check if the user has permission to bulk delete

#

Ye, ik lol

#

But uh

#

you dont know how?

#

send the code for that

#

while i go have lunch

#

Like you found a buy one right?

#

Bug*

#

Ok

urban pelican
#

good how do i fix it ?? write to me: (node: 23880) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'fetch' of undefined

pale vessel
#

messages

#

Missing an s

urban pelican
#

aha

sacred trout
#

@pale vessel

earnest phoenix
#

@urban pelican that code is wrong btw

sacred trout
#
# class fun(commands.Cog):
#     def init(self, bot):
#         self.bot = bot

#     reddit = praw.Reddit(client_id='h',
#                          client_secret='h',
#                          user_agent='h')

# # meme

#     @commands.command()
#     async def meme(ctx, self, subred="memes"):

#         subreddit = reddit.subreddit(subred)
#         all_subs = []
#         top = subreddit.top(limit=50)

#         for subbmission in top:
#             all_subs.append(subbmission)

#         random_sub = random.choice(all_subs)
#         name = random_sub.title
#         url = random_sub.url

#         embed = discord.Embed(title=name)
#         embed.set_image(url=url)

#         await ctx.send(embed=embed)


# def setup(bot):
#     bot.add_cog(fun(bot))```
pale vessel
#

Why did you comment everything

earnest phoenix
#

you are fetching a single message then message.channel.bulkDelete(message)

sacred trout
#

ik

#

but help me fix it

#

reddit is not defiended

earnest phoenix
urban pelican
earnest phoenix
#

uhm... just bulkDelete everything?

earnest phoenix
urban pelican
earnest phoenix
#

You want the uh purge command or?

#

Lol

#

@earnest phoenix so the purge command coding?

#

yes

#

where you checked if the user has permission

sacred trout
#

@pale vessel discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'reddit' is not defined

urban pelican
#

?...

sacred trout
#
class fun(commands.Cog):
    def init(self, bot):
        self.bot = bot

    reddit = praw.Reddit(client_id='nothing',
                         client_secret='nothing,
                         user_agent='')

# meme

    @commands.command()
    async def meme(ctx, self, subred="memes"):

        subreddit = reddit.subreddit(subred)
        all_subs = []
        top = subreddit.top(limit=50)

        for subbmission in top:
            all_subs.append(subbmission)

        random_sub = random.choice(all_subs)
        name = random_sub.title
        url = random_sub.url

        embed = discord.Embed(title=name)
        embed.set_image(url=url)

        await ctx.send(embed=embed)


def setup(bot):
    bot.add_cog(fun(bot))
earnest phoenix
#

@earnest phoenix

sacred trout
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'reddit' is not defined

#

please help someone

pale vessel
#

Define reddit as self.reddit

earnest phoenix
pale vessel
earnest phoenix
#

@pale vessel since when did you know python

pale vessel
sacred trout
#

oh

earnest phoenix
#

It bully me a lot

sacred trout
#

i am changing from normal to cogs

earnest phoenix
#

@pale vessel yo there is no closing '

#

in client_secret

sacred trout
#

xtension 'cogs.fun' raised an error: NameError: name 'self' is not defined

#

E

earnest phoenix
#

So what’s the uh problem?

#

Code

cinder patio
#

the problem is that you don't know javascript and just type in random shit and expect it to work

#

you never define purgeEmbed

earnest phoenix
earnest phoenix
#
  1. ok where are you actually checking if the user has permission
#

@cinder patio well it does work bruh

rustic nova
#

look closely

earnest phoenix
#
  1. purgeEmbed is undefined
pale vessel
#

Close your client secret and check your indentation

#

You're coding in python, indentation matters

earnest phoenix
#

@rustic nova i dont get it

sacred trout
#

it is correct

earnest phoenix
sacred trout
#

lol

urban pelican
rustic nova
#

you forgot the l on channel

#

message.channe

pale vessel
#

why are you fetching messages

#

you can provide a number directly

earnest phoenix
#

main.js instead of index.js how is node . running the correct file Thonk

#

npm init -y puts the main file to index.js

cinder patio
#

he can change it from package.json

sacred trout
#
NameError: name 'self' is not defined```
#

see this @pale vessel

pale vessel
#

Show your code

urban pelican
#

so what should i do there is a bit of a mess 😄

sacred trout
#
class fun(commands.Cog):
    def __init__(self, client):
        self.client = client

    reddit = self.Reddit(client_id='',
                         client_secret='',
                         user_agent='')

# meme

    @commands.command()
    async def meme(ctx, self, subred="memes"):

        subreddit = reddit.subreddit(subred)
        all_subs = []
        top = subreddit.top(limit=50)

        for subbmission in top:
            all_subs.append(subbmission)

        random_sub = random.choice(all_subs)
        name = random_sub.title
        url = random_sub.url

        embed = discord.Embed(title=name)
        embed.set_image(url=url)

        await ctx.send(embed=embed)


def setup(bot):
    bot.add_cog(fun(bot))
pale vessel
#

Otherwise it can't access properties inside init

earnest phoenix
#

why does py use forced indentation

sacred trout
#

fun' object has no attribute 'Reddit'

pale vessel
#

It's the property you're assigning

#

self.reddit = ...

urban pelican
rustic nova
#

channe

earnest phoenix
#

@urban pelican you seriously didn't understand

#

Spoonfeeding

urban pelican
#

I'm sorry I'm a blind person here

earnest phoenix
#

And also wrong

rustic nova
#
#

re-read the docs

sacred trout
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'Reddit' is not defined

earnest phoenix
urban pelican
sacred trout
#

@pale vessel :9

#

😦

pale vessel
#

Did you put self.reddit = self.Reddit?

sacred trout
#

it shoud be self.reddit = praw.Reddit

#

right?

earnest phoenix
#

@urban pelican you should learn coding before trying to make a bot

sacred trout
teal egret
#

wait

#

nvm

pale vessel
#

That's why I'm asking

rustic nova
#

The code is wrong, even i can say so without any proper js knowledge

earnest phoenix
#

That' tho

pale vessel
#

It's probably praw.Reddit(), which is what you had

sacred trout
#

bruh it worked like this

earnest phoenix
sacred trout
#

when i didn't use cogs

urban pelican
rustic nova
#

nah js is nothing for me, maybe sometimes for tampermonkey stuff, but meh

sacred trout
#

i can't fix it @pale vessel

urban pelican
sacred trout
#
The bot is online.```
#

@flazpre

pale vessel
#

what's your new code

sacred trout
#

umm

#
import discord
from discord.ext import commands, tasks
import random
import datetime
import json
import os
import asyncio
import youtube_dl
import praw
from random import choices
from discord.voice_client import VoiceClient
from PIL import Image
from io import BytesIO
import functools
import itertools
import math
import youtube_dl
from async_timeout import timeout


class fun(commands.Cog):
    def __init__(self, client):
        self.client = client

        reddit = praw.Reddit(client_id='',
                             client_secret='',
                             user_agent='')

# meme

    @commands.command()
    async def meme(ctx, self, subred="memes"):

        subreddit = Reddit.subreddit(subred)
        all_subs = []
        top = subreddit.top(limit=50)

        for subbmission in top:
            all_subs.append(subbmission)

        random_sub = random.choice(all_subs)
        name = random_sub.title
        url = random_sub.url

        embed = discord.Embed(title=name)
        embed.set_image(url=url)

        await ctx.send(embed=embed)


def setup(bot):
    bot.add_cog(fun(bot))
``` cog
warped sphinx
#

i don't understand a thing 🙁 i am just 14

pale vessel
#

It's self.reddit = praw.Reddit(...)

sacred trout
#

lol me 13 xD

#

no

warped sphinx
#

bruh what

pale vessel
#

and inside the command, you use it as subreddit = self.reddit.subreddit(subred)

sacred trout
#

self.Reddit*

#

'Context' object has no attribute 'Reddit'

#

subreddit = self.Reddit.subreddit(subred)

#

@pale vessel it doesn't work

#

this is the error 'Context' object has no attribute 'Reddit'

eternal osprey
#
  if (message.content.startsWith(prefix + "setprofile")){
      let member = message.author
      const args2 = message.content.slice(prefix.length).slice(10).trim();
      const list = client.guilds.cache.get("734123033782124575"); fs.appendFileSync("./members.txt", message.author.username+ " " + args2 + "\n"); 
message.channel.send("**Your profile has been set!**"); 


    }
    if (message.content.startsWith(prefix + "profile")){
      allItems = fs
      .readFileSync("./members.txt", "utf8")
      .split("\n")
      .map((x) => x.split(/ +/));
      console.log(allItems)
        let filtered = allItems.filter((x) => x[0] === message.author.username);
        let final = filtered.map((x) => x[1]).join("\n");
        

      const exampleEmbed4 = new Discord.MessageEmbed()
      .setColor('RANDOM')
      .setAuthor('Server Moderator')
      .setFooter("Command created for your community!")
      .setDescription("**Your set user description: **" + final)
      .setThumbnail("https://media.giphy.com/media/phJ6eMRFYI6CQ/giphy.gif")
      message.channel.send(exampleEmbed4);  
    ``` if i use !profile it returns:
#

you see

#

how do i get all the text i put in?

rustic nova
#

loop through the rest of your args

eternal osprey
eternal osprey
rustic nova
#

No js experience, can't help lol

eternal osprey
#

i know i can loop usin map and foreach etc

rustic nova
#

i mean i don't have js experience lol

eternal osprey
#

owh

#

sorry my bad

true ravine
#

If you're getting your args as an array you can just use args.join(" ") to get one string from it

earnest phoenix
#

@eternal osprey wait how are you using the chrome console

eternal osprey
#

in vsc

earnest phoenix
#

but how

eternal osprey
#

by debugging...

earnest phoenix
#

you cant press buttons to collapse or expand in vsc

true ravine
eternal osprey
#

no

#

i just ran the bot

#

and went to debug console

true ravine
#

Ohhhh

#

I see

eternal osprey
#

why?

earnest phoenix
#

or node index.js

eternal osprey
eternal osprey
earnest phoenix
#

ahh

#

i get it

eternal osprey
#

node.js preview.

#

why?

earnest phoenix
#

because if you ran with node index.js them no debug session starts so no ooh buttons

eternal osprey
#

ooowh okay

earnest phoenix
#

ooh ye got it

eternal osprey
earnest phoenix
#

Hello.

#

@eternal osprey please stahp using a text file for database even for a test bot

#

I made an AI

#

ok

#

you made an ai

#

Could someone test it for me, or if I should continue developing?

#

it started an invasion of the planet

eternal osprey
#

Bruhhh

earnest phoenix
#

code, you created a 2d array, no?

#

wdym?

#

@earnest phoenix ?

earnest phoenix
eternal osprey
#

I created an image recognition api using python once.

pale vessel
#

That's crazy bro

eternal osprey
#

it really was a pain in my fucking ass.

earnest phoenix
#

python

silent cloud
#

What can I do if when I enter * image (Russian text) I get an error:

earnest phoenix
#

snakes cant use computers

#

you split by newline, returns an array
then you map the array to another split which turns it into an array of arrays, hence a 2d array

silent cloud
#
TypeError [ERR_UNESCAPED_CHARACTERS]: Request path contains unescaped characters
    at new ClientRequest (_http_client.js:148:13)
    at request (https.js:316:10)
    at /home/container/node_modules/node-fetch/lib/index.js:1438:15
    at new Promise (<anonymous>)
    at fetch (/home/container/node_modules/node-fetch/lib/index.js:1407:9)
    at Image.run (/home/container/src/commands/utility/image.js:27:21)
    at Image._run (/home/container/src/structures/Command.js:53:34)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async CommandHandler.run (/home/container/src/monitors/command.js:178:5)```
#

How i can fix it? Can i catch it?

#

If i get error it will write : use english text

earnest phoenix
#

@silent cloud send code

silent cloud
#

Kk give me sex

earnest phoenix
#

what

warped sphinx
#

he means seconds

earnest phoenix
#

I would give you hastebin

#

😳

rustic nova
#

kk give me sex

silent cloud
#

AHAHAHAHAHA

earnest phoenix
#

kk give me nitro

silent cloud
#

Ye ye second

#

Thats T9

warped sphinx
silent cloud
#

😂

earnest phoenix
#

@silent cloud ngl that code looks dope

silent cloud
#

It working

#

But if im writing *image russian text, i have error

hushed vale
#

can someone help me on hot to get economy type thing which is public and not centered to one guild

earnest phoenix
#

I TAKE THAT BACK

#

WHY ARE YOU USING BING

silent cloud
#

Good ask

#

Hahaha

#

I found that easily

#

How to make it on bing

#

And doesnt find on google

#

Idk how to do that

earnest phoenix
#

use duckduckgo

silent cloud
#

Nononono

earnest phoenix
#

and scrape it

silent cloud
#

Im so lazy to remake this

earnest phoenix
#

duckduckgo allows scraping and does not track you

#

google doesn't allow scraping of any kind

#

they will ip ban you

#

idk if the same goes for bing

#

id assume so

#

google doesnt allow scraping because the api is a 10000x better

#

and scraping sucks anyways

silent cloud
#

Wow wow wow

#

Ohhh, lets i try to see that

earnest phoenix
#

they don't allow scraping because robots dont care about ads and because they want you to go through the api

willow mirage
#

i think Hackerrank broke

earnest phoenix
#

robots cant fuck up advertisers

silent cloud
#

I cant find image api on delevopers google

earnest phoenix
#

@silent cloud its search

cinder patio
silent cloud
#

I see only maps

cinder patio
#

nvm what is the link to the problem

earnest phoenix
#

Learn how to work with databases ig

hushed vale
#

oof lemme just figure it myself

hushed vale
true ravine
#

I'm writing an API with express, and rather than manually requiring and useing each of my routes, I want to use a for loop to iterate though my routes folder and require them all, then dynamically route requests based on which route folder they should go to. I am currently trying to nest one app.use inside another to first find out what route is needed and then send the request to the right place. It gets to the right place, but none of my request listeners trigger anymore, so I'm assuming the original request doesn't get passed correctly when nesting use statements. What would be the proper way to go about this?

willow mirage
pale stump
#

hi

willow mirage
#

Hi

misty sigil
harsh blade
#
 
   const exampleEmbed = new Discord.RichEmbed()
                         ^

TypeError: Discord.RichEmbed is not a constructor
    at Client.<anonymous> (/home/container/src/index.js:164:26)
    at Client.emit (events.js:326:22)
    at Object.module.exports [as GUILD_MEMBER_ADD] (/home/container/node_modules/discord.js/src/client/websocket/handlers/GUILD_MEMBER_ADD.js:16:14)
    at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
    at WebSocketShard.onPacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
    at WebSocketShard.onMessage (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
    at WebSocket.onMessage (/home/container/node_modules/ws/lib/event-target.js:132:16)
    at WebSocket.emit (events.js:314:20)
    at Receiver.receiverOnMessage (/home/container/node_modules/ws/lib/websocket.js:825:20)
    at Receiver.emit (events.js:314:20)

I Believe i mispelled something but cant figure out wat

misty sigil
#

the google api isn’t that good

misty sigil
harsh blade
#

bruh lol

#

thanks

earnest phoenix
#

@true ravine make an array of required stuff then loop and use it

urban pelican
#

ah

true ravine
#

So do you mean use everything and not just the request route?

willow mirage
#

how i can remove a value from array

#
const a = [1, 2, 3]
// How to remove
// so a = [1, 3]
silent cloud
#

Hey guys

#

How i can do google image finding?

#

From this

willow mirage
#
const arr = [1, 2, 3, 4, 5]
const minNum = Math.min.apply(null, arr);
const min = arr.splice(minNum, 1);
// Why MinNum == 2
// Why arr = [1, 3, 4, 5]
// WHY THE FUCK
silent cloud
#

this.url = (query, nsfw) => `https://www.bing.com/images/search?q=${query}&view=detailv2&safeSearch=${nsfw ? "off" : "strict"}`;

misty sigil
summer torrent
pale vessel
silent cloud
#

I need to do google search from bing

#

Now it

#

this.url = (query, nsfw) => `https://www.bing.com/images/search?q=${query}&view=detailv2&safeSearch=${nsfw ? "off" : "strict"}`;

#

I need to do something like this

#

this.url = (query, nsfw) => `https://www.google.com/images/search?q=${query}&view=detailv2&safeSearch=${nsfw ? "off" : "strict"}`;

#

But it will work

sacred aurora
#

is it working?

earnest phoenix
#

spoonfeed Spoon-feeding

#

Check it click

true ravine
#

Clicked just to vibe

#

If you know what I mean

earnest phoenix
#

Lmao

#

I see

silent cloud
#

But i need google

sacred aurora
#

in js?

earnest phoenix
sacred aurora
#

i think u need pupeteer to scrape google images

#

the content is dynamic

#

i've try and i just got the thumbnail with quite mini size

wheat valve
earnest phoenix
sacred aurora
#

its supposed to be an image link

earnest phoenix
wheat valve
#

This is the part of the code it throws that error at, it used to work for a while but just noticed it doesn't anymore.

sacred aurora
#

try console log the avatar url

lament wadi
#

could someone send me a poll script?, node.js, I'm having problems

earnest phoenix
wheat valve
sacred aurora
#

thats the problem then

urban pelican
earnest phoenix
#

you aren't importing discord

#

like the error says

sacred aurora
#

did u already const Discord = require("discord.js")

#

eh is that the package name

urban pelican
#

?

sacred aurora
#

instead of passing Discord, just import it at the top of your code

#

u seems to be passing the discord var on command execute but its says that the Discord is undefined

urban pelican
#

and how do I fix it?

misty sigil
#

some whitenames, honestly, some greennames too

lament wadi
#

could someone send me a poll script?, node.js, I'm having problems, pls help me

misty sigil
umbral zealot
#

pretty sure we've been through this a few times

#

you can't do that without a database.

#

so what the heck is deleteIds then, why is it there

#

Oh geeze, that's not very clear. alright

#

so... why not just use args[1] then

#

that would be the second argument

#

because message.guild.channels.cache.delete(msgArgs[0]) ?

#

why is that msgArgs and not args ?

#

Also it's message.guild.channels.delete() I'm pretty sure of that

cinder patio
#

also it should be just channels.delete

umbral zealot
#

what, no

#

This is a very simple thing you should know how to do, if you knew javascript. We are not in the habit of spoonfeeding and handholding people through simple tasks.

quartz kindle
cinder patio
#

currying

umbral zealot
#

Actually currying is a super great feature, I rarely use it but when I do I'm really glad it's a thing.

cinder patio
#

same

misty sigil
sudden olive
#

Hello can anyone tell which app use for creating commands in android

coral smelt
#

what methods are there to let my bot get my tweets

misty sigil
#

wdym by get your tweets

coral smelt
#

Example mee6 announces when I make a new tweet

misty sigil
#

I assume they use the Twitter api

coral smelt
#

DUDE IM SO DUMB I FORGOT ABOUT THE FUCKING TWOTTER API

umbral zealot
coral smelt
#

I was trying to do this shit through RSS feeds lmao

coral smelt
umbral zealot
#

Mine's Twatter actually. ayy

coral smelt
umbral zealot
#

Not really, but ok.

coral smelt
sudden olive
#

Hello

#

Please tell me

#

Which app use for creating commands in Qndroid

#

Android

umbral zealot
#

You can use BDFD but it's going to give you a crappy result.

#

It's also not "development", it's just pressing buttons and writing pseudo-logic.

sudden olive
#

Any other app best for creating commands

misty sigil
umbral zealot
#

BDFD is the only app that can create commands

misty sigil
boreal pewter
#

Anyone knows how to send a DM to the user who invited the bot. on server join?

umbral zealot
#

Anything else you need to actually learn a programming language and, ideally, you need to be programming on PC.

misty sigil
#

but you could just pull a voltrex

sudden olive
quartz kindle
umbral zealot
#

Then maybe don't try to make bots until you do, really.

boreal pewter
sudden olive
umbral zealot
#

You can write code in many ways but on a tiny-ass mobile screen it's going to be crap anyway

misty sigil
#

those are git sites

umbral zealot
#

Coding on mobile is horrible, don't do it
Mobile devices like your handheld phone are not appropriate devices to create code. Phones:

  • Are way too small. You can't see the whole line, or it's too small, or you scroll for days. Your eyes will suffer from this.
  • Don't have a proper keyboard. Yeah there's a "hacker keyboard" but it's still going to be a painful endeavour to write proper syntax.
  • Have horrible editors. There's some crap IDEs out there but they barely function to a level that's useful.
  • Can't run a lot of bot code, and it's hard to do that in the first place. You can't run databases, sqlite, ffmpeg, canvas, or anything requiring more than core javascript. And running Termux is a pain in the ass, and it can't access your files (or your editor can't access the termux storage) without some intense technical gymnastics. That's if you have an Android, not an Apple phone, which can't even get that far.
  • Getting help is hard because nobody wants to see your damn badly cropped screenshot showing your 25 facebook notifications from your mom inviting you to play farmville, or your 9% battery charge.
  • Can't easily interact with online services like github to save/manage your code or upload it to your host.

If you really think you can code on a phone, you are horribly insane. That's your prerogative, but don't drag us into your insanity, we don't want anything to do with it.
getapc nomobile

misty sigil
#

HOLY FECK

earnest phoenix
#

you can fetch the audit logs, but as Tim said, it's not reliable

misty sigil
#

don’t show that to voltrex lmao

umbral zealot
#

Ok. So you have a larger screen. That's 1 of 6 problems.

sudden olive
umbral zealot
#

No you still have the other 5 problems and we can't help you with those.

sudden olive
#

😩

earnest phoenix
#

a tablet is not as powerful as a machine, ARM can't verse a proper x64/x86 cpu

you're trying to race a sports car with a tractor

umbral zealot
#

Use an online IDE like repl.it or whatever, but don't ask us to help you when it craps out.

#

Or send us screenshots where half the screen is your keyboard.

earnest phoenix
#

Getting help is hard because nobody wants to see your damn badly cropped screenshot showing your 25 facebook notifications from your mom inviting you to play farmville, or your 9% battery charge.
LMAO

sudden olive
#

Can i coding from My Friends laptop

misty sigil
umbral zealot
#

Sure, of course, absolutely.

sudden olive
earnest phoenix
umbral zealot
#

Dunno I don't write python.

sudden olive
lusty quest
#

Apple did some crazy stuff on ARM tbh

earnest phoenix
#

i mean sure

misty sigil
#

But that’s only on MacBooks

sudden olive
#

Bcz today i watch stream in this server

lusty quest
#

there are also ARM powered Servers

earnest phoenix
#

Can anyone forceban in v12, sorry for bad english 😄

#

mac mini does wonders with ARM

but it still can't compete with traditional arch cpus

lusty quest
#

wait 2-3 generations

sudden olive
#

in stream he Editing files which created with java script language

willow mirage
#

smh

#

pls anyone help me

umbral zealot
#

I mean

#

Your code's too slow.

there I helped

earnest phoenix
willow mirage
#

thx but that i know too, @umbral zealot

#

i mean the way to optimize it

#

i don't have any idea to optimize it

umbral zealot
#

I'm actually not sure that can really be optimized

#

Maybe with a reduce() ?

willow mirage
#

nope wait imma tell ya

sudden olive
umbral zealot
#

seriously

#

we're having a conversation here

sudden olive
#

i need one help

#

Only

true ravine
#

Be patient

willow mirage
#
//you have an array
[1, 3, 6, 9, 10]
// You have to find the most smallest diffrent between them
// SO [9, 10]
// Becuase 10 - 9 == 1
sudden olive
#

About bdfd

willow mirage
#

and my brain just ded

umbral zealot
#

This is #development not #buttonmashing , we can't help you with bdfd.

sudden olive
#

How can i Get Umlimted hosting time for bot

willow mirage
#

by paying

#

for vps

umbral zealot
#

Paying money.

willow mirage
#

@umbral zealot any idea ?

#

me just ded

umbral zealot
#

the most smallest diffrent between them who even wrote this 😂

willow mirage
#

smh

#

my english

sudden olive
#

And how other bots online daily

#

Can u tell

umbral zealot
#

Literally they pay to be online that's how it works.

lusty quest
#

or own something like a Raspberry Pi / Nas at home

sudden olive
lusty quest
#

nvm then

umbral zealot
#

local hardware still "costs" just different costs.

true ravine
#

I can feel my brain imploding watching this discussion lol

sudden olive
#

Your bot link can u send me in dm

slender thistle
#

diff = 0
loop i from 0 to arr.length - 1
if diff > abs(arr[i] - arr[i + 1])
diff = abs(arr[i] - arr[i + 1])

umbral zealot
#

What is that, like, homework or an employment test? lol

willow mirage
#

@sudden olive ???

#

@umbral zealot ye

misty sigil
#

shiv fast

willow mirage
#

Homework

slender thistle
#

Pseudocode and general logic, the rest is up to you to figure out @willow mirage

sudden olive
#

You have any bot

umbral zealot
#

smh asking us to help with your homework

earnest phoenix
#

solve my homework for me 🥺

misty sigil
#

ok

slender thistle
#

How come

sudden olive
willow mirage
#

cuz the number can be [0, 9, 1, 10]

#

they are not after each other

#

@sudden olive Yes i do

earnest phoenix
#

@sudden olive for the love of god stop being annoying and asking unrelated questions, if you want to talk go to #general

sudden olive
#

diff = 0 loop i from 0 to arr.length - 1 if diff > abs(arr[i] - arr[i + 1]) diff = abs(arr[i] - arr[i + 1])

willow mirage
sudden olive
slender thistle
#
>>> l = [0,3,10,20,60]
>>> for i in range(0, len(l) - 1):
...     if i == 0:
...             diff = abs(l[i] - l[i + 1])
...     if abs(l[i] - l[i + 1]) < diff:
...             diff = abs(l[i] - l[i + 1])
...
>>> diff
3
#

#stupidbutworks

slender hamlet
#

lmao

#

i didnt even realize it was py until now im an idiot

slender thistle
#

Actually let me do that a bit better

slender hamlet
#

wait so is this to get the min difference between array elems?

slender thistle
#

Mhm

#
>>> l = [0,10,5,60,120]
>>> diff = abs(l[0] - l[1])
>>> diff
10
>>> for i in range(0, len(l) - 1):
...     if abs(l[i] - l[i + 1]) < diff:
...             diff = abs(l[i] - l[i + 1])
...
>>> diff
5
#

There we go

slender hamlet
#

that works too

#

i was gonna suggest combining the if conditions if you don't want to initialize diff

#

but yeah this is good

slender thistle
harsh blade
#
/home/container/src/index.js:163
  .setTitle("Welcome");
  ^

SyntaxError: Unexpected token '.'
#

Any ideas?

slender hamlet
#

could you give more code, possibly?

#

I think you might have ended the new Discord.messageEmbed() with a semicolon is my guess with this much code

umbral zealot
#

That would also be my guess.

harsh blade
#
client.on('guildMemberAdd', async newMember => {
let a = client.channels.cache.get("765885272092180483");
  let embed = new Discord.RichEmbed();
  .setTitle("Welcome");
  .setAuthor(`${member.user.tag} Has Joined.`, member.user.displayAvatarURL,);
  .setThumbnail(member.user.displayAvatarURL);
  .addField('Date Joined', member.user.createdAt, true);
  .addField('Total Members', member.guild.memberCount, true);
slender hamlet
#

Yep.

harsh blade
#

thats the code

slender hamlet
#

remove the semicolon after new Discord.RichEmbed()

#

with that semicolon, you're telling the computer to end that line of the conversation

harsh blade
#

oh

slender hamlet
#

but you're setting its properties below

harsh blade
#

bruh

slender hamlet
#

so you wanna remove all semicolons until the last one

harsh blade
#

last one would be the line which sends the embed?

slender hamlet
#

the Total Members field is the last field, so it will be the one with the semicolon

harsh blade
#

Alright

#

and i send that embed by
a.send(embed);

pure lion
#

if a is a channel then yes

slender hamlet
#

where a is a valid channel

#

yeah

harsh blade
#

Alr

pure lion
#

you might want to check if a is invalid

#
if (!a) {
  // do something if it can't get the channel
} else {
  // it got the channel so send the embed
}```
slender hamlet
#

might also wanna try like if (!a || typeof(a) != Discord.Channel)

harsh blade
cinder patio
#

typeof returns a string

#

and it only returns "object" for complex types

harsh blade
slender hamlet
#

pretty sure its Discord.messageEmbed()

subtle holly
#

hello

slender hamlet
#

richEmbed might be v11

#

v12 changed it i think

umbral zealot
#

yes, it's MessageEmbed in v12

crimson vapor
#

Any reason they changed it?

slender hamlet
#

no clue personally, maybe evie knows

umbral zealot
#

¯_(ツ)_/¯

#

Lotsa random breaking changes in v12

slender hamlet
#

yeah rip

cinder patio
#

MessageEmbed was a thing before v12, but it was used for embeds in already sent messages, while RichEmbed was used only to make embeds

#

I think

slender hamlet
#

luckily my bot wasnt dependent on v12 changed stuff until after v12 came out

harsh blade
#

bruh

sacred aurora
#

capital M bruh

sudden geyser
#

that's one difficult screenshot to read

sacred aurora
#

isn't it with a capital M?

#

Eh

sudden geyser
#

yes it is

sacred aurora
#

so it is working now @harsh blade

#

?

harsh blade
#

no its not

sacred aurora
#

oof

#

now what

harsh blade
#

capital M?

sacred aurora
#

yeah

#

MessageEmbed

distant wren
#

whats the best database shit

sacred aurora
#

try mongodb

harsh blade
#

bruhhhh

#

did member change too in v12

umbral zealot
#

no

#

You still have to define variables you want to use, that's a JavaScript requirement, it has nothing to do with discord.js

slender hamlet
#

notice anything?

harsh blade
#

wait

#

i didnt set member?

#

hold on

#

no i did?

slender hamlet
#

what parameter are you supplying the callback with?

slender hamlet
#

what is the name of the variable that you give the function that is called when guildMemberAdd fires off

#

here, let me explain

harsh blade
#

newMember?

slender hamlet
#

yes

#

that is the member that joined

harsh blade
#

i just replace the (member) with newMember

slender hamlet
#

or vice versa

harsh blade
#

right

#

tysm

slender hamlet
#

np

willow mirage
#

what is faster .some or .every

slender hamlet
#

doesnt it depend on your use case?

quartz kindle
#

most likely some

slender hamlet
#

some is probably faster, but its kind of apples to oranges

#

only slightly

quartz kindle
#

some should stop and return at the first positive result, while every continues until it finds all positive results or reaches the end of the dataset

slender hamlet
#

yeah

quartz kindle
#

assuming both are optimized enough

slender hamlet
#

so they aren't exactly the same

quartz kindle
#

a micro-optimized for loop beats both tho

slender hamlet
#

i think if you're split between some and every, just find the one that better matches your criteria for the task

#

the speed of each should be trivial as long as its not a massive array

quartz kindle
#

ye

true ravine
#

Could somebody suggest a way of fixing this abomination in my API code - I have tried the obvious for-looping but it doesn't work because it's all promises and stuff (I only just started learning how express and stuff works)

cinder patio
#

Use fs to get all files from the ./api/routes folder

slender hamlet
#

yeah

#

fs.readdirsync should do

true ravine
#

Yeah I set up a for loop to loop through routes and require them all, but you can't do that for the app.use if I understand correctly (or maybe I just did it wrong)

quartz kindle
#
fs.readdirSync("./api/routes").forEach(route => {
  app.use(`./${route}`, require(`./api/routes/${route}`))
})
slender hamlet
#

you could use a method similar to how discord command loaders work

#

yep, tim's gotcha

true ravine
#

Yeah that's similar to what I did except I just used for not foreach

true ravine
slender hamlet
#

alrighty

#

so

#

essentially, there are three parts

#

the reading of the directory

#

the parsing of the file

#

and the loading of the file

#

first, fs.readdirSync is a way to synchronously read the files in a directory

true ravine
#
bot.commands = new Discord.Collection()
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for(const file of commandFiles){
    const command = require(`./commands/${file}`);
    bot.commands.set(command.name, command)
}

I put this into my bot code pretty early on when I was making my bot (got it off the internet I must admit) and just left it because it worked

slender hamlet
#

line 1 - so here, we add a new property to the Discord.client (bot) which is an empty collection

#

line 2 - we are reading the ./commands directory, filtering out any non .js files; this should work assuming you do not have any .js files in there that aren't commands. we take the object returned and put it in a variable called commandFiles

#

line 3 - we iterate over the object in commandFiles, with file representing the element it is currently at

pale vessel
true ravine
#

I understand the reading of it, I just don't understand how collections work because I've only come across things like arrays and dictionaries etc

slender hamlet
#

ah, ok

pale vessel
#

Collections are just extended maps

slender hamlet
#

its like a map but better

#

fancier

slender hamlet
true ravine
#

So are maps like an array of objects?

slender hamlet
#

maps are like arrays, if you could set custom indexes

true ravine
#

Ah I see

slender hamlet
#

array[0] is based on zero indexing

#

if you could do array["mypropertyname"] thats what maps are essentially

#

kind of like python dictionaries

true ravine
#

In one of the methods I tried it successfully got the right file for the right request, but the file didn't get any request data so it's as if the call was closed too soon

slender hamlet
#

except you'd not go array["mypropertyname"] you'd go collection.get("mypropertyname")

pale vessel
#

Maps are more like objects

slender hamlet
#

yeah

pale vessel
#

Collections are extended maps that have array methods

#

e.g. reduce(), forEach(), map(), etc

slender hamlet
#

that's odd

true ravine
#

I put a console log in the file and it logged, but I think it was because I nested one app.use inside another

#

But I needed the first app.use to find out what route the request was for

slender hamlet
#

ok, first, see if tim's example fixes this

#

it could potentially have to do with for vs foreach, but this is just a guess

#

if not, we might have to investigate further

true ravine
#

Give me a minute I've got the application stuck running lol

slender hamlet
#

no problem

true ravine
#

I commented out my old code and added tims directly, however it just goes to my 404 case

#

Oh wait hang on

#

I'm assuming the callback from foreach gives the filename with extension and not just the filename right?

#

Ah yes it does I've fixed that though

#

Yeah it still goes to 404

#

I logged the foreach to check it runs and it does

willow mirage
#

@quartz kindle i need help

#
function stringAnagram(b, q) {
    const a = (s) => {
        let a = 0;
        b.some(i => {
            if(i.length == s.length){
                const r = i.split("")
                r.every(a => s.includes(a))?a++:null
            }
        })
        return a;
    }
    const n=[];
    q.every(e=>n.push(a(e, b)))
    return n;
}

I have to optimize this

true ravine
#

With a bit of tweaking using Tim's code as the base, I managed to get it working, thank you all for your help <3

#
fs.readdirSync("./api/routes").forEach(route => {
    app.use(`/${route.slice(0,route.length-3)}`,require(`./api/routes/${route}`))
})

Really wasn't much tweaking at all - in my method I required all my files first and then used an event to spin up the correct file, but that's clearly not the correct way to do it

#

Thanks again :)

pale vessel
#

you can omit route.length and use -3

true ravine
#

Oh really I thought that was only a thing in python

#

Thanks

quartz kindle
willow mirage
#

b = dictionary

#

q = queries

#

so

#

it searchs

quartz kindle
#

dictionary as in, an array?

willow mirage
#

yes

quartz kindle
#

and queries are also arrays?

willow mirage
#

yes

#

I made the code

#

but too slow

quartz kindle
#

neither .some nor .every are needed here

willow mirage
#

how . . .

quartz kindle
#

you dont use them for looping

#

if you want to loop you use forEach, or a for loop

#

.some and .every return booleans to know if their respective tests pass or not

willow mirage
#

yes

#

i have to return how many matches

quartz kindle
#

you're not using the return value anywhere

willow mirage
#

wdym?

#

the a() return how many matches

quartz kindle
#
let exists = array.some(a => a === "abc") // exists is true if one item in the array is equal to abc
let all = array.every(a => a === "abc") // all is true if all items in the array are equal to abc
willow mirage
#

btw if i name those variable to a, b does it will make code faster?

quartz kindle
#

no

willow mirage
#

oh

pale vessel
willow mirage
#

So how i can optimize it now?

quartz kindle
#

.some and .every are like .find and .filter, you only use them if you need the value that they return

willow mirage
#

ok

quartz kindle
#

otherwise use forEach or for

willow mirage
#

ok

#

but i tried

#

it is still slow

#

Like im trying to not use loops

#

but it is still slow

quartz kindle
#
function stringAnagram(data, queries) {
  return queries.map(query => {
    let a = 0;
    for(let item of data) {
      if(item.length === query.length) {
        let r = item.split("");
        if(r.every(letter => query.includes(letter))) {
          a++
        }
      }
    }
    return a;
  });
}
#

something like this makes more sense

#

it wont be necessarily much faster, because its still loops inside loops

willow mirage
#

hmmm

#

ok

#

but i think it won't be faster or just a little bit faster

#

but lemme try

digital ibex
#

im not sending it multiple times

#

its whenever i send a request to my api, the text in the input is still there

willow mirage
#

bruh the text format

pale vessel
#

beautiful

digital ibex
#

so, i added a if (client.nick !== nickname) { but it still repeats, any ideas? nickname is req.body.whatever, and client.nick is my bots nickname before getting changed

#

any ideas?

#

i didnt realise i said any ideas so many times lol

slender hamlet
#

alr im back

slender hamlet
#

just to be clear

digital ibex
#

it sends the message twice

#

like if the message was "hello"

#

it'll say "hello" twice as separate messages

slender hamlet
#

ah theres a much easier way

#

this is a discord bot, correct?

digital ibex
#

which part?

#

im sending messages via my bot from a website

slender hamlet
#

ok, but the if statement is in the message event

digital ibex
#

no

#

there is no message event

slender hamlet
#

ah, where is it then

digital ibex
#

there is none

slender hamlet
#

as in, where does the if statement go?

earnest phoenix
#

am i allowed to ask if anyone wants to create a bot with me here?

digital ibex
#

its in a post request, in my backend

slender hamlet
#

ok