#development
1 messages Β· Page 1078 of 1
Hey so I am trying to make a Smash or pass discord bot and I'm trying to get the images from reddit. Most subreddits are NSFW tho and apis like random-puppy or imageapi don't work when the reddit is marked NSFW. Does anyone know how to bypass this? Here is my code if you need it
const Discord = require('discord.js'); const api = require("imageapi.js") module.exports = { name: 'girl', run: async (client, message, args) => { let subreddits = [ "RealGirls" ] let subreddit = subreddits[Math.floor(Math.random() * subreddits.length)]; let img = await api(subreddit, true) message.channel.send("Here's a girl image...") message.channel.send(img) } }
@earnest phoenix anyone can help me?
So me and my friend we made an NPM package and we can't add myself to the Collaborators anyone knows how to do it?
It just shows my friend
Is it usual for a bot to be in the que of approval for over 2 weeks?
Yep
you have to store it somewhere right?
it doesnt affect channelMessages, it affects whatever its on
const newvar = channelMessages.reverse()
Try logging the channelMessages in the console and look what it returns
I'd do it exactly like Woo wroteπ
You can also just go with channelMessages.reverse() without creating a new array.
Try to do it after the Promise. Not in the .then
Luca will DM you
3+ weeks
humm ok
.setThumbnail(message.guild.iconURL)
This doesnt give me an error but it doesnt show the image for the embed, does anyone know why this is happening?
if youre using v12 <Guild>.iconURL is a function, like <User>.avatarURL
Yeah im using v12, im a bit slow and im embarrased to say but i have no clue what that means
This happen when I tried to ban someone with reason but if without reason it's fine am I doing something wrong or I need to add specific lines for reason of ban ?
wow snipping tools fucked.
it did that because you drew bigger than the screenshot
anyway, stats needs to be defined
Hmmm yes.
where did you define it?
oh
yes
In my help command I didn't use group(folder) for each command and if I do put them into groups should I be adding ${cmd.folder} ?
helpEmbed.addField(
`**${message.client.prefix}${cmd.name} ${cmd.aliases ? `(${cmd.aliases})` : ""}**`,
`${cmd.description}`,
true
);```
yes?
and btw
the forEach function is slow, you shouldn't use it often when map does the exact same thing but faster
what should it be ?
like commands.map because replacing forEach ?
yes
Alright, let me experiment with something, thanks for it.
@digital ibex do you have actual evidence that it's faster
and have you also considered for loops
I tried to move kick, ban to moderations and it's changed to this.
let me do some benchmarks
.setThumbnail(message.guild.iconURL) Doesnt display the server's icon and has no error. Im using v12 discord.js and was told that iconURL was a function but i dont know how to apply that and im more confused now. Thanks if you can help
read the docs
so...
i couldnt find the actual source
so
i timed it, and the difference is only a small 0.3ms
thought it was much bigger tbh
after I put all commands to specific folder like moderation and music bot doesn't dm anything after changing and adding ${cmd.folder}
Am I missing something.
i feel my code is broken
doesn't show any error.
lol
hold.
thats console.time, right?
my previous bot using klasa the help command was like this.
does array.fill not work
it is possible to use klasa and discord js at the same time ?
umm
quick question
the code isn't on github, any ideas?
~~ yes ik i spelt upstream wrong
~~

oh cool
oh
with 1.5 million entries, forEach is the fastest at 35ms, followed by map at 40ms, then for loop at 49ms
this is on a ryzen cpu also
hmm.
Using value: 991
Array entries: 15000000
forEach took: 466 ms
for loop took: 459 ms
map took: 454 ms
with that many entries you can see that forEach still works faster
not by much but there's a diff
oh
science?
never knew that
thing is, map is designed to return a value
hmmm
for each is undefined, which i believe was on the stackoverflow i got that info from
idk
for loops and forEach don't need to. i don't know why for loops are slow but forEach clearly seems superior
how to make the bot see commands inside a folder, because when I put commands into another folder like ban to moderation it don't shown anything on help command.
code is nothing fancy to test them
for is blocking
the bot doesn't see folder of commands.
can't help you without code
send the code where ur exporting the command
module.exports = {
name: "help",
aliases: ["h"],
description: "Display all commands and descriptions",
execute(message) {
let commands = message.client.commands.array();
let helpEmbed = new MessageEmbed()
.setTitle("Bill Cipher Help")
.setDescription("List of all commands")
.setColor("#F8AA2A");
commands.map((cmd) => {
helpEmbed.addField(
`**${message.client.PREFIX}${cmd.name} ${cmd.aliases ? `(${cmd.aliases})` : ""}**`,
`${cmd.description}`,
true
);
});
helpEmbed.setTimestamp();
return message.author.send(helpEmbed).catch(console.error);
}
};
it doesn't have a folder property
then.
How do I get data from an array, froma get request?
wdym
@amber fractal how's that
just fetch('url', { method: 'get' }); ?
i did this to test it
module.exports = (array) => {
const start = Date.now();
let strs = [];
for (const item of array) {
strs.push(item);
}
return Date.now() - start;
}
I mean, how do I get the data from the get request
@digital ibex What should I add next like ${cmd.folder} or something ?
@earnest phoenix make the api request yourself
@sick cloud hmm could you show me an example on how to do that
how to display all commands and description on discord.py?
Is this the right code?
for command in bot.commands:
try it
@digital ibex before putting the commands to folder it shown fine before putting it to folder.
For example, how do I get data from that url
but to get the commands name
you're not doing that
how r u getting the name of the command?
Not putted into folder.
Wait a sec
I know that part, but how do I get data from an array?
@earnest phoenix find a http request lib, request the reddit json (reddit.com/r/subredditname.json) and tada
ie showerthoughts is https://www.reddit.com/r/Showerthoughts.json
just use node-fetch :p
If mongo is backend only then how do I interact from the webserver
node-fetch is bloated
:d
it is?
yes
:o
phin is good
Snek fetch
thats how i make all my api requests in my discord lib π³
snekfetch is discontinued
m
:(
gona use snekfetch
https://oliy.is-just-a.dev/7g4fd4_5171.png this is the best way I can easily show for vs forEach's performance
request is also deprecated
Timmm :>
is console.time slow also? i've never seen people use it, they always use date.now
hey can someone help me, im trying to get the nickname of a user but it keeps returning "undefined".
my code is
.addField("Nickname:", `${message.author.displayName}` || "None", true)
the overhead of console.log far outweighs the overhead of forEach
redo the test without logging
users dont have the displayName property
what would it be?
its member, not user
ive looked thru discord.js
The loops both do the same thing
you're looking in the wrong place, look at member, not user
only guild members can have a nickname therefore displayName doesn't exist on a user
And forEach would win if you just do nothing with the array
but for is generally more performant in a real situation
to my knowledge anyways
ok then
yeah, nothings happening there 
I mean that's just from my testing I've noticed
@earnest phoenix here u r https://discord.js.org/#/docs/main/stable/class/Member?scrollTo=displayName
js basically optimizes them both to the same thing
Tim
DO u know how to add people as contributors to an NPM package
As me and my friend made a package but we can't put me on there
And we already have 130 downloads in 2 days so I would likke to be put on there as a contributor
https://oliy.is-just-a.dev/tjoffv_5173.png this is what I got
I hate to break it to you most new packages get a lot of downloads because of package managers
their data is fucked
ok
on the package
u'd need ur friend or whoever 4 this
btw
You should just have to be a collaborator on the projects github
I think that's where it gets them from
What's the package?
tell ur friend to go to <package > contributors > add user > <ur npm username>
@earnest phoenix find a http request lib, request the reddit json (reddit.com/r/subredditname.json) and tada
@sick cloud Sorry for asking so many questions π¦ Now that I have the json how do I implement it into my d.js bot?
https://oliy.is-just-a.dev/1u5k4e_5174.png yeah npm docs say that too
require the lib, request the url, use the json, do whatever you want with it
screenshot?
he just had to go
But he was screensharing
It just showed like this
I am added as a maintainer tho
u probably cant be both then
oh
@client.event
async def on_ready():
servers = list(client.guilds)
print('Theo is online!')
print("-----")
print(f"{client.user.name} is Connected on {str(len(servers))} server(s):")
print("-----")
print("Bot created by .rareh#2968")
print("-----")
print('\n'.join(server.name for server in servers))
print("-----")
members = 0
for guild in client.guilds:
members += len(guild.members)
messages = cycle([f"Theo Zeciu", f"{str(len(servers))} servers", '.help', '.rareh'])
status = cycle([3, 2, 2, 2])
while True:
curr_message = next(messages)
curr_status = next(status)
await client.change_presence(status=discord.Status.online, activity=discord.Activity(name=curr_message, type=curr_status))
await asyncio.sleep(7.5)```
any ideea?
the bot it's not oppening
like nothing will print
print('\n'.join(server.name for server in servers))
i think smth is wrong there
require the lib, request the url, use the json, do whatever you want with it
@sick cloud ```js
const Discord = require("discord.js");
const snekfetch = require('snekfetch');
module.exports = {
name: 'meme',
run: async (client, message, args) => {
try {
const { body } = await snekfetch
.get('https://www.reddit.com/r/dankmemes.json?sort=top&t=week')
.query({ limit: 800 });
const allowed = message.channel.nsfw ? body.data.children : body.data.children.filter(post => !post.data.over_18);
if (!allowed.length) return message.channel.send('It seems we are out of fresh memes!, Try again later.');
const randomnumber = Math.floor(Math.random() * allowed.length)
const embed = new Discord.RichEmbed()
.setColor(0x00A2E8)
.setTitle(allowed[randomnumber].data.title)
.setDescription("Posted by: " + allowed[randomnumber].data.author)
.setImage(allowed[randomnumber].data.url)
.addField("Other info:", "Up votes: " + allowed[randomnumber].data.ups + " / Comments: " + allowed[randomnumber].data.num_comments)
.setFooter("Memes provided by r/dankmemes")
message.channel.send(embed)
} catch (err) {
return console.log(err);
}
}
}``` I did this and it didn't work. I am sure i did something wrong lmfao
For rareh's thing, I don't think a string can use the .join method. Did you get any kind of error message?
Yo, is that a webhook?
I came here to ask about those.
is what a webhook
What Valckyz posted. snekfetch?
no
@viral plover
Oh.
quick question if anyone knows
So @earnest phoenix.
Error says that it crashed because .join(server.name for server in servers) isn't a string.
the owner of a repo merged the master branch into my branch, god knows why. how can i remove his, the owners, merge so i can push?
@earnest phoenix errors or none
why do people keep using snekfetch
I did this and it didn't work. I am sure i did something wrong lmfao
if you are using v12 and the error is .get is not a function then you clearly copied the v11 code cause I have that as well
Is it possible to make a webhook using a website that doesn't have built-in support for them?
What do you mean by webserver?
I want to make a while loop on discord.py
is this work?
from discord.ext import commands import asyncio
client = commands.Bot(command_prefix='!')
async def background_task():
await client.wait_until_ready()
counter = 0
channel = client.get_channel(123456) #Insert channel ID here
while not client.is_closed():
counter += 1
await channel.send(counter)
await asyncio.sleep(10)
client.loop.create_task(background_task())
client.run('token')
I probably should've just Googled that.
and im talking about a proper webhook too
@earnest phoenix errors or none
@sick cloud No errors but nothing posts
I use javascript.
for the backend, express?
why do people keep using snekfetch
@quartz kindle I use node-superfetch for it now lol
I'm not trying to pull data from a website I made.
if you want to pull data from your website, make the api public
You dont pull data with webhooks
webhooks can be converted using a middle man
I mean send data to Discord via a webhook.
you can probably just make it only so ur IP can make requests to get data, not sure though. im just assuming it
yeah
make a <method> request
Not send data to the website.
there are a few services that do that, such as ifttt
The website (MAL) isn't supported on ifttt.
does mal emit webhooks?
No.
then what do you want to do?
you'd need to make ur own discord API request then (u can use a library but thats kinda hacky)
hi
I want to be able to use a webhook to get data from MAL and send it to Discord, but I'm not sure if it's possible since MAL doesn't have built-in support for webhooks.
I came here to know if it's possible.
if mal doesnt emit webhooks, then you need to build the interface yourself
Yeah, that's MAL.
a program that periodically downloads from mal, then sends to discord
i feel for u that u know that but ok
Okay, so it is possible, but difficult (as expected).
depending on what you need its not difficult
if mal has an api, you can just query their api
Earlier search results showed something for API, but the primary links on it all lead to 404s.
Yeah, it's a website.
then u can just literally
@sick cloud ```js
const Discord = require("discord.js");
const snekfetch = require('snekfetch');module.exports = {
name: 'meme',
run: async (client, message, args) => {
try {
const { body } = await snekfetch
.get('https://www.reddit.com/r/dankmemes.json?sort=top&t=week')
.query({ limit: 800 });
const allowed = message.channel.nsfw ? body.data.children : body.data.children.filter(post => !post.data.over_18);
if (!allowed.length) return message.channel.send('It seems we are out of fresh memes!, Try again later.');
const randomnumber = Math.floor(Math.random() * allowed.length)
const embed = new Discord.RichEmbed()
.setColor(0x00A2E8)
.setTitle(allowed[randomnumber].data.title)
.setDescription("Posted by: " + allowed[randomnumber].data.author)
.setImage(allowed[randomnumber].data.url)
.addField("Other info:", "Up votes: " + allowed[randomnumber].data.ups + " / Comments: " + allowed[randomnumber].data.num_comments)
.setFooter("Memes provided by r/dankmemes")
message.channel.send(embed)
} catch (err) {
return console.log(err);
}
}
}``` I did this and it didn't work. I am sure i did something wrong lmfao
@earnest phoenix Can someone help me? It doesn't send the message and no errors
Since it didn't crash, it's likely that it just didn't receive any data to post, yeah?
channel.send(JSON.stringify(bob));
function bob() {
// api requests
}
@earnest phoenix are you using v12 discord or v11
cause thats a v11 code 
does anyone know how to delete a specific array element in a document using mongoose
@earnest phoenix are you using v12 discord or v11
@zenith terrace v12...
what do I have to change
Mal's API requires authentication
Do you know how this authentication is granted?
From what I saw earlier, I'd expect through their Discord in some way.
wait let me send a picture
MAL API isn't the best. I'd use another service like kitsu
@quartz kindle mal api is dead
The API is intended to expect the user to be working with it. Aka, you can't do something like get an API key then send a request to the API to get your anime data. A user must log in with your client and you should use that token to request data.
@earnest phoenix are you using v12 discord or v11
@zenith terrace What do I have to change in it to make it a v12 code
then use the $pull operator
I recommend you use an alternative API, such as AniList or Kitsu. I recommend AniList myself (even though it's graphql).
You could also use a scraper such as Jikan, but those tend to be slower and less reliable.
@sudden geyser oh thanks for thar
The main data I want from MAL is the popularity of the anime. Since this is based on users, it naturally varies from website to website.
ah ok, i dont use mal myself so i just googles for mal api and found that
Scraper?
It doesn't need to be fast.
mal scraper died
no
but you want to post popularity updates or what?
#memes-and-media please @earnest phoenix
webhooks are meant for periodical data and updates
It's more complicated...
its not
I mean why I want the info.
Β―_(γ)_/Β―
I'm not going to pretend I'm an expert on webhooks.
if you want to make bot commands, its better to just make the bot do the job, no need for a webhook
ok so it didn't work but i'm assuming it's an issue with what i'm doing
i've never used mal or anything, but if it requires authentication.. all u need to do is make an account or whatever, and use that
Any discord.py users still online?
if (!message.author === message.guild.owner) return;
let removeItemEmbed = new MessageEmbed()
shop.find({ Guild: message.guild.id}, (err, data) => {
if (err) console.log(err);
if(!data) {
message.channel.send("You haven't set up your shop!")
} else if (data) {
let itemName = args.slice(0).join(" ")
data.updateOne({ $pull: { name: `${itemName}`}})
data.save()
removeItemEmbed.setTitle("Item Removed")
removeItemEmbed.setDescription(`Item removed: ${itemName}`)
}
})
uh
so basically
Does that mean I can make the bot look at the website and gather data? @quartz kindle
basically the reason to use webhooks is to post stuff on discord without needing a discord account nor a bot
if you have a bot, you dont need a webhook anymore
wait
Oh.
i've never used mal or anything, but if it requires authentication.. all u need to do is make an account or whatever, and use that
@digital ibex it's user authentication. Not normal "grab my key and send a request" auth.
i need to send a message, and it requires me to connect
how cnan i do the same but with webhooks?
i dont get it
so like
what message
What kind of message?
im not using a library
and im also not connecting to discord
so i cant send a message to a channel
yes you can send a webhook
where do you want to send it to tho?
webhooks basically need to be "opened from inside"
by going in your server's configuration and adding it there
This is the most help from the most users I've gotten from all my inquiries. (Is it because I mentioned MAL?)
Thanks @quartz kindle. I have research to do now~
im trying to do this automatically
what im doing is: creating user account, enter discord id, send discord id to modmail bot, manually verify they're claiming to be x user, and if they are, change their user model to pending: false, all im trying to do is make it all automatic.. do u know how i can do this?
(this isn't related to discord btw, i just need their discord id so i cant use <member>.id or whatever)
so you're not using oauth2 for this?
nope
is modmail your bot?
alright, so when a user enters their discord id in your website, you would need to send this id to your modmail program, probably through a small api
you can slap an express server inside the modmail bot so it can receive stuff like that
im trying to remove the whole modmail thing
then what do you need? send a message to this id and ask them to verify? what if they do not share a server with modmail? then modmail cant dm them or anything
ah
yeah
do they need to be in your server?
you cant send webhooks to dms
but im trying to make it not do anything
yeah
i was thinking..
i can send the message to a channel as a webhook, and get the webhook and match the code and the code they got provided.. (to verify they say who they are)
hm
Tim what port should I use for the dbl webhook?
i can try that actually
ok
how are you gonna "get the webhook to match the code"?
Instead of using a webhook to transfer data, use post requests on a small api
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
and split it with "code: whatever"
but how is that gonna verify anything?
what im doing is
user creates out account, once creating and they pass security checks, they get prompted a "enter ur discord id" thing, and they enter their id, the id which they provided gets sent via a webhook to a channel with the info:
code: <secret code>
id: <discord id>
and then, it gets matched with their actual id
which actually thinking about
how am i gonna get their id π€
there's only two options:
the user needs to go into discord, get the code themselves and paste it back in the website
use a bot to send the user a dm and read the user's response or to give them the code they should paste in the website
yeah, thats where the modmail thing came in
which is exactly what im doing, but without a human checking the thing
still does fasten the process but 
the only way to be fully automated is oauth2
i've done oauth2 once before
and the codes a mess
and to open source that shit π₯΄
well i mean
use that code in an open source repo π₯΄
also tim, one more question, i hope. do u know how to revert a merge?
for some reason, the owner of the master branch merged master into dev
i tried git revert --hard HEAD^ but nothing happened
quick question. If you use mongoDB and your off your laptop/desktop does everything still store onto mongo
(never used it before so just wondering)
yes
if ur using localhost, it can only be accessed by that machine
if ur using atlas, it can be accessed via anything
im guessing theirs also a documentation on how to use Mongo as well (like what quick.db has)
yes
alright, thanks
Can any body see if what i want will happen ? Search for my server > name all humans in β§Λ*ΰΌβΎuser nameβ½ΰΌ*Λβ§
if(message.content.startsWith('!test')){
srvmembers = client.guilds.cache.get('705909917558767616').members.array
srvmembers.forEach(user => {
if(user.bot) return;
if(user.id === '586997743478636556' || user.id === '464870886621708290') return;
user.setNickname(`β§Λ*ΰΌβΎ${member.username}β½ΰΌ*Λβ§`)
})};
try it 
then you can fix it...
Wut is dis
discord
Ok smart ass
then go into a testing server and use it
what
i've been trying to work out how i'd remove data from an array for a little while. if anyone can tell me what i'm doing wrong i'd appreciate it.
const { MessageEmbed } = require("discord.js")
const shops = require("../../models/shop.js")
module.exports.run = async (bot, message, args) => {
if (!message.author === message.guild.owner) return;
let removeItemEmbed = new MessageEmbed()
let itemName = args.slice(0).join(" ")
shops.findOne({ Guild: message.guild.id }, (err, data) => {
if (err) console.log(err);
if(!data) {
return message.channel.send("You haven't set up your shop!")
} else if (data) {
data.update({$pull: {Name: itemName}}) // remove object
}
})
}
module.exports.help = {
name: "removeitem",
description: "removes an item from your guild's shop",
arguments: "<item name>",
category: "Economy",
aliases: ["shop"]
};
the data is stored in an array object
the code doesn't error it just doesn't remove the object
what are you doing to remove the item?
basically i'm getting the document and then pulling the name field from that document
like prefix removeitem what here?
.removeitem <itemname>
you're looking for args[0]
yes
not args.slice(0).join(' ')
which is what ur doing
which is basically the whole thing
yeah but if the item has spaces it'll error
console.log(itemName)
it's what i expect it to be
it might be because it's not referencing the array
but the document as a whole
although data.Items throws an error
just in a new schema?
const mongoose = require('mongoose');
let Schema = new mongoose.Schema({
Guild: String,
Items: Array,
})
module.exports=mongoose.model("shops", Schema)
thats why
no offence, but its a stupid way
do
Items: { type: [ { name: String, price: Number } ] }
that way you can easily do it
yes
ok
ok cool
quick question
do u have a schema for each thing
like a schema for prefix, shops etc/
yes
just mkae one model
for guild and thats all u need to do
and add the properties onto it
so just read data from one document basically
is it possible to add a document for a guild as soon as the bot joins a guild?
djs?
yes
yes
u can do it like that
so not when you join a guild, but when you join a guild?
but im p sure it'lll be slower
yeah probably
events are slower?
Hey, can any one help me? How can I fix this?
let textChannels = message.guild.channels.cache.find(x => x.type == "text");
await textChannels.overwritePermissions([{
id: message.guild.roles.cache.find(x => x.name === "Muted"),
deny: ["SEND_MESSAGES", "ADD_REACTIONS"],
},
]);
Console Error:
(node:6360) UnhandledPromiseRejectionWarning: TypeError [INVALID_TYPE]: Supplied parameter is not an User nor a Role
the first parameter is a string which is User or Role, not an array
?
is the code running?
someone here is a python boi?
cool
but in discord bot off
Iirc.
Glitch doesn't run things 24/7
Yea
How do I slice of a command?
let query = message.content.split('!!querytest ')
message.channel.send(`${query}`)
}```
When I do this, it leaves a comma
how to fix
Use something other than glitch
@earnest phoenix .split() makes an array
can you elaborate on that?
@half bison After the tos change for glitch, I started to use repl.it
It works like a miracle, you should try it
Hello world.split(" ") -> ["Hello", "world"]
Ohhh, so how should I solve the problem?
I use this:
// Message: "!Ban 671483717826379787" Advertisement
let messageArray = message.content.slice(prefix.length).trim().split(/ +/g);
// MessageArray = ["Ban", "671483717826379787", "Advertisement"]
let cmd = messageArray[0].toLowerCase();
// cmd = "ban"
let args = messageArray.slice(1);
// ["671483717826379787", "Advertisement"]
And pay attention to the capitalization
// Message: "!Ban 671483717826379787" advertisement
let messageArray = message.content.slice(prefix.length).trim().split(/ +/g);
// MessageArray = ["Ban", "671483717826379787", "advertisement"]
let cmd = messageArray[0].toLowerCase();
// cmd = "ban"
let args = messageArray.slice(1);
// ["671483717826379787", "advertisement"]
Then you can do:
if (cmd === "ban") {
// CODE
}
hi
Be careful not to spoonfeed, cough
does anyone know why im getting this error, { message: '404: Not Found', code: 0 } ?
Hahahhaa @spare goblet
Thanks for the help.
np
what im doing is: console.log(await createWebhook('735455517509681195', 'hi'))
what im doing is: console.log(await createWebhook('735455517509681195', 'hi'))
Ok, tysm
@earnest phoenix ok
anyone know why im getting: { message: '404: Not Found', code: 0 } ? my code: js async function createWebhook(channelID, name, avatar) { const fetch = require('node-fetch'); const webhook = await fetch(`https://discord.com/api/channels/${channelID}/webhook`, { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bot ${require('./token')}` } }).then((e) => e.json()); return webhook; }
Obviously the message isn't found
How to execute code using exec() function on discord.py?
what message @spare goblet ?
how do i code
thats a very massive question.
it seems so interesting tho π
if you're referring to { message.. in the error...
thats not the error message
not the message which isn't found - and what message isn't found
...
Hey
I have started using a command handler
Is there any way that I can do it such a way
That if person does
s!hell command name
It tells the info like name description and usage ?
Itself
i don't think that's how you use a webhook
@trim saddle i am not referring to webhook
Just do exports.config
@earnest phoenix can u explain a bit more i am not good at coding
Anyone know when the "always-on" repls is coming out? Or how long it's been "coming soon"?
Its up to them, you need to follow da news
Where
Idk blog?
it's not on it
Guys anyone can help me
ββββββββββββββββββββ
βββββββββββββββββββββ
βββββββββββββββββββββ
ββββββββββββββββββββ
ββββββββββββββ
βββββββββββββββ This is Bob
βββββββββββββ ββ
βββββββββββββ ββ Copy And Paste Him In Every Discord Server,
ββββββββββββββββ So, He Can Take
βββββββββββββββββ Over Discord
βββββββββββββββββ (dont spam him tho)
ββββββββββββββββββ
βββββββββββββββββββββββ
βββββββββββββββββββββββ
βββββββββββββββββββββββββ
ββββ βββββββββ ββββββββββββ
Gay
Iβm trying to make a code to collect things from the sky block wiki, such as values and crafting recipes any ideas?
There's an API
oh k then
There's an API
@cinder patio can you dm me that api?
I'm on mobile it'd be faster if you searched it yourself, but I am sure there's one
Ight
By wiki do you mean wikia/fandom?
Yeah
Yea for sure there's one
@hazy sparrow i think
there is an error
with the command file
can u show that
of the coinflip.js
ok wait hold on
alr
module.exports = {
name: 'ping',
description: "this is a ping command!",
execute(message){
const cf = Math.floor(Math.random() * 1001) + 1
if(cf===1 ){
message.channel.send ("**" + `OMG ${message.author.username}!!!` + "**" + `THE COIN LANDED ON ITS SIDES `)
}
else if(cf<=500){
message.channel.send ("** :bowheads: |" + `${message.author.username}` + "**" + ` it was heads!`)
}
else{
message.channel.send ("**" + `${message.author.username}` + "**" + ` it was tails!`)
}
}
}
alr
i found the error
@hazy sparrow the name
the name is ping
change it to cf
but the name of file is cf.js
becuase ping is name
so it will say ping only
@hazy sparrow change name and try again
it should say correct
does anyone know how I can fix Promise { { _misc: [ 'Only dictionaries may be used in a DictType' ] } } ?
my code:
async function sendWebhook(content, username, avatarURL, webhook) {
const fetch = require('node-fetch');
const hook = await fetch(`https://discord.com/api/webhooks/${webhook.id}/${webhook.token}`, {
method: 'post',
body: { content: JSON.stringify(content), username: JSON.stringify(username) }
}).then((e) => e.json());
return hook;
}```
await sendWebhook('hi', 'hi', 'https://bob.png', webhook);
ty
@hazy sparrow mention not
omg
a new change just happend for bots
if u do any cmd which has a link
it will automatically remove link and attach it as an file
wow
for ex like gif
it will hide it!
it does that for humans
not sure
/giphy ok
yes it does
how do i make people add my bot?
i have worked hard on it/ i pay 10$ for it's hosting but people keep removing it from their server
it was in 92 servers 3 days before
and now it is in 86
including 2 my servers
so 84
Not bad although I'd say you should use another color palette
Oh in that case nevermind
interesting font
will the first if statment ever run?
module.exports = {
name: 'bottleflip',
description: "this is a ping command!",
execute(message){
const cf = Math.floor(Math.random() * 101) + 1
if(cf<= 5 ){
message.channel.send (':bowbottlecap: | OMG! The bottle landed on its cap! What a pro!')
}
else if(cf<= 30){
message.channel.send (':bowbottlesuccess: | The bottle stands on the ground! you got lucky there..')
}
else{
message.channel.send (':bowbottlefail: | The bottle landed on its side. LOL')
}
}
}
maybe but only with a 5% chance
If you guys needed help with making your bot online 24/7 feel free to dm me
I can't Get Guild Webhook, it's returned 401 Unauthorized, What should I do?
My Webhook URL is: https://discordapp.com/api/webhooks/ID/TOKEN
In discord.js how would i make it so my bot can detect a language the user speaks and redirects them to another channel? ( if that is possible to do )
Hello, can someone please help me. My bot runs of my raspberry pi and the scripts are still running, it is connected to wifi and the token is correct but my bots are offline?
@cosmic iris have you tried stopping the bot than starting it up again? and have you tried double checking the token? cause the token is above 32 characters.
Yeah I did
Your pi 100% have internet?
did you got a console log?
@normal kraken you could use something like the Google translate API to detect the language
Aight thx @lusty quest xD
I can't Get Guild Webhook, it's returned 401 Unauthorized, What should I do?
My Webhook URL is: https://discordapp.com/api/webhooks/ID/TOKEN
@solid falcon anyone?
Your pi 100% have internet?
@frank jackal Ive been using it for a week
just now it stopped
I checked if my tokens changed and replaced them still doesnt work
its not the pi cuz it doesnt work on my pc too even with new tokens and stuff
Hey Guys
Quick question
If I buy the Developer license, what perks or features will I get.
create announcements channels
that's the only special thing you'll get
and obv publish SKUs
the dev license is meant for gane developers
You buy it once and finish, you have it forever, right?
correct
are you sure member is defined
well assuming you have the message
?
you can use message.member
in the Thumbnail?
well no
you'd have to do
message.member.user.displayAvatarUrl()
you should really read the docs
Can my bot be accepted if it's using a image from google as pfp?
what i need to do?
define person
oh wait i know how
Dm me pls if u can help me i am trying to make my first bot
if you pay me, sure
Uhmm I just need help with making it
@acoustic orchid https://discordjs.guide/
use this site if you want to make a bot
it walks you through everything you need to know
π
it still needs basic understanding of javascript
im assuming all he wanted to do was get his bot up and running
Dm me pls if u can help me i am trying to make my first bot
@acoustic orchid sry for the ping
it gives you instructions on how to do that
not to mention they provide links to js courses
I already have my bot but idk how to add commands
ok also you got then basic knowledge this helps a lot. many users join here and expect to get Spoonfed
Oh ok
yes
half the questions / commands people ask for are already online too lol (noticed this in every dev discord lol)
every command is doing this. heres the mybot.js code https://pastebin.com/qCTW4W2J
looks like it doesnt load the prefix (without looking at the code)
hmm the main file looks ok
thats the problem since i added aliases to one of my commands
module.exports = {
name: 'cf',
description: "this is a ping command!",
aliases: ['coinflip', 'cointoss'],
execute(message){
const cf = Math.floor(Math.random() * 1001) + 1
if(cf===1 ){
message.channel.send ("**" + `OMG ${message.author.username}!!!` + "**" + `THE COIN LANDED ON ITS SIDES `)
}
else if(cf<=500){
message.channel.send ("** :bowheads: |" + `${message.author.username}` + "**" + ` it was heads!`)
}
else{
message.channel.send ("**:bowtails: |" + `${message.author.username}` + "**" + ` it was tails!`)
}
}
}
how did you define the aliases for the other commands?
are the aliases different
its possible that the bot gets them as a empty string and executes every command bcs of this
client.commands.find(cmd => cmd.aliases && cmd.aliases.includes).execute(message); this could be the issue
i dont have aliases for other commands
Hello
yea it looks like you only execute commands that have a alias
anyone?
looks like an error
ik but it was working perfectly for months
maybe you need to update something
or maybe change something.
Does anybody know how to setSelfDeaf a bot?
voicestate#setSelfDeaf(true)?
umm @lusty quest thats weird my other bot isn't displaying errors
but that one bot is
i have no knowledge about py
hmm super weird tho
can someone help me? i have a script to play music but somehow it always skipping the music, not playing it, heres the script
bot.joinVoiceChannel(msg.member.voiceState.channelID).catch((err) => { // Join the user's voice channel
bot.createMessage(msg.channel.id, "Error joining voice channel: " + err.message); // Notify the user if there is an error
console.log(err); // Log the error
}).then((connection) => {
if(connection.playing) { // Stop playing if the connection is playing something
//connection.stopPlaying();
return "> a song was played";
}
const musicStream = ytdl(url, {
audioonly: true
});
connection.play(musicStream); // Play the file and notify the user
bot.createMessage(msg.channel.id, `Now playing **${url}**`);
connection.once("end", () => {
bot.createMessage(msg.channel.id, `Finished **${url}**`); // Say when the file has finished playing
});
});```
can anyone help me find the problem and the solution? (im using js eris)
@lusty quest lol all i had to do was python -m pip install -U discord.py
in my terminal
told you to update
yo if i restart my vps would the docker container running stop?
yes
anyone know how to solve this error with lavalink?
lavalink/server/info/AppInfo has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
My command handler it's working fine with help and some music commands but when I tried using ban, kick, purge it always shown this error, I had 2 command handler the first one I'm using and the second one works on ban but not on music.
the scond one is simplified of the first one.
I use heroku for my bot and website host and I want to use the vote webhook I go to set it up but it doesn't work is that just a heroku issue it doesn't give any errors
depends on how you are using it
The dblpy example is a cog, yes
Ah tnx
how to fix this it says commands.get not a function working on music commands but not in moderation commands.
commands.get(message, args);
} catch (error) {
console.error(error);
message.reply("There was an error executing that command.").catch(console.error);
}```
If using second command handler music command do the same like moderation but the moderation works fine.
what's commands?
@slender thistle and theres a way to put the dblpy direct to code?
Well, yes, if you know what to remove
does anyone have python flask code for a DBL webhook handler as mine is currently not working (they aren't passing anything in headers etc ._.)
tysm β€οΈ
this is what i have
// server.js
// where your node app starts
// we've started you off with Express (https://expressjs.com/)
// but feel free to use whatever libraries or frameworks you'd like through `package.json`.
const DBL = require('dblapi.js');
const express = require("express");
const http = require('http');
const app = express();
const server = http.createServer(app);
const dbl = new DBL(yourDBLTokenHere, { webhookAuth: 'password', webhookServer: server });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running with path ${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});
// make all the files in 'public' available
// https://expressjs.com/en/starter/static-files.html
app.use(express.static("public"));
// https://expressjs.com/en/starter/basic-routing.html
app.get("/", (request, response) => {
response.sendFile(__dirname + "/views/index.html");
});
// listen for requests :)
const listener = app.listen(process.env.PORT, () => {
console.log("Your app is listening on port " + listener.address().port);
});
server.listen(5000, () => {
console.log('Listening');
});```
sadly it has to use python lol
Flask script mainly to handle POST requests from top.gg - shivaco/DBL-python-webhook
hm thx
so the js one does not work?
uh, idk
i have to use python as that's my main codebase lang and api lang
.-.
if request.headers.get('Authorization') == webhook_password:
``` that isn't working though as it isn't passing any headers
its logging the headers here on a successful user vote
seems like i forgot to print theform and post data, now to use another alt to try that .-.
Test button π
"fake", yeah
You get a request as you voting for the bot where request_type will be equal to 'test'
It always comes as a POST request
hm
hm ok
this is the test data ._. @slender thistle
hmm
it seems to not be sending the authorization code as a header?
Did you set the Authorization field as anything?
yes
Mind if I poke 165?
I can't Get Guild Webhook, it's returned 401 Unauthorized, What's URL should look like?
authorize
https://discordapp.com/api/v6/webhooks/700788404195033135/ or something similar
The ID being ID of the webhook
hmm, is there an issue with dbl's webhook system
No, that's not dbl webhooks, that's discord webhooks.
What IP did you route it to?
well now im getting this
What is vote_keys
#topgg-api for API questions please
Β―_(γ)_/Β―
ehh not necessary
well i was asking for code but it kinda broke on me
Did you press Save before pressing Test
yes
Mind sending me your auth key and URL in DMs?
I just got it working I can't host my website and the Web hook at the same time for some reason
They might be on the same port
yeah i see that
// server.js
// where your node app starts
// we've started you off with Express (https://expressjs.com/)
// but feel free to use whatever libraries or frameworks you'd like through `package.json`.
const DBL = require('dblapi.js');
const express = require("express");
const http = require('http');
const app = express();
const server = http.createServer(app);
const dbl = new DBL("~~~", { webhookAuth: '~~~', webhookServer: server });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running with path ${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});
// make all the files in 'public' available
// https://expressjs.com/en/starter/static-files.html
app.use(express.static("public"));
app.get('/', (request, response) => {
response.sendFile(__dirname + "/views/index.html");
});
server.listen(process.env.PORT, () => {
console.log('Listening');
});```
sigh i fixed it
how
how to make this more humanly readable? (discordia)
this is the code
client:on('memberJoin', function(member)
if member.guild.id == "735405634111012985" then
local memberid = member.id
local joinAt = member.guild:getMember(memberid).joinedAt
member.guild:getChannel("735410662016155679"):send("some dude joined at "..joinAt.." !")
else return 0 end
end)
why my bot not here
Guys how to thumbnail bot icon
Dbd
Is this good I am trying to learn how to make a bot this is my first time trying it
Can someone maybe help
with
installing de dblpy
cant help
discord.ext.commands.errors.CommandNotFound: Command "update_stats" is no
t found
i have this error
I want to know how to set botton style
update_stats is a loop, not a command
it runs by itself in the code once you start it
No one know...
update_statsis a loop, not a command
@slender thistle ah
@acoustic orchid dont spam.. if its in your opinion good, then it is good.
hey guys I need help with regex
@acoustic orchid dont spam.. if its in your opinion good, then it is good.
@restive furnace I mean idk I have never done this
says n/a
how do I split a string (example: "1d12h15m7s") into "1d", "12h", "15m" and so on
I am asking if what I did is good
@acoustic orchid Hmmm Your bot may not be able to add to DBL
Split by a non-numeric character (regex probably)
Whatβs dbl
@acoustic orchid Hmmm Your bot may not be able to add to DBL
@hollow crypt yeah, cuz dbd
Bot maker apps are fine as long as the bot isn't a clone of a template
ah, good to know
Hmmm
I am trying to do something but I have like 0 idea of what I am doing
So How to set all button style
@hollow crypt CSS?
@slender thistle Hmmm IDK how to do
I'm asking you what you want to use to edit the "buttons"
Yes css
A rule for button if you want to edit all button elements
@slender thistle ok
apply a certain class to the elements and then add a rule for .yourclass in your CSS if you only want to edit certain buttons
shit
Regenerate that token
my token
yeah
import dbl
import discord
from discord.ext import commands, tasks
import asyncio
import logging
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = 'thetoken' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token)
# The decorator below will work only on discord.py 1.1.0+
# In case your discord.py version is below that, you can use self.bot.loop.create_task(self.update_stats())
@tasks.loop(minutes=30.0)
async def update_stats(self):
"""This function runs every 30 minutes to automatically update your server count"""
logger.info('Attempting to post server count')
try:
await self.dblpy.post_guild_count()
logger.info('Posted server count ({})'.format(self.dblpy.guild_count()))
except Exception as e:
logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
# if you are not using the tasks extension, put the line below
await asyncio.sleep(1800)
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(TopGG(bot))
token regened
what's the error
just when I thought I needed to update the docs everywhere
?
A simple API wrapper for top.gg written in Python. Contribute to DiscordBotList/DBL-Python-Library development by creating an account on GitHub.
see the example including update_stats
aka the first one
-faq @analog kestrel
...
-faq 1
Is this better?
yes
I'm asking you what you want to use to edit the "buttons"
@slender thistle Oh sorry...Its HTML...
You want to edit all <button> elements, correct?
Yes
It automatically grabs length of client.guilds and posts it on the website
aka what update_stats currently does for you
ah, and whitch is better?

