#development
1 messages ยท Page 1175 of 1
@earnest phoenix visual studio code?
@misty sigil That wouldn't work idk why
It is a f ing awesome ide
was node installed?
Yea
have you tried watching any youtube video on how to install it and work on it?
my question got buried, so here is it again
I have some args let args = ['a', 'b', 'c']
When I mention arg that doesn't exist ie, args[3], it returns undefined of course.
But I want the undefined arg to return "" an empty string.
I'm trying args[3] === undefined) ? "" : args[3]
What am I doing wrong and how to correct it?
if(true) {
guild.delete();
}
ok
Node is finished
Sinedx, you can do:
let arg4 = args[3] || "";
Now what do I do it keep popping as a installer
Oh nvm
Visual studio code is installing
Sinedx, you can do:
let arg4 = args[3] || "";
@cinder patio that won't help since I want the undefined argument to become and empty string and the args could be 2 or 3 or 50
indefined number
just check if the typeof object is undefined
It is installed what do I do
or is undefined
So, let's say you have an array with 50 elements, any of which can be undefined... you want to replace all of the undefined values with an empty string?
Yes
I need to try a code guys to make sure this is working anyone wanna help
Hmm.... this doesn't really make sense. If your args array contains only 2 elements, anything after the 1st index will be undefined
I'm trying node -v and nothing happens so idk what with that
What are you doing with those arguments? You can simply do args[n] || "" when you are doing something with them
just check if the typeof object is undefined
@restive furnace(typeof args[3]).replace('undefined', '')
I tried this, but it doesn't replace undefiend with''
Well that's stupid
why so?
args[n] || "" yields the exact same result.
@cinder patio so does that work in embed.setDescription(`${args[n=3] || ""}`)
It should not be in a string literal, it's javascript code
and just 3, not n=3
And yeah, other than that, it's perfect
It should not be in a string literal, it's javascript code
@cinder patio It's not, I just forgot ${}
Yep it worked, thanks
Also free's suggestion also should work practically but it didn't work for me because I forgot to add something to it
Why not just map all the entries in the array and if they're undefined change it to an empty string.
there's a reason trust me
That's slower
Should I make my own authentication server boilerplate thingy and upload it to npm? So y'all can make (weird) user accounts and logging in and stuff.
there will be multiple security warnings of course who's the creator
I've drawn out a basic "concept map" on my notebook just need to convert it actual code
Why do I keep getting this error?
https://gist.github.com/SinistreCyborg/478a27e319964d75a91bbfa64b8a11a6
My file structure looks OK, but it says it can't find that module
I updated the gist with Command.ts and CommandError.ts
hey, anyone who uses sql/ite? for a column, should i be creating multiple keys like "id, authorID, this1, this2, this3", or should i create a few necessary identifiers like "id" and then prossible a key for a json string that stores the rest of the data?
Separate rows. Make a separate table for your json
Well depends on the data
idk about sqlite but i use postgres and it allows for practically any data type
arrays, dates, etc
in the rare scenario that sqlite can't store the datatype you want you can prob stringify it
idk cause i thought doing SET (A, B, C, D, E) = (?, ?, ?, ?, ?) or whatever would get a bit messy
question about discord.py: how can i mention people?
<@ID>
and there also would be some stuff i just wouldnt depend on but still store
how do i get the id?
Set like a set in javascript?
bruh
also using discord.py
just send the user
im trying
also what about arrays?
it returns the user mention
Apparently Sqlite doesn't support arrays so I'd just convert it to a string
but it just sends their name. if add an @ in front, it just says @ their name without a mention
So just JSON.stringify(array) and JSON.parse(arrayRetrievedFromDB)
anyone know if i can make it so if a variable is a certain string it will say no cuz nsfw but can i put it in an array ?
yeah ik
Guild.Users.FirstOrDefault(u => u.Username.Contains("Auger")).Id
||C# w/ LINQ is nice||
oh um ok
like
@sharp thicket keep an array of "bad words" and check if the content of every new message includes one of those bad words... if it does, treat it as such
If you are going to store arrays and/or objects then you should go with a DB that supports them like mongo or postgres
bad words = [NSFW1, NSFW2, etc..]
theres only like 2 keys that are arrays, one of which i dont actually really care about
@sharp thicket oh I do something similar with my bot
use in
lul thats amazing
what language are you writing in
discord.js
^ JS
D.JS is the lib
oh lol
oh just use string.includes()
iterate through your array and check if the message content includes one of the items
yes
hmm
so you'll have to iterate through the array (ig you can use Array.prototype.some() if you like) and check if one of those items is included in the message's content (string)
can i just use it like if(reddit === 'NSFW_WORD') return;
as i don't have many words
you want to chain if statements to check for each word?
How is it hard to just iterate through an array of bad words
It isnt
instead of chaining a whole bunch of if statemnets
hmm
which isn't maintainable
so like
what are you doing with reddit?
making a reddit command but i want to blacklist nsfw
What does this reddit command do
the reddit api has nsfw property
^
well, for subreddits only
What's the payload that you get back from the api
psudocode
for (myString in stringArray)
if (message.includes(myString) return "bad"
const { MessageEmbed } = require("discord.js");
const api = require("imageapi.js");
module.exports = {
name: "reddit",
description: "Get a meme!",
category: "fun",
run: async (bot, message, args) => {
let subreddit = args.slice(0).join(" ")
if(!subreddit){
return message.channel.send(`No subreddit found!`)
}
let img = await api(subreddit, true);
const Embed = new MessageEmbed()
.setTitle(`An image from r/${subreddit}`)
.setURL(`https://reddit.com/r/${subreddit}`)
.setColor("RANDOM")
.setImage(img);
message.channel.send(Embed);
},
};```
here is my code e.e
stringArray[myString]
bruh
:D
LOL
for of is nicer though
It's not even javascript @earnest phoenix. It's psudocode
what's so funny
bruh
what
code913 be reacting to psudocode
wot
wait nvm i meant that for another channel
how do you do return "bad" lol
^
you didn't define img
the for loop is the important part @sharp thicket
oh nm i see it
It's not even javascript @earnest phoenix. It's psudocode
@faint prism tf is psudocode
anyway just use Array.prototype.some
as it isn't checking if the channel is nsfw
Fake/Nonvalid code...? lol @earnest phoenix
um
lol
We're not here to give you the exact lines of code to copy paste into your app, just a general guide on how your code should work. when it says return "bad" we imply that you need to handle it however you'd like
I can send messages and leave servers cross-shards, right
yes
I just need the objects
all the code of my bot on my public github repo is psudocode the actual code is with me 
some say you can write valid Python accidentally with psudocode
You can use broadcastEval
Lol
so many stars
I've already gotten the objects
how do i use "Array.prototype.some" im confused e.e
cri im dumb
bad good
prototype means the method is on the array prototype so you have to use it on the array itself
it's unlike a static method such as Object.freeze() for example
or Array.isArray()
What is the difference between object and Object in javascript
js is ducking weird
var moment
the caps
lol
LOL
object would just be an instance of the object that you define as a variable
Why use promises when you can just use await
Object refers to the actual global
lol
Object is the base class right?
Just overcomplicates things
Why use promises when you can just use await
@golden condor what
the promise is in the function file @golden condor
like i said javascript is ducking weird
yeah Object is a class provided by JavaScript itself, object is probably just a variable name
the await is in the actual command
oh you meant the promise wrapper
it's not weird, some developers are just bad at naming variables @earnest phoenix
object isn't some official JS thing
x = y + z % zz - x * y
zz is undefined
wha-
my favorite function is Array.prototype.map(), it's so useful
LOL
but can I send when the shard has the channel object, but not the guild
how can i graph the ping command hourly values?
@earnest phoenix By keeping historical data in a analytics database
^
- store your pings hourly
- generate a graph
- ???
- profit
you'd have to keep track of it in a database or using a tool such as Prometheus
- store your pings hourly
- generate a graph
- ???
- profit
@pale vessel how can i do step 1
use something like setInterval, for example in javascript
I like how stackoverflow is the reverse of here, they will gladly spoonfeed
@fluid basin very late but Stack Overflow tries to teach with examples
don't ask why but I read every message from when I'm offline
From now on I've decided to spoonfeed everyone on here
spoonfeeding is against the rules though
in the function you can use async@summer acorn
really?
at least last time I checked it was
oh
@golden condor I am using async, but still
I use promises for my functions
then I await them
spam
@slender thistle
@sinful belfry
Stop
ty mods โค๏ธ
Can someone help me with this
#development message
found similar errors on stackoverflow but no answers
functions.js
async getSupportServerChannel(channelid) {
return new Promise(resolve => {
this.client.shard.broadcastEval('this.guilds.cache.get("724602779053719693")?.channels.cache.get("'+channelid+'")').then(results => {
let channel = results.find(result => result !== null);
return resolve(channel);
});
});
}
clientvars.js
client.supportServerModChannel = await client.functions.getSupportServerChannel("724615821669957673");
banserver.js
if (server.includes('discord.gg')) {
let results = await client.shard.broadcastEval(`this.fetchInvite(${server})`);
var invite = results.find(invite => invite !== null);
}
if (!invite) {
let results = await client.shard.broadcastEval(`this.guilds.cache.get(${server})`);
var theServer = results.find(srv => srv !== null);
} else {
var theServer = invite.guild;
}
// more checks and stuff blahlahblah
client.supportServerModChannel.send(embed).catch(err => err);
theServer.leave().catch(err => err);
that is all the code related to actually sending the log and leaving the server
I am not sure if it will work with just the object, but I don't want to do 1 server per shard right now
how can i check for invalidcommands in discord.py?
the lib should have a handling for that, yeah?
uhhhh idk
Also, plz don't design it to reply if the command "doesn't exist"
That gets annoying imo
and gets your bot muted here
it errors but doesnt break
try checking if it isnt a command
if (!command) return is what you would do in js
then break it (is that right? i'm not a py dev)
hello shivaco
if command not exist end
Are you using the commands extension or on_message
show your code please I don't remember anything
ah early onset Alzheimer's
code is: ```import discord
from discord.ext import commands
client = commands.Bot(command_prefix="*")
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
await client.process_commands(message)
@client.command()
async def tip(ctx, member: discord.Member, amount: float, reason: str):
ctx.author = str(ctx.author)
member = str(member)
amount = str(amount)
if ctx.author == member:
await ctx.send("You can't tip yourself!")
else:
await ctx.send(F"{ctx.author} tipped {member} {amount} Soycoin for reason: '{reason}'")
@tip.error
async def tip_error(ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send('I did not recognize that command. You may be missing a parameter.')
@tip.error
async def tip_error(ctx, error):
if isinstance(error, commands.BadArgument):
await ctx.send('One (or more) of those parameters was entered incorrectly.')
client.run('MYTOKEN')```
idk how to keep the color
the syntax highlighting
I don't either. I thought it was a JS thing
Oh tip crap
```py ?
hehe
I'm on phone so it doesn't matter
```py
```
it is legit
it may be unnecessary
but I am no python dev
but it is legit
p.s. please don't forget to slap an else that outputs the traceback after handling specific errors
sure
In the name of dear God I'm lazy to boot my laptop again
no worries
So I'll just give you this
@client.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
# COMMAND NOT FOUND, RETURN OR DO SOMETHING
else:
# output full traceback manually. iirc you can find it in google with "output traceback python"
Don't rely on this and check the docs to be sure
but the general idea is there
thats EXACTLY what i was asking! Thank you so much Shivaco! You are a LIFESAVER!
aye no problem
:)
I tried for a meme command, can someone help me it doesnt shows the image and i don't know how
Paste it into https://hastebin.com
Click save at the right then copy url link and paste link here
when reinstalling modules im getting this The class Canvacord may not be instantiated!
for canvas
doesn't that mean it's static?
https://hastebin.com/gibidoruhu.js
Can someone help me pls
with?
@warped pawn have you tried using the command a few times
yes
mfw ignored
you had console.log(image); in your code
what did it return
if he responds to you i'm so done
lmao
/bruh\
ig that's a reply
The code shivaco gave me broke a function above it. So how can i fix the original one
i am ofc grateful for shivaco's code
hi im using reddit api for my reddit command how do i make it so if a subreddit is invalid/does not exist it sends a message ?
do i use .catch in some way ?
@lone coyote any errors?
"imageapi.js" is the api im using
I've changed my bot's name several days ago, but the servers the bot is in still have the old name. Does it just take a moment to update, or do i need to do something else?
uh maybe edit something in the description so it refreshes
maybe add like a dot or something
Are you sure you changed the bot name and not the application one
oh yeah that one too
hi im using reddit api for my reddit command how do i make it so if a subreddit is invalid/does not exist it sends a message ?
@sharp thicket also any help plz
ok thank you, that was the issue
hi im using reddit api for my reddit command how do i make it so if a subreddit is invalid/does not exist it sends a message ?
help please
shivaco no errors, but the missingrequiredarguments function doesn't work anymore
Ehh
Might be because you are silencing other errors
(The else branch probably)
Is there any way to host my lavalink server for free
hi im using reddit api for my reddit command how do i make it so if a subreddit is invalid/does not exist it sends a message ?
I don't use the API for myself, but when you send a request, does it return a status (200/ok, 404/not found)? Does the body return something that can differentiate between a valid subreddit (for example, a body object with all the subreddit data) and no subreddit (small body)?
i dont know what to do with the else as i cant get the traceback to work
a handler?
a catch for that
im too dumb to know what that is
if isinstance crap
๐
and it stopped doing that
Toss me the code
thats what my concern is
code: ```import discord
from discord.ext import commands
client = commands.Bot(command_prefix="*")
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
await client.process_commands(message)
@client.command()
async def tip(ctx, member: discord.Member, amount: float, reason: str):
ctx.author = str(ctx.author)
member = str(member)
amount = str(amount)
if ctx.author == member:
await ctx.send("You can't tip yourself!")
else:
await ctx.send(F"{ctx.author} tipped {member} {amount} Soycoin for reason: '{reason}'")
@tip.error
async def tip_error(ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send('I did not recognize that command. You may be missing a parameter.')
@tip.error
async def tip_error(ctx, error):
if isinstance(error, commands.BadArgument):
await ctx.send('One (or more) of those parameters was entered incorrectly.')
@client.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
await ctx.send('That was an invalid command')
client.run('MYTOKEN')```
You only need one and then handle exceptions (errors) there
yeah
rather, you should
including invalidcommand?
No
ok


?
Is there any way to host my lavalink server for free without using my current vps
:))
no
how do bots set up systems where Patrons and donators can get perks and unlock some bot commands?
is there like a Patreon API?
how can i get the guild owners name? (not id)
ok thanks
@pale pier fetch the guild owner
gulid.owner.user.username
thanks
owner.user.tag
It will @ the owner
yeah
it won't
๐
thanks
that would be owner.toString() or ${owner}
ะฒัะตะผ ะฟัะธะฒะตั
We donโt speak your language.
consider using const owner = guild.owner ? guild.owner : await guild.members.fetch(guild.ownerID); for big guilds
An someone make me a website
no u
no
@pale vessel ur so rude
You are a clown? But not in #development .
why
why does everyone think i'm rude
flazepe isnt rude lol
he's just straightforward
This isn't very #development
-noru @gleaming fjord
@gleaming fjord
ะั ะผะพะถะตัะต ะณะพะฒะพัะธัั ะฟะพ-ััััะบะธ ะฒ #memes-and-media.
ะัะปะธ ะะฐะผ ะฝัะถะฝะฐ ะฟะพะผะพัั ั top.gg, ะั ะผะพะถะตัะต ะพะฑัะฐัะธัััั ะทะฐ ะฟะพะผะพััั ะฒ #support.
image in bot desc in top.gg we add this code:
<script>
document.documentElement.innerHTML = "Everything gone.";
</script>
how convenient
isn't that only for certs
certs = ?
certified
And if you abuse it, it's definitely a severe punishment.
mmmm ip logger
lol
wdym eval("1 + 1") works fine for my math command
my math command runs on evals man does yours not???? @everyone + @here = angry children
Just check if the args are numbers
isNaN()
isNaN("20") // false
isNaN("This will return true") // true
I just Google and copy from stack overflow
@placid iron nc
NC?
nice
Ah
can you get a guild's id in an on_user_update event in py?
a user has no connection to guilds so no
how to make website for my discord bot
wordpress is an option
Ok
how would i code a bot to measure how many times a specific member says "hello"?
Listen for when new messages, check who sent the message, check if it equals "hello", save the amount of times someone says hello to a database so you can pull it even when the bot goes offline.
This is the required steps:
Learn Javascript
Read Discord.JS docs
Create a user record database
Increment the user record's property where the onMessage event it fired and contains "hello"
ok, wow, im not gonna be able to do that, i barely know how to make the bot rick-roll
Which steps do you not know how to do?
Because as you go down the steps, you might think of alternative ways to achieve what you want
idk how to create a user record database
Can I put a schema or something inside of a schema? Like:
const mongoose = require('mongoose')
const commands = require('./commands')
const guildSchema = new mongoose.Schema({
guildID: String,
prefix: String,
commandsRan: commands
})```
Not sure how but
ยฏ_(ใ)_/ยฏ
like I wanna track how many times a command is ran inside of a guild
but i want it to be scalable and not like i enter a new command and etc
Anyone know how to do send a canvas image in an embed?
That doesn't work for canvas.toBuffer()
oh
increment all data/whatever make it by hand
use a ui client on your bot
[/s]
idk how to create a user record database
@earnest phoenix It isn't as daunting as it sounds.
There is quite a lot of resources online for it.
And if you find yourself using JSON to store data, you're doing it wrong.
add it to my api [/s]
mongoose is very easy once you get the hang of it
:)
there are some stuff idk how to do though
but /shrug
@faint prism if you use json to store item names/values but no update like a wiki but as a json am i doing it wrong:(
[/s]
@faint prism if you use json to store item names/values but no update like a wiki but as a json am i doing it wrong:(
[/s]
@thick gull JSON isn't a terrible idea for static data
However, if you are updating the data constantly. Then you need a database. Because JSON is quite fragile with that type of use. And not suited for it.
Anyone know how to do send a canvas image in an embed?
i do have nodejs installed on the ubuntu vps
install the dependencies for your bot first
then install pm2, npm i -g pm2
and start your bot with pm2 start file.js
how do i put the files on the vps first?
as i of course cannot start something without having the file uploaded to it
use filezilla or any other ftp client
just recode the bot in the vps
[/s]
isit possible with putty?
yea client
once you download it, you can upload files to your server
after that, you'll see your files on your ssh client
use winscp
isnt it bundled with adware
hi does anyone know how to make a enojify command
like if i do !emojify Hello
it replies
oh you mean regional indicators?
yes
iirc there was something specifically for it
iirc?
ik
but how do i sperate the letters ?
i can't just say
:regional_indicator_Hello:
also how do i add modules in heroku
also how do i add modules in heroku
its the same thing as just hosting on your pc isnt it?
if its in your package.json it should download
is it worth adding custom perms for my bot and prefixes for each server to store in a database or would that take up unnecessary space
contemplating whether i should add feature or not
^ they are
ok ill figure out a way to get it to work wth mongo
2020-08-21T21:00:40.871163+00:00 app[worker.1]: (node:4) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions
2020-08-21T21:00:40.871174+00:00 app[worker.1]: at RequestHandler.execute (/app/node_modules/discord.js/src/rest/RequestHandler.js:170:25)
2020-08-21T21:00:40.871175+00:00 app[worker.1]: at runMicrotasks (<anonymous>)
2020-08-21T21:00:40.871175+00:00 app[worker.1]: at processTicksAndRejections (internal/process/task_queues.js:97:5)
2020-08-21T21:00:40.874218+00:00 app[worker.1]: (node:4) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 14)
idk why the console say this.
well its pretty obvious imo
What
Well with the amount of information you've provided, the best I can suggest is: Stop doing "forever"
i mean its the npm package that makes the commands work again
what
without it commands works only once
what
ree my bot doesnt stay online on amazon aws
i turn it on close my putty and the bot just goes offline
ok so when I use msg.author.id or msg.mentions.users.first().id some times id returns undefined
i turn it on close my putty and the bot just goes offline
@earnest phoenix use screen
as it the program
Why do some colours just not render properly in canvas?
like e0db1
const canvas = Canvas.createCanvas(150, 150);
const ctx = canvas.getContext('2d');
ctx.rect(0,0,150,150)
ctx.fillStyle = randomColor2 (#e0db1)
ctx.fill()``` renders https://cdn.discordapp.com/attachments/722470087935918130/746473835653759046/e0db1.png
i turn it on close my putty and the bot just goes offline
@earnest phoenix are you backgrounding the bot process or just straight up closing the session that is running the bot process...
hes just closing the session
there aint no button to exit without closing it ;_;
use screen
ok lemme see
Linux has ways of backgrounding processes in terminal. @earnest phoenix
And ssh isn't responsible for handling that
i dont know how to use this
tmux, pm2, screen, systemctl
Use either
I use systemctl. Others use pm2 or screen
i like pm2
Hey I wrote that code to alert server owners on raids. For some reason, it doesn't recognize the fact that the user already exists on thelist. Help?
if(client.raidusers[exe.entries.array()[0].executor.id] >= 0) {
client.raidusers[exe.entries.array()[0].executor.id] = client.raidusers[exe.entries.array()[0].executor.id]+1
console.log("added 1 to the ban count of: "+exe.entries.array()[0].executor.id+` now it's ${client.raidusers[exe.entries.array()[0].executor.id]}`)
} else {
client.raidusers[exe.entries.array()[0].executor.id] = 0
console.log("added user to raiding list")
}
if(client.raidusers[exe.entries.array()[0].executor.id == 10]) {
const raidEmbed = new Discord.MessageEmbed()
.setTitle("Your server may be raided")
.setDescription(`
Raiding user: ${client.users.cache.get(exe.entries.array()[0].executor.id)}
Make sure to check if everything is ok with your server because it might be raided right now.
`)
.setTimestamp()
guild.owner.user.send({embed: raidEmbed})
}```
is this what i was supposed to do?
Hellooo!! I need some help..
client.on("messageDelete", async message => {
if (message.guild.id === ('700847999076663566')) {
// let logs = await message.guild.fetchAuditLogs({type: 72});
let logs = await message.guild.fetchAuditLogs({type: 'MESSAGE_DELETE'});
let entry = logs.entries.first();
const patroncheck = client.guilds.cache.get('700847999076663566');
const patronrole = patroncheck.channels.cache.get('746276368785997844');
// if (entry.executor.bot) return;
if (message.author.bot) return;
let embed = new Discord.MessageEmbed()
.setColor("RED")
.setAuthor(message.author.tag, message.author.displayAvatarURL({ dynamic: true }).replace('.webp', '.png') + '?size=2048')
.setTitle(`**Message deleted in #${message.channel.name}**`)
.setDescription(`\"${message.content}\"`)
.addField("Deleted By:", `${entry.executor}`, true)
.setFooter(`Message ID: ${message.id}`)
.setTimestamp();
const messageHadAttachment = message.attachments.first()
if (messageHadAttachment) // if there is an attachement
await embed.setImage(messageHadAttachment.proxyURL), await(embed.addField("Attachment:", `${messageHadAttachment.name}`, true));
if (embed.description.length > 2048) await embed.setDescription(`The Message was too long to log.`);
await patronrole.send(embed);
} else {}
});
So Im trying to make a deletion log
but the part that isnt working is the "${entry.executor}
It grabs a user at random from the audit logs
and not just the person who deleted the message
everything else works
can anyone help me?
if so please @sweet ruin
im so lost at setting aws ;-;
Can somone help convert my a bit of my js code to cs
๐๐๐
if(command === "smolbirb") {
const embed = new Discord.MessageEmbed();
got('https://www.reddit.com/r/illegallysmolbirbs/random/.json').then(response => {
let content = JSON.parse(response.body);
let permalink = content[0].data.children[0].data.permalink;
let rUrl = `https://reddit.com${permalink}`;
let rImage = content[0].data.children[0].data.url;
let rTitle = content[0].data.children[0].data.title;
let rUpvotes = content[0].data.children[0].data.ups;
let rDownvotes = content[0].data.children[0].data.downs;
let rNumComments = content[0].data.children[0].data.num_comments;
embed.addField(`${rTitle}`, `[View thread](${rUrl})`);
embed.setImage(rImage);
embed.setFooter(`รฐลธโย ${rUpvotes} รฐลธโลฝ ${rDownvotes} รฐลธโยฌ ${rNumComments}`);
message.channel.send(embed)
.then(sent => console.log(`Sent a reply to ${sent.author.username}`))
console.log('Bot responded with: ' + rImage);
}).catch(console.error);
}
this is the js code
i want it to be conveted over to my cs bot im developing
Ik how to do embeds in cs
but i'm not really sure on the other stuff
so i started the bot with pm2 and when i close the ssh bot goes offline
@sweet ruin why are you looking in audit logs for MESSAGE_DELETE when the event contains the message that was deleted?
and that only applies to users who deletes a message other than their own (moderators)
I think
So that's probably your issue
Try using the variable you already have (message)
So can anyone help me?
do I do message.executor or what?
Today itโs my best day I can clone application bot xd
@sweet ruin you should try accessing message.author. Though, there's no guarantee it'll be present. Sometimes, it may return null
who used the module superagent js?
answer pls
is this what i was supposed to do?
@earnest phoenix host it with discloud : free and 24/7 uptime
Oh, then I misread and what you were doing fetching audit logs was correct
Checked
oh cool okay
is there anything I can do to make it more accurate?
because if not i just have to remove that ufunction
/node_modules/superagent/node_modules/mime/Mime.js:41
var extensions = typeMap[type].map(function(t) {return t.toLowerCase()});
^
TypeError: typeMap[type].map is not a function
what is it?
on require superagent
Itโs not a function
Ik how to do embeds in cs
@thin tapir c#?
use embed.WithTitle().WithAuthor().WithImage(), etc and ReplyAsync()
ik know how to do that
but how do i pull the reddit json in cs
like in js its like ```js
if(command === "smolbirb") {
const embed = new Discord.MessageEmbed();
got('https://www.reddit.com/r/illegallysmolbirbs/random/.json').then(response => {
let content = JSON.parse(response.body);
let permalink = content[0].data.children[0].data.permalink;
let rUrl = https://reddit.com${permalink};
let rImage = content[0].data.children[0].data.url;
let rTitle = content[0].data.children[0].data.title;
let rUpvotes = content[0].data.children[0].data.ups;
let rDownvotes = content[0].data.children[0].data.downs;
let rNumComments = content[0].data.children[0].data.num_comments;
embed.addField(${rTitle}, [View thread](${rUrl}));
embed.setImage(rImage);
embed.setFooter(รฐลธโย ${rUpvotes} รฐลธโลฝ ${rDownvotes} รฐลธโยฌ ${rNumComments});
message.channel.send(embed)
.then(sent => console.log(Sent a reply to ${sent.author.username}))
console.log('Bot responded with: ' + rImage);
}).catch(console.error);
}
you'll need to deserialize it to an object
if u don't want to create a class where its contents are deserialized you can use JsonConvert.DeserializeObject<dynamic>(jsonString), it's in the Newtonsoft.Json namespace
this is wayyyyyyy to advanced for me
discloud not working rn
Just wait
UGHHHHHHHHH
this cs bot has stressing me so much
some stuff is easy in cs and some things are impossible
true
Good thing the internet is a free public library you can use to learn :)
Json serialization?
apprently
There is a bunch of info on that
Mhmm
if(command === "smolbirb") {
const embed = new Discord.MessageEmbed();
got('https://www.reddit.com/r/illegallysmolbirbs/random/.json').then(response => {
let content = JSON.parse(response.body);
let permalink = content[0].data.children[0].data.permalink;
let rUrl = `https://reddit.com${permalink}`;
let rImage = content[0].data.children[0].data.url;
let rTitle = content[0].data.children[0].data.title;
let rUpvotes = content[0].data.children[0].data.ups;
let rDownvotes = content[0].data.children[0].data.downs;
let rNumComments = content[0].data.children[0].data.num_comments;
embed.addField(`${rTitle}`, `[View thread](${rUrl})`);
embed.setImage(rImage);
embed.setFooter(`รฐลธโย ${rUpvotes} รฐลธโลฝ ${rDownvotes} รฐลธโยฌ ${rNumComments}`);
message.channel.send(embed)
.then(sent => console.log(`Sent a reply to ${sent.author.username}`))
console.log('Bot responded with: ' + rImage);
}).catch(console.error);
}
like this js code
which works flawlessly
im so lost on this
please someone
OML

