#development
1 messages · Page 1505 of 1
codeblock?
self.leaderboard.start(ctx)
why does a leaderboard be a loop though
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?
Anyone got a distort command using canvas-js
yeah whats the problem
i mean its pretty straightforward
you create a canvas with createCanvas
you get its context with .getContext('2d')
I meant the .draw image stuff
for that you need an image
Image can be anything
you can use loadImage('url-or-image-path')
Just not like how to imagedraw
ctx.drawImage(image, x, y, width, height)
Yeah what should I do to get a good distort
oh um
you probably need to use pixel data
havent done one, but shouldn't be too hard
Ok
use .getImageData()
it returns an array of numbers for the RGBA data of each pixel
you can modify it and use putImageData(data)
k
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
yea
yeah
wait
is your current code this?
Once done imma eval a file and write it
k
There
wat
?
Bytes?
Ok
Is there anything like spotify dl?
each 4 of them are the values for 1 pixel
Okay
?
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]
so that's where you start from
?
Oh
but yeah you can do that
maybe map the array into a 2d array or something and work it out from there
idk, use array.reduce
O
i'd say first group the numbers into arrays of 4
For each?
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
Like mix the array
use Array.reduce
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())
um that's not how Array.reduce works
Array.reduce(array)
El método reduce() ejecuta una función reductora sobre cada elemento de un array, devolviendo como resultado un único valor.
check this out
wait
thats spanish lmao
Hard on mobile
freakin google 
And I cant read Spanish only German and english
yea
here it is
The reduce() method executes a reducer function (that you provide) on each element of the array, resulting in single output value.
cuz the url is still in spanish
im a dumbass
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
wait so .reduce basically is doing something to an array but having the last returned variable provided?
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
so you can basically do eval(\${array.join("+")}`)` without having to use eval
you could use it to group the pixels into an array of arrays of 4
you can set its initial value to an empty array
Wha
or you know what
just do it the old way
make an empty array and add the pixels in groups to it
let grouped = Array.reduce(function (obj, item) return; });
@mellow kelp
That close
um thats not how it works
^
I didn't understand that
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
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
First element on array is 0
its 2
Wa
Ok
anyways i got to go
K
Hello, does anyone know the Regex for how to allow Spotify links in this format too?: spotify:playlist:playlistID

that does not contribute in any shape or form
Like ```js
"spotify:playlist:playlistID".replace("spotify", "https://open.spotify.com").split(":").join("/");
whats the issue
life
The format basically looks like this spotify:playlist:37i9dQZF1DX1gRalH1mWrP, trying to do it with a Regex (currently my bot only supports regular playlist URL's and not that format above
None of the Regex's from online seem to work
only playlists or what
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
Ye
why not something like this ```js
const str = "spotify:playlist:playlistID";
str.match(/^spotify:(.+?):(.+)$/) ? str.replace("spotify", "https://open.spotify.com").split(":").join("/") : "invalid";
regex more like random spit
That'll create https///open.spotify.com/playlist/playlistID
Gotta add https:// after the split
kinda offtopic but can you force kill or change other apps permission while it's running? (java)
how do i make such a table? 😄
These are vars people use for suggestions/logs etc. Any suggestions on what other vars I could add???
People might want a separate name and tag variable for users? Other than that it looks good
Does anyone know how to get the specific user who invited the bot? (discord.py preferably)
and does that require privileged intents
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
have you imported reddit?
bruh
wait actually?
is reddit even a module?
lol it seems to be
it's praw
nop3
that u need to pip install
praw is a module
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
For fuck's sake
Put self.reddit = praw.Reddit(...)
Then use self.reddit
There, solved within seconds
yea but the guy didnt even install praw
NameError: name 'praw' is not defined
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
@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
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
Try to str() this
Since that's an Asset by default
url=str(member.avatar_url)
bruh'
@void vale woah woah woah did you just send your oauth token
lol it worked
@earnest phoenix It's disposable
How can I make my purge command embed response?
Thanks I guess
@earnest phoenix uh why are you not checking if the user has permission to do that
you still didnt fix the deleteCount error?
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
it is lol
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?
Every time I use it why does it do this?
send the code for that
while i go have lunch
Like you found a buy one right?

