#development
1 messages Ā· Page 965 of 1
its not library
Literally what the.
I'd recommend you learning the language you're trying to code on.
Then go learn how to code.
^>^
that's not a library
Idk what the subject
subject?
@dawn trout where are you from
wdym by "subject"?
Subject, what do you mean.
I am trying to make bot profile picture animated on bot page , but my code is not working , if someone can help I will really appreciate it !
.bot-img {
-webkit-animation: mover 3.0s infinite alternate;
animation: mover 3.0s infinite alternate;
-webkit-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
}
</style>```
Did you create the mover
mhm
dont use snekfetch, use node-fetch or axios, snekfetch is deprecated.
this error didn't exist a few days ago
did you update some package
I moved the bot from x VDS to y VPS and this error started to appear
modules latest version
well when you did npm install, probably some package did get update
sometimes there comes breaking chamges
can anyone here remember which api endpoint it is to grant or remove a role from a user please?
i dont usually dabble in raw api endpoints, cant remember
@green kestrel DELETE /guilds/${guild}/members/${member}/roles/${role}
PUT for giving
DELETE for removing
also yikes i pasted twice
thanks! š
Hey there. I'm using a reverse-engineering API of my school's online service. On this service, there's a mailbox, but the thing is that all the message contents are encrypted or idk. Knowing the input and the output of the encryption, is there any way to get the encryption key? I suspect the encrypted code to contain the layout too. I noticed that the characters PHA are used a lot. Any ideas of how I could find the encryption key?
There's also the \n that isn't changed, so I can know where are the paragraphs
@stuck scaffold just try and see.
how do i define a channel that i want to send a message in?
Uh you can cache the channel
Or you cAn send it to the same channel the command was ran
You just send it via <message>.channel.send("text")
Sorry Iām on mobile so itās harder to write
what is the text to set an embed to white?
or .setcolor([255,255,255])
Is there a command to make a prefix changeable
You can use commando or you can setup your own
you could make a mysql table where you can change the prefix with a command
How do I do that?
YouTube
Ok

If you want to make it with mysql i recomend using phpmyadmin
Is there a way of making text go onto a new line?
\n
Ok
in a string
Might just be me being dumb but the status of my bot doesnāt seem to be changing or updating. Little help here? Hereās my code. Also, the console.logs are just for debugging to see if the code reached there. "were here" was printed but "here again" and "woooohoo" was not.
console.log("were here")
setInterval(() => {
console.log("here again");
let botStats = JSON.parse(fs.readFileSync("./botStats.json", "utf8"));
this.bot.editStatus({name: `raiding ${botStats.guilds} servers`});
console.log("woooohoo")
}, 3600000);
It was stuck being empty for hours.
this.bot.user.setActivity()
the language is the same lol, both are javascript
~į½ ~
I wanna create a website where there is like a 3d space ship that you can rotate and move around and when you click on a certain spots some interface pops up and show different info about my discord bot, but it seems really complicated and not doable only with html css and js. Anyone has any input, is there a preferred way to do this?
thats like creating a browser game
Kind of
@earnest phoenix try .editStatus("online",{name:"your text here"})
š hold on
if it doesnt work, maybe you need to specify the type as well
@opaque seal its totally doable with css and js
Whaaat
css supports 3d transforms and animations
yup
@opaque seal i`ve seen this package but you need to setup a nodejs server
check this out
A CSS powered 3D environment with geometry created from HTML elements and CSS transforms. Textures and lightmaps are composed by layering multiple background-images and colour is applied using CSS blend-modes.
its the same and it looks like itās because the interval was not even reached somehow because āhere againā was not logged in the console
imma try and see if botStats.guilds is even reachable because i got it from a JSON file
@earnest phoenix do you run that code outside of the interval too?
because the interval will run for the first time only after the timer
if you want to run something immediately, you need to run it once without the interval, then create the interval
intervals run in timeouts too right?
because i need time for all the clusters and shards to launch
When generating an ssh key from my windows pc it asks to replace the comment of the key with the username of the pc user, this has to be the username of my windows pc right? Not the ubuntu server I want to connect to
hi
how can i filter the guilds i have a certain permission with?
i only have the permission bit thingy, using js
@opaque seal do you want to remote develop on a ubuntu server?
then i have no idea
can somebody explain me this please?
i dont want to advertise the site. so i dont't give a link, sorry
how do u make it so it doesnt respond to other bots
@sacred oyster which programming language?
discord.js
if(msg.author.bot) return
ok thanks
@granite girder now when i do any command the bot says it 2 times
oh wat
now it isnt
yes
I'm having a token invalid error with my bot. I'm not quite sure what's happening as it only seems to have started happening this morning. I've rebooted, upgraded discord.js and upgraded all of my system packages. I've also changed my bot's token. I've also never had this issue before in the past. What's going on and how do I fix it?
keep on regenning it
Does Discord make your bot's tokens invalid after a certain amount of time?
no
the only two cases where your bot token will be regenerated by discord is if you hit the identify limit or if you upload the token to github
yello
Now playing command for my bot. Any suggestions for additional info etc?
on my bots dashboard, it shows all the users guilds even which they don't have perms to manage. how can i filter it to only show the servers they have perms in?
using js
does anyone know how to make a webdashboard for my bot?
any ideas of how i can change this to prefix instead of prefix's length??
how big is your prefix? one character?
i would assume you should just be able to delete .length and it should work
in theory anyway
let me try it
ok
nah it didnt work
then i have no clue. sorry
if(msg.content.startswith(prefix)){}
more like return if it doesn't
how can i make that message command
if(msg.content.startswith(prefix)){}
oh lmt
ill write back
thanks for suggstin
don't do that, it makes the code dirtier
idk but i need a solution
make it return instead when the message doesn't start with the prefix
so something like if (!<Message>.content.startsWith(prefix)) return;
should i put that to near the first lines after if message
bruh
oh nvm
solved it
it was about
i forgot
to remove the old code :((
now it works and only reacts to my prefix thanks flazepe and others that helped!
I have a question. I have a bot which recently crossed 1k servers (1022 servers) and sometimes when bot is added to new servers, it restarts.
Does that mean i need to use Shards now?
if the bot is not added to new servers, the bot doesn't restarts...
that seems more like a flaw in your code
you need to shard at 2.5k other wise the bot wont start
I have a question. In Pokeverse when someone battles it shows the opposing health in rectangular form. I want to know how to do that in python
hmm ok
so i did this code in my bot but when i add a reaction nothing appears in console wtf
console.log(reaction.emoji.name);
console.log(user.username);
Are you sure the message is cached
try this
how can i cache all messages from a server
(this bot is only for my personal server)
you cant
you would need to recursively call getMessages on every restart or store them in a db
use carlbot logs instead but they only notify you if a message deleted or edited
its not as simple as that
you will need to have a good knowledge of Html, css, js (for making website) and http requests (for requesting the data entered by user and adding them to bot)
you don't need to have good knowledge of html and css
@vernal vapor those rectangles are text, some unicode character
@tight plinth discord.js v12 has partials for that, to enable reaction events on uncached messages
oh
with express, how can i make a url like servers/server-id with express?

app.get("/servers/:id")
example
app.get('/users/:userId/books/:bookId', function (req, res) {
res.send(req.params)
})
req.params holds the url parameters used, ie req.params.userId = whatever the person wrote in the userId parameter
oh
in my middleware routes, what would it look like?
like app.use('/guilds/:id') too?
@tight plinth discord.js v12 has partials for that, to enable reaction events on uncached messages
@quartz kindle cant find them ;-;
@tight plinth https://discordjs.guide/popular-topics/reactions.html#listening-for-reactions-on-old-messages
ok
@digital ibex pretty sure that yes
ah, ok. thanks :)
I wanna get started on this bot ban system
o ok. thank u
@quartz kindle im confused with the middleware routes, it looks like: ```js
app.use('/guilds/:id', path);
how can i make the :id be the guild id?
when i use my clear command like example: -clear 44 but theres only lets say 6 messages in the channel, it will purge the 6 messages and then say 44 Messages Have Been Cleared! how do i make it say 6 Messages Have Been Cleared! even tho i typed 44? discord.py btw.
i want it to say the amount of messages that it actually cleared.
@commands.has_permissions(manage_messages=True)
async def clear(ctx, amount : int):
await ctx.channel.purge(limit=amount)
await ctx.send(f'**{amount}** Messages Have Been Cleared!', delete_after=5)``` thats my current code
is there a way to code a command that sets a log channel and it logs when a message was deleted
Use messageDelete event
@earnest phoenix fyi purge() returns the list of deleted messages
look for how many messages r in the channel (100 max), and if there r more than, lets say 44 in ur case, if its above 44 then just do nothing else and carry on with the command, otherwise u can maybe change the value of 44 to 6 ?
Get length of that list
@slender thistle what exactly do you mean?
ill read
@slender thistle its not working
Show your code
@commands.has_permissions(manage_messages=True)
async def clear(ctx, amount : int):
await ctx.channel.purge()
await ctx.send(f'**{}** Message(s) Have Been Cleared!')```
i dont even understand the docs tbh
Don't remove the limit argument from purge
You just assign it to a variable and then len() that variable
ye i dont understand never used len()
len() returns the length of the provided array or string
len(some_list) returns number of elements in that list
anyone?
Just ask your question
@slender thistle anyone who knows python and can help me do dm on join and activity set (changing)?
this is so confusing bruh
Activity changing every X minutes?
variable = .purge()
return len(variable)``` @earnest phoenix
?
where do i put that bro
How do you test bots in this server?
Function purge() returns a list, which will be stored in variable
Then, you want to get a number of elements in a list under variable variable, hence the len(variable)
@foggy river #commands
i dont understand at alllllllllllllll
then learn pythonnnnnnnnnnn
just nvm dude
um
I'm not sure how else to break it down for you
all good ill just leave it its wtv
def get_list():
return [1,2,3]
my_var = get_list() # got [1,2,3] returned from function get_list
# to get the length of [1,2,3] returned in my_var, use len(my_var)
print(len(my_var)) # 3, because there's 3 elements in the list```
@digital ibex if you define it as /guilds/:id then someone navigates to yourwebsite.com/guilds/123456789 you will get 123456789 in your req.params.id variable
if you define it as /guilds/:bla then you would use req.params.bla to get whatever the person wrote after /guilds/
how can i log when a message has been deleted
check out the message delete event for your library
how come this doesnt work?
await bot.change_presence(activity=discord.Game(name="."))
await bot.change_presence(status=discord.Status.online, activity=discord.Game("namehere"))
try that
@indigo flax
didnt work
@earnest phoenix
await bot.change_presence(status=discord.Status.online, activity=discord.Game("yeet"))
What's the error
AttributeError: module 'discord.ext.commands.bot' has no attribute 'change_presence'
hmm
2020-06-09T14:44:29.328841+00:00 app[worker.1]: --------
2020-06-09T14:44:29.328842+00:00 app[worker.1]: Bot is up and running.
2020-06-09T14:44:29.328910+00:00 app[worker.1]: Ignoring exception in on_ready
2020-06-09T14:44:29.330199+00:00 app[worker.1]: Traceback (most recent call last):
2020-06-09T14:44:29.330240+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/discord/client.py", line 307, in _run_event
2020-06-09T14:44:29.330241+00:00 app[worker.1]: yield from getattr(self, event)(*args, **kwargs)
2020-06-09T14:44:29.330289+00:00 app[worker.1]: File "bot.py", line 22, in on_ready
2020-06-09T14:44:29.330290+00:00 app[worker.1]: await bot.change_presence(status=discord.Status.online, activity=discord.Game("Hidden"))```
What's bot defined as
Did you copy paste something
if(cmd == 'ger'){
let channelger = message.guild.channels.cache.find(channel => channel.name = userInfo8.channelname)
//userInfo8.channelname:This is a string from a database,it stands for the saved channelname by user.
channelger.toString()
msgchannel = message.channel.name
if(message.channel.name.toString() === channelger){
message.channel.send("Test")
}
So, I dont get any error messages, nothing happens simply. In my console, I dont see anything going on that is weird, but the command still doesnt work.
What could be wrong
I am not sure how this doesnt work
why the extra ) ?
still doesnt work
calling .toString() on a variable doesnt change the variable, just returns a stringified version of it
you're still comparing message.channel.name to a channel object
2020-06-09T14:50:21.315642+00:00 app[worker.1]: --------
2020-06-09T14:50:21.315642+00:00 app[worker.1]: Bot is up and running.
2020-06-09T14:50:21.315663+00:00 app[worker.1]: Ignoring exception in on_ready
2020-06-09T14:50:21.316861+00:00 app[worker.1]: Traceback (most recent call last):
2020-06-09T14:50:21.316935+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/discord/client.py", line 307, in _run_event
2020-06-09T14:50:21.316936+00:00 app[worker.1]: yield from getattr(self, event)(*args, **kwargs)
2020-06-09T14:50:21.316936+00:00 app[worker.1]: File "bot.py", line 22, in on_ready
2020-06-09T14:50:21.316937+00:00 app[worker.1]: await client.change_presence(status=discord.Status.online, activity=discord.Game("Hidden"))
2020-06-09T14:50:21.316937+00:00 app[worker.1]: TypeError: __init__() takes 1 positional argument but 2 were given```
@quartz kindle oh, you are correct about this, completly forgot that
@pale vessel I should use === ah
ok
xD
thanks guys
you should first check if channelger exists, since it might not exist
then if it exists, check if message.channel.name === channelger.name
no need to call .toString() on anything
Show your code
``await client.change_presence(status=discord.Status.online, activity=discord.Game("hidden"))
await client.send_message(member, "hidden")``
@slender thistle
Use game instead of activity
ok
what about the second one?
dm on join
@slender thistle
@slender thistle
@slender thistle await client.change_presence(status=discord.Status.online, game=discord.Game("hidden"))
like that?
Use on_member_join event
await client.send_message(member, "hidden")
what to change @slender thistle
cause it doesnt work
What did I say about mentions
1 mention a minute
because I have a reason to not respond immediately?
What are you putting under the event
await client.send_message(member, ""
First of all, do you have a member variable?
await client.on_member_join(member, "Welcome.")
thats outdated
like, 3 years outdated
What...
You don't send a message with on_member_join, logically speaking. Do you?
how
I thought you were supposed to know that...
first of, How much python do you actually know
is there a way of coding a command that turns on/off other features
is there a website explaining that?
aaaaaaaaand
@earnest phoenix if active do this->
what's the error
await client.change_presence(status=discord.Status.online, game=discord.Game("hidden"))
u told me to change activity to game
out of 100% Curosity
@slender thistle
Where df are you getting these bits of code
people
Learn to be patient
first of, How much python do you actually know
@modest maple what do you mean?
@earnest phoenix Litterally just checking a value
const queue = message.client.queue.get(message.guild.id);
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'get' of undefined
oh ok
what do i do
message.client.queue is undefined
oh
@edgy girdereco
Bruh
also how do i use multiple api keys in the same code

as in the same music module

Multiple API keys?
@quartz kindle req.params is an empty object, how can i change that?
for youtube
Store them in an array and choose one randomly if the same API
oh ok
i dont think you can have multiple API keys
you can
@digital ibex it shouldnt be empty if the used typed something in the url
What are server member intents/prescence intents>
app.use('/guilds/:id', guilds);
What are server member intents/prescence intents>
uhhh, how would i do that?
Integrate your service with Discord ā whether it's a bot or a game or whatever your wildest imagination can come up with.
oh
That isn't very helpful.
thats what it is, read it and it explains
Are those permissions?
no
when you connect to discord, discord sends you EVERYTHING by default
all possible things that happen
Then what are they?
gateway intents are a way to tell discord "send me only these"
that way discord will only send you the data you want and need, instead of everything
Thank you Tim cough
for example, if you specify GUILD_MESSAGES in your intents
discord will send you only these
and nothing else
So if I don't need any of those events sent to me, I wont check intents?
tim, same thing
yes you configure your intents with only the data you want
and that was what i was doing before btw
oh
ah you're doing the verification form
you need to describe what kind of data your bot saves about its users
and what kind of security measures does your bot and database take
the part about intents is if your bot uses member and presence data
for example if your bot has welcome messages, or anything that uses memberAdd/memberUpdate/memberRemove, you need to enable the GUILD_MEMBERS intent
and if your bot uses presenceUpdate or checks for user online status, etc, you need the PRESENCES intent
ah ha
thanks tim
also, is there a way for me to delete it?
how can i make sure that actually is a guild?
like, if its not a proper server id, send them to the 404 page?
@quartz kindle Can you dm rq?
its gonna be the same
what is the point of that then?
if it has no way of detecting a real guild, then what is it for?
yeah you should use that param to get data about the guild from some database or discord or whatever
if it doesnt exist then show an error
or a 404
uhh, idk any other way to do it
async def amiadmin(self, ctx):
if ctx.author.id in self.config.owners:
return await ctx.send(f"Yes {ctx.author.name}, you are an admin. ā
")```
oh
is anything wrong here
yes
just do something like {"guildId":null} if it's not a real guild

ur not checking anywhere if theres a message to be sent, so nothing is like triggering it to say it
or
its spamming it
can anyone help me ^
@quartz kindle I am not sure what to write for our data retention, may I have a n example/template?
tim, im so confused
Yes
what do you save in it?
But it only stores stuff such as dadjoke responses, or just a list of responses.
no users ids or guilds ids or user/guild configuration?
no custom prefixes?
no logs channels?
no custom prefixes?
@quartz kindle I think I handle those via discord.js commando
@quartz kindle And the bot is not mained for moderation nor does it have any moderation commands, a log channel wouldn't be necessary.
I get what he means but I don't really store many things.
discord is asking you want kind of information your bot saves. if your bot saves custom prefixes, then you need to explain what it saves and why
I see
for example "this bot stores guild IDs in order to track custom settings"
they also want to know for how long you store them
for example "settings are stored only while the bot remains in the guild and are deleted once the bot leaves"
Our application store such things as Guild IDs, we may store guild ID to be able to track custom settings/prefixes. We may store track message-ids to be able to find the certain messages that has been ever posted.
something like that yeah
It has to be 100 messages so brb
Interface
ejs
Go all the rest just wondering for the interface
vue
well some people design websites in photoshop
ejs is good
i recommend vue, but its kinda hard to interact the frontednw ith backend
i mean, those are frameworks
hard for me anyways
tim, what did u mean by "yeah you should use that param to get data about the guild from some database or discord or whatever"
@quartz kindle What about => HOW HAVE YOU SECURED ACCESS TO YOUR SYSTEMS AND INFRASTRUCTURE?
navigate them to the actual dashboard
like where u can change the config of the bot
what is the dashboard supposed to contain?
I am officially lost
@glossy elk where is your bot hosted and how is your hosting security
like, the prefix, logs channel, mute role, nickname of the bot, custom command thingy and the automod module
DigitialOcean?
do you use ssh?
yes
which one?
then thats your answer
Oh wow
"the server is secured by ssh keys"
Can I send you my application after I completed everything so you can check it?
mongodb
indexed by a guild id?
yeah
then thats your answer
user nagivates to /guilds/bla
data = mongo.guilds.findOne(id === req.params.id)
if(!data) send(404)
whatever file has the router
ah, ok. thanks
hm, tim
router.get('/', (req, res, next) => {
const guild = Guild.findOne({ id: req.params.guildId });
if (!guild) {
res.send('e');
} else {
res.send(req.params);
next();
}
});``` its sending `req.params`
any idea why thats happening?
if the role Muted is already created how would i make it not make another role? heres the code:
@client.command() @commands.has_permissions(manage_roles=True) async def mute(ctx, member: discord.Member): guild = ctx.guild await guild.create_role(name='Muted', color=discord.Color(0x5c6b6f)) role = discord.utils.get(ctx.guild.roles, name='Muted') await member.add_roles(role) await ctx.send(f'{member.mention} Has Been Muted')
thats why im asking dude
check if the role exists, if it doesn't then create the role otherwise just add the role
You're creating the role and THEN checking if the role with named Muted exists
ye toe
@digital ibex console.log(guild) and console.log(req.params)
kk
so how would i say if its made to not remake it
get the role first
use an if, check if the returned value of utils.get is None (role wasn't found)
@client.command() @commands.has_permissions(manage_roles=True) async def mute(ctx, member: discord.Member): role = discord.utils.get(ctx.guild.roles, name='Muted') guild = ctx.guild await guild.create_role(name='Muted', color=discord.Color(0x5c6b6f)) await member.add_roles(role) await ctx.send(f'{member.mention} Has Been Muted')
like that
use an if, check if the returned value of utils.get is None (role wasn't found)
tim, it logs:
@client.command() @commands.has_permissions(manage_roles=True) async def mute(ctx, member: discord.Member): role = discord.utils.get(ctx.guild.roles, name='Muted') if None: guild = ctx.guild await guild.create_role(name='Muted', color=discord.Color(0x5c6b6f)) else: await member.add_roles(role) await ctx.send(f'{member.mention} Has Been Muted')
like that?
and req.params logs: {"guildId":"null"}
if role is None
Try it
shivaco, what library did u make?
dblpy
@digital ibex well mongo is returning something even if you pass null to it
maybe you're using the wrong way to get data, idk
oh
how do you usually get data from mongo?
worked nvm
wait did you console.log guild or Guild?
const Guild = require('path to model');
const guild = Guild.findOne({ id: req.params.guildId });
``` and i logged `guild`
ok
then idk, findOne is returning something else instead of the data
dont you need to await it or something?
what softwares do I use when making a discord bot?
then you can use node.js
i just added await but same result, and u only need await if ur gonna search for something specific, doesn't make a difference if ur not doign anything else with it i believe
well i dont use mongo so idk
oh
you have to figure it out
can someone giveme th ebasic code when making a bot go online
oki, thanks
@agile oyster check out discord.js
k
k thxs i got it
tf
now its not loading
oh, i thnki kn y
its logging but doesn't load š¤
i asynchronies the function and it doesn't load
wtf
@slender thistle
how do i change perms for all channels instead of the role perms?
thanks
ctx.channel.set_permissions(ctx.guild.default_role, send_messages=False)
this?
can you rephrase that please
how can i detect and set off a command if someone has only put part of a command
like !play but without the url. i want to tell them to put a url
check args
how?
@client.command()
@commands.has_permissions(manage_roles=True)
async def mute(ctx, member: discord.Member):
role = discord.utils.get(ctx.guild.roles, name='Muted')
if role is None:
guild = ctx.guild
await guild.create_role(name='Muted', colour=discord.Colour(0x5c6b6f))
ctx.channel.set_permissions(ctx.guild.Muted, send_messages=False)
role = discord.utils.get(ctx.guild.roles, name='Muted')
await member.add_roles(role)
await ctx.send(f'{member.mention} Has Been Muted')
else:
await member.add_roles(role)
await ctx.send(f'{member.mention} Has Been Muted')```
this make sense? @slender thistle
cuz its not working
create_role method returns the created role
You can just assign it to a variable and use it instead of searching for the role after you create it
Also, don't take me too literally when I say replace X with Y
ctx.guild.Muted doesn't make sense or exist
you told me to that that fuck
@agile oyster Depends on what language you're comfortable with
how do i check args for 1 and then set off a command is it dosent exist
Well if there is nothing : there is no url
what?
Are you on discord.py @earnest phoenix
no
discord.js
discord.js doesn't have a built in command handler, so you should know if you made yours
unless you copied it
On discord.py would be something like
@client.command(pass_context=True)
async def command(context, *,* arg):
await print(arg)
bruh im typing it, so i can explain was going on
const idd = "myid";
const a = "asd";
config[msg.author.id].idd = {
something: a
}
so basically
yeah?
it wont detect idd and a
const Discord = require('discord.js');
const client = new Discord.Client();
const botToken = process.env.DISCORD_BOT_TOKEN;
const pinEmoji = process.env.DISCORD_BOT_PIN_EMOJI || ':pushpin:';
const wastebasketEmoji = ':wastebasket:';
async function dmPinnedMessage (messageReaction, user) {
if (!user.dmChannel) {
await user.createDM();
}
let text = `${pinEmoji} message by <@${messageReaction.message.author.id}> in <#${messageReaction.message.channel.id}>/${messageReaction.message.guild.name} ${pinEmoji}\n${messageReaction.message.content}`;
let messageOptions = {};
messageOptions.embed = {
author: {
name: messageReaction.message.author.username,
icon_url: messageReaction.message.author.avatarURL,
},
timestamp: new Date(messageReaction.message.createdTimestamp).toISOString(),
};
if (messageReaction.message.attachments.size > 0) {
messageOptions.files = messageReaction.message.attachments.map(attachment => attachment.url);
}
let dmMessage = await user.dmChannel.send(text, messageOptions);
dmMessage.react(wastebasketEmoji);
}
function deleteDM(messageReaction, user) {
messageReaction.message.delete();
}
client.on('ready', () => {
console.log('I am ready!');
});
client.on('messageReactionAdd', async (messageReaction, user) => {
if (user.bot) {
return;
}
if (messageReaction.emoji.name === pinEmoji) {
dmPinnedMessage(messageReaction, user);
} else if (messageReaction.emoji.name === wastebasketEmoji) {
deleteDM(messageReaction, user);
}
});
client.login(botToken);```
Bot's purpose: Member reacts to a message and bot DMs the message to user
What I want: This bot to work for only members with certain role
bruh
would be glad if someone could help, trying for 2 hours im dumb smh
just check if the member has the role?
First thought: Just need to check the roles of the sender and if it's in the authorized list of roles do the stuff
First thought: Just need to check the roles of the sender and if it's in the authorized list of roles do the stuff
@crimson jetty do you have the code for that
legit just check if member has role
one question
how can i make it so as long a the command someone typed starts with my prefix it sends a reply
how i can get number of ppl who has ADmin perms
@vale python show code
const client = new Discord.Client();
const botToken = process.env.DISCORD_BOT_TOKEN;
const pinEmoji = process.env.DISCORD_BOT_PIN_EMOJI || ':pushpin:';
const wastebasketEmoji = ':wastebasket:';
async function dmPinnedMessage (messageReaction, user) {
if (!user.dmChannel) {
await user.createDM();
}
let text = `${pinEmoji} message by <@${messageReaction.message.author.id}> in <#${messageReaction.message.channel.id}>/${messageReaction.message.guild.name} ${pinEmoji}\n${messageReaction.message.content}`;
let messageOptions = {};
messageOptions.embed = {
author: {
name: messageReaction.message.author.username,
icon_url: messageReaction.message.author.avatarURL,
},
timestamp: new Date(messageReaction.message.createdTimestamp).toISOString(),
};
if (messageReaction.message.attachments.size > 0) {
messageOptions.files = messageReaction.message.attachments.map(attachment => attachment.url);
}
let dmMessage = await user.dmChannel.send(text, messageOptions);
dmMessage.react(wastebasketEmoji);
}
function deleteDM(messageReaction, user) {
messageReaction.message.delete();
}
client.on('ready', () => {
console.log('I am ready!');
});
client.on('messageReactionAdd', async (messageReaction, user, message, member ) => {
if(!message.member.roles.cache.find(r => r.name === "Mods")) {
return;
}
if (messageReaction.emoji.name === pinEmoji) {
dmPinnedMessage(messageReaction, user);
} else if (messageReaction.emoji.name === wastebasketEmoji) {
deleteDM(messageReaction, user);
}
});
client.login(botToken);```
I added
client.on('messageReactionAdd', async (messageReaction, user, message, member ) => {
if(!message.member.roles.cache.find(r => r.name === "Mods")) {
return;
}
but it says member is undefined
Yea it depends on how you called your sender's message
get role first
Member here isn't undefined in your error
sorry I am not good at this at all
It's message which is undefined
get role then check if member has role
"cannot read property something OF undefined"
.cache doesnt exists on v11
@vale python you're trying to get properties that dont exist
you cannot make up stuff in events
messageReactionAdd gives you a reaction object and a user object
const role = msg.guild.roles.cache.find(r => r.name === "some role");
if (!msg.member.roles.cache.has(role)) {
//yeah
}
messageReaction.message.member.roles is the sender's roles i guess
you cannot magically add more things to it, you need to use what is given
You named your message object as messageReaction
also .cache doesnt exists on v11, so use <memberRoles>#has instead.
if ur adding .cache on v11 might as well just update d.js
v11 isn't gonna be stable
https://glitch.com/edit/#!/join/2f9204b7-1e3c-40f2-aaaf-7a210130a2c6 if anyone wants to give a hand
glitch xd
there might be guys who might only come to steal yr token tho
i kicked the bot from my server
kk
3 people gang banging the code rn
regen the token after you recv the help and removed the user from yr project
or users
and make your project private
lol 2 ppl looking .env
lmao
lmaoooo
you know what
Bruuuuuh
why not we all make a twitch plays discord bot
someone deleted your app.js
i gotta see that
y gonna need rewind
and someone wrote "jews deserved it"

Why are people like that 
Never make projects editable without a backup or to people you dont trust
imagine this
100 people coding a bot together on glitch
livestreamed on twitch/discord
100 people on one vscode live server with full terminal access
pc dies in seconds
lmao
is there a ay of deleting only part of a message?
you can edit the message
only your messages*
oh. delete the message someone typed and then send a certain part of it?
yes
how?
slice it
what?
use the String.slice() method
ok
is it just me or
request to discordapp.com/api/v7/gateway/bot failed
httperror
name: 'FetchError'
code: 500
method: 'get'
path: '/gateway/bot'
Internal Server Error š¤·āāļø
my problem?
nope if you are requesting from discord's api it's their server
im just looking for nothing, dont mind me.
When did it happen?
just a few mins
Those who have their bots up and running, can you guys suggest good hosts for the bot and the database?
Ofc i can't be. My electricity bill would kill me
@plucky harness I personally use Heroku to host the bot and Firebase to host my database
Not really the best option but works fine for me
Firebase. Is it fast?
so its not my fault
Well it's from Google sooooo @plucky harness
šÆ šÆ
Well yea normally @royal portal
Paid?
Nope I use the free plan
Oh hell yea! I'mma try it
and its fine
Thanks
discord problem i guess lol
Though it's not a database like MongoDB or stuff like that (it's kinda JSON structure based)
how do i copy the text someone put into a chat
Would it host sql database?
Hmmm don't think so @plucky harness
š«
You could look at the new version (firestore)
Oh alright
Don't know though
how do i copy the text someone put into a chat
@earnest phoenix Check at the arguments and send back
I don't know how to work with Mongo DB tbh. I already know sql so went with it
Don't know SQL soooo
I'm all json based because never learnt another way of storing things
Json is cool too
I need some help, somebody my bot woont go online, can someone be my guide or teacher
How do you host it? @agile oyster
what do you mean host
Oh you still developing it?
What's your code? Is it the first time you're running the bot
If so just run the program/script you wrote and it should go up
yeah, im using node.js, but on top of that
i tried installing the discord.js and it says this, hodl let me screenshot it
??
I deleted the question instead of editing š¤¦š½āāļø
Oh bruh
Do npm init
k, then what should i do
Yea you need to initialize it
how
Go in your folder
k
npm init
well i would say npm install discord.js
But
It seems like it added it
You can still try to reinstall it though
k
It worked? @agile oyster
can someone help, i don't understand how to check the arguments and send them back
it now says description
About what ?
cus right now im installing it
first it said package name, version, now description
Hmmm
Sorry I don't use npm a lot so I don't know much about it
It asks you to give a description ??
yep
Well give it a description then lol
@agile oyster ur running npm init
yeah
how can i get a role from args[1]? like, with mention
thats not how u install a package
then how do you do it
yes, but if i do message.mentions.roles.first() it won't work
u dont
And then npm install discord.js
but ok
k
Well you don't have to but it was giving him warning messages
hold on ima delete node.js and reinstall it
it installed
@agile oyster why
k, sorry im still a beginer
Yea ik but not to install packages
do i download package.json file
k, i have a json file in my folder now
a package.json is only needed if u are publishing a package
u dont need it anywhere else
k thxs
it isnt required to run a node project either
I mean it's good to have one
Where are you going to store your dependencies? Am I missing something?
yes but what they were saying is untrue
if u install without initialization npm should make a package.json
if u put the save argument
itll just have ur dependencies
Why after i use the command and set a value in data base, in my settings command i got
cuz its an object
how can i solve that ?
your json either got corrupted or you're acessing it wrong
let role = await db.get(`ServerRole_${message.guild.id}`) ? await db.get(`ServerRole_${message.guild.id}`) : "None"
this is how i get
Object.values(yourjsonfile)
@lyric mountain i'm using quick.db
still json
what
quick.db uses sqlite under the hood but I don't remember if it also uses json somewhere
you gotta print an object's property, not the object itself
it doesnt
all objects in js are jsons
sir no
...json is a js object
json is json

JSON stands for JavaScript Object Notation. It is basically a text format that makes it easy to share data between devices such as Clients and Servers. Its Origin is based on how JavaScript object works so in that sense, it is related/close to but not completely JavaScript Object.
technically a js object
sort of, but not the exact same.
@knotty steeple what software do you use to make your bots
you gotta get a property of that object