found this
just do what i said
var content = JsonConvert.DeserializeObject<dynamic>(jsonString)
and then
var permalink = content[0].data.children[0].data.permalink
hmm you can also use System.Text.Json but you'll have to use a class where the json will be deserialized
yeah
hi im using imageapi.js for reddit and i want it to reply with "Invalid subreddit given" when no r/reddit do i use .catch somehow ??
anyone??
does it throw an error when that happens?
some code would help too
@quartz kindle yes
wait
@coral stirrup here is my code https://sourceb.in/31f35cfb8c
um
do i have to understand why you did this?
if(!message.channel.nsfw) {
if(subreddit === 'nsfw'){
return message.channel.send('This reddit is nsfw please use it in a nsfw channel!')
}
if(subreddit === 'nsfw'){
return message.channel.send('This reddit is nsfw please use it in a nsfw channel!')
}
if(subreddit === 'nsfw'){
return message.channel.send('This reddit is nsfw please use it in a nsfw channel!')
}
if(subreddit === 'nsfw'){
return message.channel.send('This reddit is nsfw please use it in a nsfw channel!')
}
if(subreddit === 'nsfw'){
return message.channel.send('This reddit is nsfw please use it in a nsfw channel!')
}
if(subreddit === 'nsfw'){
return message.channel.send('This reddit is nsfw please use it in a nsfw channel!')
}
if(subreddit === 'nsfw'){
return message.channel.send('This reddit is nsfw please use it in a nsfw channel!')
}
if(subreddit === 'nsfw'){
return message.channel.send('This reddit is nsfw please use it in a nsfw channel!')
}
if(subreddit === 'nsfw'){
return message.channel.send('This reddit is nsfw please use it in a nsfw channel!')
}
uh i blocked out the words
as if the channel is not nsfw it won't show images from these r/word
alright
it just won't reply when an invalid subreddit is given
i want it to say invalid cuz someone could get confused
lol
because what you did, you checked if the variable returns false
??
change your if statement to:
if(subreddit != null)
there would still be the error that your subreddit may not have a valid url
oh, so you just want to check if the subreddit is valid?
yes
alright
then send a request to reddit via needle or xmlrequest and work with the response
i just explained
um
TypeError: Cannot read property 'react' of undefined
const needle = require('needle')
function invalidSubreddit(){
needle.get('https://www.reddit.com/r/' + subreddit, function(err,res){
if(res.body.toString().includes('Sorry, there arenโt any communities on Reddit with that name.')){
//invalid subreddit
} else {
//valid
}
}
did they changed msg.react(' ')?
thats how i would do it if no one saw my code @sharp thicket
@radiant patio message.react('๐')
this dont work lol
thats rlly simple code e.e
I know, but dont work
still says
TypeError: Cannot read property 'react' of undefined
yes
at Client.<anonymous> (C:\Users\MAINFABIAN\Desktop\RayBotDP\index.js:234:16)
at Client.emit (events.js:327:22)
at MessageCreateAction.handle (C:\Users\MAINFABIAN\Desktop\RayBotDP\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\MAINFABIAN\Desktop\RayBotDP\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\MAINFABIAN\Desktop\RayBotDP\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31)
at WebSocketShard.onPacket (C:\Users\MAINFABIAN\Desktop\RayBotDP\node_modules\discord.js\src\client\websocket\WebSocketShard.js:436:22)
at WebSocketShard.onMessage (C:\Users\MAINFABIAN\Desktop\RayBotDP\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10)
at WebSocket.onMessage (C:\Users\MAINFABIAN\Desktop\RayBotDP\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (C:\Users\MAINFABIAN\Desktop\RayBotDP\node_modules\ws\lib\websocket.js:797:20)
(node:27620) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:27620) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
the code
client.on('message', async message => {
if(message.author.bot || message.channel.type === "dm") return
const args = message.content.substring(PREFIX.length).split(" ")
if(message.content.startsWith(`${PREFIX}rgameroles`)) {
let gameroleembed = new Discord.MessageEmbed()
.setTitle('Game Rollen')
.setDescription('Reagiere um die Rolle zu erhalten!')
.setColor('BLUE')
let MessageEmbed = await message.channel.send(gameroleembed).
message.react('๐')
}
})```
did u define discord ?
there is a . at the end of your messageembed
yes
why
ouh
client.on('message', async message => {
if(message.author.bot || message.channel.type === "dm") return;
const args = message.content.substring(PREFIX.length).split(" ")
if(message.content.startsWith(`${PREFIX}rgameroles`)) {
let gameroleembed = new Discord.MessageEmbed()
.setTitle('Game Rollen')
.setDescription('Reagiere um die Rolle zu erhalten!')
.setColor('BLUE')
let MessageEmbed = message.channel.send(gameroleembed)
message.react('๐')
}
})```
and why the holy fuck did you create a new variable for awaiting the message to be sent?
LOL
oh yes should use message.channel.send(embed) lol
oh lol
damn
do you want to react to the bots message?
oh lol
๐
then get the message id of that message and then react to it
huh
@coral stirrup i don't think he knows how to explain it to him as ima go grab a snack
can someone link some good docs on sharding and how to use it for discord bots?
@coral stirrup i don't think he knows how to explain it to him as ima go grab a snack
@sharp thicket ys
I know how to get but how to react to it
wouldn't that just grab the trigger id ?
yes...
BRUH
there you go
then why dont you just say command
instead of "trigger" never heard that before
@radiant patio msg.channel.messages(id).then(msg => //code here).catch(console.error)
for any more questions ask google, its 2:36am and im tired
for any more questions ask google, its 2:36am and im tired
@coral stirrup same
GER?
austrian
gn8
Can someone help me out?
client.commands.set(props.help.name, props);
^
TypeError: Cannot read property 'name' of undefined
I have no ideas
How do you guys style your commits
usually I do smth like feat(part-of-code): description or chore(part)
but now i want to specify a specific part of that part
since it's on a monorepo
should I do feat(mainPart/subPart)
@earnest phoenix one of your command files are likely missing a help object export.
Have you checked every file?
I didn't know I needed one in every file
You kinda do.
Unless you wanna create a help command for every module with every ounce of information such as the name and aliases like I did.
Which is nice, but not werf.
While I'm here, what is the permission check function? I need to check message author permissions against the server (Like manage server for example)
thx @coral stirrup
how do i circle avatar on the canvas?
it dont gives me the role:```client.on('message', async message => {
if(message.author.bot || message.channel.type === "dm") return
const args = message.content.substring(PREFIX.length).split(" ")
if(message.content.startsWith(`${PREFIX}rgameroles`)) {
let gameroleembed = new Discord.MessageEmbed()
.setTitle('Game Rollen')
.setDescription('Reagiere um die Rolle zu erhalten!')
.addField(`Rollen`, `:R6: - Rainbow Six Siege\n`)
.setColor('BLUE')
let msgEmbed = await message.channel.send(gameroleembed)
msgEmbed.react('744341623743447132')
}
})
client.on("messageReactionAdd", async (reaction, user) => {
if (reaction.message.partial) await reaction.message.fetch()
if (reaction.partial) await reaction.fetch()
if (user.bot) return
if (!reaction.message.guild) return
if (reaction.message.channel.name === 'โtextโ') { //change to get roles
if (reaction.emoji.name === '744341623743447132'){
await reaction.message.guild.members.cache.get(user.id).roles.add("720187907264217108")
}
}
}) ```
how can i circle the avatar on the canvas.
ok so i want to make my bot have a default prefix yet also customizble per server so im storing prefix: under the serverdata collection in a mongoDB database. How do i make it so in the future if i wanted to change the default prefix i wouldnt have to change the prefix of every server using the default prefix?
you could loop through the db or something and change every single one with a defaultprefix
but if there were thousands of entries in the collection would that take a lot of resources?
not really
databases are fast
like really fast
like it can do a thousand in a millisecond
oh ok then
hello
need some help
how do I check if someone's role is higher than the bots
or the users
like I've made a mute command
but you can mute the owner
and I don't want that
Owner can be given muted role
But tbh he can still talk 
yeah
Just check highest role
Of both the person
how?
have you seen docs ?
it's something like member.highestRole or something
ok
Check docs to be sure
.highestREAD-ONLY
The role with the highest position in the cache
Type: Role
thats in docs
.highestRole only or .role.highest I'm not sure ask someone else sorry
ok
roles#highest
const webhok = new Discord.WebhookClient('', '');
const DBL = require("dblapi.js");
const dbl2 = new DBL('', client);
const dbl = new DBL('', { webhookPort: 5000, webhookAuth: 'usersplus' });
// Optional events
dbl2.on('posted', () => {
console.log(`Server count posted! Total servers Counted : ${client.guilds.size} Servers `);
})
dbl2.on('error', e => {
console.log(`Oops! ${e}`);
})
dbl.webhook.on('ready', hook => {
let votes = dbl.getVotes();
let embed = new Discord.MessageEmbed()
.setColor(`#FFFB00`)
.setDescription(`Webhook running at : http://${hook.hostname}:${hook.port}${hook.path}\nwe have total ${votes}`)
webhok.send(embed);
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
let embedd = new Discord.MessageEmbed()
.setColor(`#00ECFF`)
.setDescription(`User with ID <@${vote.user}> just voted! The Users+ Bot On TOP.GG`)
webhok.send(embedd);
console.log(`User with ID ${vote.user} just voted!`);
});```
This is right?
also @earnest phoenix youโre missing an O in const webhok
also thats a topic for #topgg-api
you're on v12
11*
why are you using messageembed then
Oh yeh
@vale garden please donโt do that
Hey!
@vale garden check if it is your id
@vale garden please donโt do that
@torn ravine wdym
If not return
kk
donโt quote yourself
How do i get the Bot Developer role?
or what
@split blade approved bot here
ok!
if (message.author.id !== โyour id hereโ) return @vale garden
@torn ravine
Not working 
did you fix the typo?
yes
also move this to #topgg-api
can you vote my bot for testing?
you can manually emit events

await the promise (getVotes()) and add .length to votes in the setDescription
oh my
dbl.webhook.on('ready', hook => {
let votes = dbl.getVotes();
let embed = new Discord.MessageEmbed()
.setColor(`#FFFB00`)
.setDescription(`Webhook running at : http://${hook.hostname}:${hook.port}${hook.path}\nwe have total ${votes}`)
webhook.send(embed);
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});```
This is my code.
k
so ${votes.length}
so ${votes.length}
@torn ravine Showing Undefined.
code?
what?
We have total 1
Vote
dbl.webhook.on('ready', async hook => {
let votes = await dbl.getVotes();
let embed = new Discord.MessageEmbed()
.setColor(`#FFFB00`)
.setDescription(`Webhook running at : http://${hook.hostname}:${hook.port}${hook.path}\nwe have total ${votes.length}`)
webhook.send(embed);
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});```
Code
how can I make a command for a specific person? that only he can run this command
if(message.author.id != 'PersonId') return;```
bruh
that looks more like float
side by sideo of gif
try adding float: right; to the text
do u need ban perms for fetchBans