Bug*
Ok
good how do i fix it ?? write to me: (node: 23880) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'fetch' of undefined
aha
@pale vessel
@urban pelican that code is wrong btw
# 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))```
Why did you comment everything
you are fetching a single message then message.channel.bulkDelete(message)
@earnest phoenix
and how do I fix it?
uhm... just bulkDelete everything?
lmao that's your command handler not the actual command
what?
You want the uh purge command or?
Lol
@earnest phoenix so the purge command coding?
yes
where you checked if the user has permission
@pale vessel discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'reddit' is not defined
?...
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))
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'reddit' is not defined
please help someone
Define reddit as self.reddit
typescript ah i see you're a man of culture as well
@pale vessel since when did you know python
and then in here you can use self.reddit

oh
It bully me a lot
i am changing from normal to cogs
the problem is that you don't know javascript and just type in random shit and expect it to work
you never define purgeEmbed

this
code
- ok where are you actually checking if the user has permission
@cinder patio well it does work bruh
- purgeEmbed is undefined
Close your client secret and check your indentation
You're coding in python, indentation matters
@rustic nova i dont get it
it is correct
which is exactly why we should code in binary
lol
pls help
main.js instead of index.js how is node . running the correct file 
npm init -y puts the main file to index.js
he can change it from package.json
Show your code
so what should i do there is a bit of a mess 😄
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))
why does py use forced indentation
fun' object has no attribute 'Reddit'
?
I'm sorry I'm a blind person here
And also wrong
re-read the docs
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'Reddit' is not defined
Why did you delete and resend the message
but he still shows me the same mistake
Did you put self.reddit = self.Reddit?
@urban pelican you should learn coding before trying to make a bot
that gives error
That's why I'm asking
The code is wrong, even i can say so without any proper js knowledge
That' tho
It's probably praw.Reddit(), which is what you had
bruh it worked like this
Nah i know you code in js in secret
when i didn't use cogs
yesterday I wrote that I am a new programmer so I don't know everything
nah js is nothing for me, maybe sometimes for tampermonkey stuff, but meh
i can't fix it @pale vessel
and that's why this roomka 🙂 isn't it?
what's your new code
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
i don't understand a thing 🙁 i am just 14
It's self.reddit = praw.Reddit(...)
bruh what
and inside the command, you use it as subreddit = self.reddit.subreddit(subred)
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'
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?
loop through the rest of your args
How?
No js experience, can't help lol
I do have js experience i am just wondering what type would be better to use.
i know i can loop usin map and foreach etc
i mean i don't have js experience lol
If you're getting your args as an array you can just use args.join(" ") to get one string from it
@eternal osprey wait how are you using the chrome console
I am using the js console.
in vsc
but how
by debugging...
you cant press buttons to collapse or expand in vsc
Are you using this?
why?
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")```am i not already doing that
extension
because if you ran with node index.js them no debug session starts so no ooh buttons
ooowh okay
ooh ye got it
but i already joined it so it still doesn't work>?
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
Bruhhh
?
I created an image recognition api using python once.
That's crazy bro
it really was a pain in my fucking ass.
python
What can I do if when I enter * image (Russian text) I get an error:
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
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
@silent cloud send code
Kk give me sex
what
he means seconds
kk give me sex
kk give me nitro
sex oh no
😂
@silent cloud ngl that code looks dope
can someone help me on hot to get economy type thing which is public and not centered to one guild
Good ask
Hahaha
I found that easily
How to make it on bing
And doesnt find on google
Idk how to do that
https://developers.google.com/apis-explorer search image api
use duckduckgo
Nononono
and scrape it
Im so lazy to remake this
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
it isnt
they don't allow scraping because robots dont care about ads and because they want you to go through the api
that's good
robots cant fuck up advertisers
I cant find image api on delevopers google
@silent cloud its search
Why are you not adding the 7
umm
nvm what is the link to the problem
pls help
Learn how to work with databases ig
oof lemme just figure it myself
no can't pls help me out
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?
it removes the last value and the first one
hi
Hi
“api is 10000x better” nice joke man
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
the google api isn’t that good
how about you try MessageEmbed
@true ravine make an array of required stuff then loop and use it
ah
So do you mean use everything and not just the request route?
how i can remove a value from array
const a = [1, 2, 3]
// How to remove
// so a = [1, 3]
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
this.url = (query, nsfw) => `https://www.bing.com/images/search?q=${query}&view=detailv2&safeSearch=${nsfw ? "off" : "strict"}`;
Scrape it?

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
is it working?
I took my full time and made free commands for you guys
Spoon-feeding
Check it click
in js?

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
What exactly does this mean? This is all in discord.js
Actually, arrays start from 0, minNum is 1, it splices that specific index from that array, that additional 1 there is the amount of elements to remove from the starting point as it's the index
whats in the embed.image.url?
its supposed to be an image link
Means you psssed a URL that doesn't start with http or https protocol
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.
try console log the avatar url
could someone send me a poll script?, node.js, I'm having problems
Logs "null"
thats the problem then
I can't go wrong to help? pls
?
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
and how do I fix it?
this bruh
some whitenames, honestly, some greennames too
could someone send me a poll script?, node.js, I'm having problems, pls help me
wdym by a poll script, and we’re not gonna spoonfeed you
ok ;(
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
also it should be just channels.delete
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.
See #rules-and-info 8.a
currying
Actually currying is a super great feature, I rarely use it but when I do I'm really glad it's a thing.
same
lol
Hello can anyone tell which app use for creating commands in android
what methods are there to let my bot get my tweets
wdym by get your tweets
Example mee6 announces when I make a new tweet
I assume they use the Twitter api
DUDE IM SO DUMB I FORGOT ABOUT THE FUCKING TWOTTER API
Ah yes api.twotter.com
I was trying to do this shit through RSS feeds lmao
My favourite social media
Mine's Twatter actually. 
Only people from British will understand
Not really, but ok.
I did it for the meme shhhhh
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.
Any other app best for creating commands
twat(ter) lol
BDFD is the only app that can create commands
coding them
Anything else you need to actually learn a programming language and, ideally, you need to be programming on PC.
but you could just pull a voltrex
i know python language but i have no pc
there is no reliable way to do that
Then maybe don't try to make bots until you do, really.
ah 💩
Can i create commands from gitlab or github
You can write code in many ways but on a tiny-ass mobile screen it's going to be crap anyway
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
HOLY FECK
you can fetch the audit logs, but as Tim said, it's not reliable
I have tab
don’t show that to voltrex lmao
Ok. So you have a larger screen. That's 1 of 6 problems.
Now you can help me in creating or devloping my bot
No you still have the other 5 problems and we can't help you with those.
😩
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
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.
Hello Listen me
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
Can i coding from My Friends laptop
ARM is meant to be low(er) powered lmao
Sure, of course, absolutely.
Which software need on laptop
yeah ik, that's why i said it can't compete against traditional architecture, it simply isnt as powerful
Dunno I don't write python.
No just for gk
Apple did some crazy stuff on ARM tbh
i mean sure
But that’s only on MacBooks
Bcz today i watch stream in this server
there are also ARM powered Servers
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
wait 2-3 generations
in stream he Editing files which created with java script language
by those new generations we will have 5nm chips lmfao, beating ARM again
thx but that i know too, @umbral zealot
i mean the way to optimize it
i don't have any idea to optimize it
nope wait imma tell ya
Hello
please stop using the reply feature every time
seriously
we're having a conversation here
Be patient
//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
About bdfd
and my brain just ded
This is #development not #buttonmashing , we can't help you with bdfd.
How can i Get Umlimted hosting time for bot
Paying money.
the most smallest diffrent between them who even wrote this 😂
They pay for a VPS.
Literally they pay to be online that's how it works.
or own something like a Raspberry Pi / Nas at home

nvm then
local hardware still "costs" just different costs.
I can feel my brain imploding watching this discussion lol
Your bot link can u send me in dm
same
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])
What is that, like, homework or an employment test? lol
shiv fast
Homework
Pseudocode and general logic, the rest is up to you to figure out @willow mirage
You have any bot
smh asking us to help with your homework
solve my homework for me 🥺
ok
that won't work
How come
@willow mirage
cuz the number can be [0, 9, 1, 10]
they are not after each other
@sudden olive Yes i do
@sudden olive for the love of god stop being annoying and asking unrelated questions, if you want to talk go to #general
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])
i just ask for idea, not solving it (:

>>> 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
Actually let me do that a bit better
wait so is this to get the min difference between array elems?
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
that works too
i was gonna suggest combining the if conditions if you don't want to initialize diff
but yeah this is good

/home/container/src/index.js:163
.setTitle("Welcome");
^
SyntaxError: Unexpected token '.'
Any ideas?
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
That would also be my guess.
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);
Yep.
thats the code
remove the semicolon after new Discord.RichEmbed()
with that semicolon, you're telling the computer to end that line of the conversation
oh
but you're setting its properties below
bruh
so you wanna remove all semicolons until the last one
last one would be the line which sends the embed?
the Total Members field is the last field, so it will be the one with the semicolon
if a is a channel then yes
Alr
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
}```
might also wanna try like if (!a || typeof(a) != Discord.Channel)
oop
did i mispell this
pretty sure its Discord.messageEmbed()
hello
yes, it's MessageEmbed in v12
Any reason they changed it?
no clue personally, maybe evie knows
yeah rip
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
luckily my bot wasnt dependent on v12 changed stuff until after v12 came out
interesting
capital M bruh
that's one difficult screenshot to read
yes it is
no its not
capital M?
whats the best database shit
try mongodb
no
You still have to define variables you want to use, that's a JavaScript requirement, it has nothing to do with discord.js
pay close attention to your variable names and what you actually want to reference
notice anything?
what parameter are you supplying the callback with?
hm?
what is the name of the variable that you give the function that is called when guildMemberAdd fires off
here, let me explain
newMember?
i just replace the (member) with newMember
or vice versa
np
what is faster .some or .every
doesnt it depend on your use case?
most likely some
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
yeah
assuming both are optimized enough
so they aren't exactly the same
a micro-optimized for loop beats both tho
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
ye
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)
Use fs to get all files from the ./api/routes folder
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)
fs.readdirSync("./api/routes").forEach(route => {
app.use(`./${route}`, require(`./api/routes/${route}`))
})
you could use a method similar to how discord command loaders work
yep, tim's gotcha
Yeah that's similar to what I did except I just used for not foreach
Is there any explanation of them because I use them but don't really get how they work
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
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
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

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
ah, ok
Collections are just extended maps
basically yes
So are maps like an array of objects?
maps are like arrays, if you could set custom indexes
Ah I see
array[0] is based on zero indexing
if you could do array["mypropertyname"] thats what maps are essentially
kind of like python dictionaries
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
except you'd not go array["mypropertyname"] you'd go collection.get("mypropertyname")
Maps are more like objects
yeah
Collections are extended maps that have array methods
e.g. reduce(), forEach(), map(), etc
how so? did the request handler file not get any method calls?
that's odd
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
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
Give me a minute I've got the application stuck running lol
no problem
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
@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
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 :)
you can omit route.length and use -3
what is that function doing?
dictionary as in, an array?
yes
and queries are also arrays?
neither .some nor .every are needed here
how . . .
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
you're not using the return value anywhere
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
btw if i name those variable to a, b does it will make code faster?
no
oh

So how i can optimize it now?
.some and .every are like .find and .filter, you only use them if you need the value that they return
ok
otherwise use forEach or for
ok
but i tried
it is still slow
Like im trying to not use loops
but it is still slow
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
hmmm
ok
but i think it won't be faster or just a little bit faster
but lemme try
hi, im having a small issue. i have: https://hastebin.com/uqomuzisev.less but the embed gets sent twice, any ideas?
im not sending it multiple times
its whenever i send a request to my api, the text in the input is still there
bruh the text format
beautiful
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
alr im back
what do you mean by "repeats"
just to be clear
it sends the message twice
like if the message was "hello"
it'll say "hello" twice as separate messages
ok, but the if statement is in the message event
ah, where is it then
there is none
as in, where does the if statement go?
am i allowed to ask if anyone wants to create a bot with me here?
its in a post request, in my backend
ok