#development
1 messages Β· Page 835 of 1
No worries
does anyone know how not to have loads of arg checks?
what do you mean? what language and library are you using?
@royal portal ```js
((activities_list.length - 1) + 1);
why are you doing that
what's the point of it
lmao
mafs
bruh
Question, in my new bot I have an issue I think? It is showing my "bundleDependancies": false, with yellow squiggles, should I be worried about such?
not really
it's just a warning
but however
hover over it and see what the warning says
just to the end of it?
instead of false set it to []
Fixed it, thank you.
lul
Can someone fix my eclipse/java issue? ill pay.
Should be easy for someone who knows wtf is going on
Maybe explain what is going on would you like to pay us for mind reading services too?
Yeah sure, i
explain your issue
I am using eclipse to run a virtual enviroment and launch an application that's already built, eclipse cannot find a path, or is running into constant issues
I literally need to just run this file in eclipse, i'm not familiar with eclipse and cannot configure it properly.
Have you checked the settings or are you setting the right path?
to my knowledge, yes, i've been wasting 90 minutes on this, and am on the verge of having a stroke, that's why if anyones familiar with these things i'll pay them to fix it.
What virtual environment are you trying to setup?
That main class is what java uses to first start the program
You have the main class inside another one
That's why it can't find it
want to get into a call and make 15$?
π©
Just move your main class outside the GameServer class
Its such an easy fix, people would do it for free
Yup
@gilded plank said they they were going wait for approval. How long will this take?
depends on how busy they are,
15 bucks to whoever dm's me, gets it working.
Share my screen, tell me what to do, get it running i'll pay you.
Again, its an easy fix
@full summit here
my friend is running a different system library, both of us are in eclipse his works
mine does not
@full summit i dmed u
public static void main(String[] args) {
GameServer.main(args);
}
public class GameServer {```
Just add that part above the GameServer class
main is using variables from the class though
Yes that will add the variables on startup too
Okay let me try, thank you.
Multiple markers at this line
- Syntax error on tokens, delete these tokens
- Syntax error on token "void", @ expected
- Syntax error on token "]", :: expected after
What does your code look like?
wouldn't just renaming the class to "Main" do the job?
I added you.
Hop into testing 1 voice channel you can screenshare from there
And then select eclipse
@prime cliff white names cant screen share

@finite bough the option for it was able to show though but it just auto closes on him with no error
So something weird is going on
I need assistance with my code, all my bot does is return empty message error and I don't know what to do. Please help.
client.on('message', message => {
if(message.content.startsWith(${prefix}cuff)) {
let member = message.mentions.members.first();
var embed = new MessageEmbed()
.setTitle('Cuffed!')
.setColor(0xFF0000)
.setDescription('π ' + member.displayName + ' is now in handcuffs!')
message.channel.send(embed)
}
})
This is my handcuff command, but all it does is spam that it can't return an empty message.
Everything else works fine but the commands with that embed procedure.
@stable nimbus you need to add ; at the end of your event and functions
Okay, where do I put it? Like at the end of everything?
client.on('message', message => {
if(message.content.startsWith(${prefix}cuff)) {
let member = message.mentions.members.first();
var embed = new MessageEmbed()
.setTitle('Cuffed!')
.setColor(0xFF0000)
.setDescription(':lock: ' + member.displayName + ' is now in handcuffs!');
message.channel.send(embed);
}
});```
Ohhhh, okay. Thats why. Thank you very much.... Sorry about that by the way.
It is still erroring out @prime cliff
What are you using to edit this? don't you get any build errors?
What is your error exactly? And semicolons arent needed in js but is good practice.
I use visual studio, its not giving me any errors.
client.on('message', message => {
if(message.content.startsWith(${prefix}cuff)) {
let member = message.mentions.members.first();
var embed = new MessageEmbed()
.setTitle('Cuffed!')
.setColor(0xFF0000)
.setDescription('π ' + member.displayName + ' is now in handcuffs!');
message.channel.send(embed);
}
});
visual studio especially should give you errors
at Client.client.on.message (/app/index.js:120:25)
at Client.emit (events.js:194:15)
at MessageCreateAction.handle (/rbd/pnpm-volume/56deaec5-796f-42f3-a8e4-eafa671e1df8/node_modules/.registry.npmjs.org/discord.js/12.0.2/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
(node:1815) 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(). (rejection id: 3)
(node:1815) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message
This is what it is telling me.
You are using djs v12 right?
Yes, I don't like it....
Try message.channel.send('', embed);
The first argument is the actual text of a message and then you need to send the embed for the second one
You should be able to just send the embed as the first parameter. How are you importing MessageEmbed?
const { MessageEmbed } = require('discord.js')
Is there any way at all to revert the discord.js to an earlier version so that way I can make this work?
Thanks, I will just do that so that way I can do this and get it done the way I know how. I don't like this update but I will try to learn it.
How will I uninstall the current version?
tbh i dont see the problem still, that shouldnt be happening. but ye i dont blame you i havent moved to v12 either haha
@dusky marsh only works as first param or if you use embed: but yes it has to be the second parameter
Will I just have to start over or is there an NPM uninstall that I can do?
MessageEmbed just builds an embed object
you can just change the version in your package.json and npm i
that should change it
Okay
Thanks.
@dusky marsh @prime cliff Thank you guys for the help, but I am just gonna stick to 11.6.2, I will eventually learn 12 but I don't think I am gonna like it, thank you.
Np. im trying to see if they changed the code for building the embed object lol. i dont see why they wouldve changed it to be like that, having to have the embed class object as the second param
It shouldn't be in the first place, like honestly the current one is very nice and it functions normally, so why try to fix something thats not broken?
ye
According to the official tests in their github repo, you can use it how you had it
It didn't wanna work so idfk....
I got them to work and send, but my bot is hella slow. I donβt know what to do anymore.
If your bot is going slow, that is most likely network or api related and not your code.
what are you doing that is slow
When I do my /cuff, /ziptie command it takes a second, I have it hosted finally on glitch (not reliable but hey it works, especially when you donβt have a job).
My main bot I use in my RPServer has never had any issues.
Could also be resource related, idk how glitch does their resource management, but maybe you got on a bad node or whatever. either way, glitch is definitely not the ideal solution.
No, not really. But until I can shell out a few bucks a month itβs all I got....
Iβll try getting rid of other nodes that I have.
Their are fairly cheap vps', i think some are pinned in this channel
like 3 dollars or less a month
I can tell from my experience that private hosting is good, like the cheapest high performance vps you can get is 92 cents
for 8gb space, 512mb ram and ddos protection
i feel that
ffs
it's supposed to send a message before it opens a ticket telling you where the ticket is, but its not,
nor is it closing or sending the Close message.
module.js:550 throw err; ^ Error: Cannot find module 'snekfetch' at Function.Module._resolveFilename (module.js:548:15) at Function.Module._load (module.js:475:25) at Module.require (module.js:597:17) at require (internal/module.js:11:18) at Object.<anonymous> (/rbd/pnpm-volume/8601f15e-c10c-40c8-9d5f-be2450b9a2bf/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/util/Util.js:1:81) at Module._compile (module.js:653:30) at Object.Module._extensions..js (module.js:664:10) at Module.load (module.js:566:32) at tryModuleLoad (module.js:506:12) at Function.Module._load (module.js:498:3)
welp ?
cannot find module
bruh
for role_id in data["pinged-roles"]:
role = ctx.guild.get_role(role_id)
pinged_msg_content += role.mention
pinged_msg_content += " "
if role.mentionable:```
i suppose u just do: npm i snekfetch
this line "Was" working before but has now stopped when i added a new code and will not work now i have removed it,
why is this happening, after updating djs i cant react with emojis from list anymore
for (let n in emojis) {
msg.react(n)
}
DiscordAPIError: Unknown Emoji
@stiff sedge show the list
Try with others
Well
Do a for (const i=0; i<emojis.length;i++){msg.react(emojis[i])}
i deleted the following lines with the main command in @earnest phoenix
@tight plinth it worked, thanks
Yea that or for...of
for..in iterates over the keys of the array
so you get 0 and 1 instead of the emojis
soo, got a new vps, hoping that i could just change the subdomain to make my api work again.
bruh they changed so much in djs
how am i supposed to get message by id now?
what
u wanna create arguments variable or
you need to split message into list
yes, split the message
or command
let args = msg.content.slice(prefix.length).trim().split(/ +/g);




who can give me a purge command for glitch?
cuz
idk
its free
glitch have discord.js
i know
yeah
but i dont know to host it
from glitch to heroku
my bot is fine on glitch
and its hosted 24/7
ye
spoonfeeding isnt allowed dw
dbl.webhook.on("vote", async vote => {
console.log("THE WEBHOOK RECEIVED SOMETHING!!!")
let db = mongo.db("main");
if(vote.type == "test") vote.user = "312559122144821248";
manager.broadcastEval(`if(this.users.cache.get(${vote.user})){this.handleVote(${vote.user})}`);
});
Can someone tell me why it won't load the function?
the console didn't output anything
handleVote is a function and I put it in client.handleVote
ik that it's not loading because i put a console.log at the start of the handleVote function
this is not webhook related
its the manager part
manager is a ShardingManager btw
ok
im just gonna wait then
or try to figure it out myself
@earnest phoenix please do not spoonfeed
ur such a weeb
Ty
nani
depends on your language you're coding it in
Java
equalsignorecasae
im not sure bout that
i code in Java
same here
Lol yup huge
@earnest phoenix you also could use toLowerCase() afaik π€·π»ββοΈ
You want the command to be lowercase right?
Oh you want both
That one I'm not sure
. toLowerCase is case in-sensitive .toUpperCase is case sensitive
I'm not sure about both though π€·π»ββοΈ
That will be just ^Help
The Message object is much more than just the string
This is true
Example:
Message {
channel: [TextChannel],
deleted: false,
id: '691948003065593896',
type: 'DEFAULT',
content: 'test',
author: [User],
pinned: false,
tts: false,
nonce: '691948002645901312',
system: false,
embeds: [],
attachments: Collection [Map] {},
createdTimestamp: 1585043659703,
editedTimestamp: null,
reactions: [ReactionManager],
mentions: [MessageMentions],
webhookID: null,
application: null,
activity: null,
_edits: [],
flags: [MessageFlags],
reference: null
}
Did you copy that
From some guide
The first line in that message event scares me
But that's literally going to emit on every message your bot recieves
In DBL this will be about 1000 messages/min
which would be 1000 presence updates
- Don't change your bot's server size on message event
message.contentis the message string, calling.toLowerCaseon there works
Someone who udnerstands this more properly help me please.
at load (C:\Users\Cools\dog1bot\handlers\command.js:16:20)
at C:\Users\Cools\dog1bot\handlers\command.js:30:27
at Array.forEach (<anonymous>)
at C:\Users\Cools\dog1bot\handlers\command.js:30:14
at FSReqCallback.oncomplete (fs.js:152:23)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fyre@1.0.0 start: `node src/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fyre@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Cools\AppData\Roaming\npm-cache\_logs\2020-03-24T09_58_37_408Z-debug.log
C:\Users\Cools\dog1bot>```
tias
[Error]: TypeError: Cannot read property 'set' of undefined
at load (C:\Users\Cools\dog1bot\handlers\command.js:16:20)
how i set a permision on a command?
In what leanguage?
ye
Version?
thx

Lol
thx nobody isnt useful here
Guys
lier
thats why they've come here expecting code 4 times today
i learn
What is spoonfeding?
@shadow shale giving them the code they're looking for instead of pointing them to the docs or telling them what to do
Sure they have the code
But they learn nothing
And come back again next time for the same issue
Oh ty for telling me

But the fact that you need spoonfeeding isn't good
all they're gonna do is C+P
like what you did with your code
which is why you update presence every message event
which make no logical sense
spam stop ty
ok, can anyone help me with this, needing a code for Disabling and Reenabling a command on the Server if the Owner wishes they don't want it there,
what lang
Python,
Do u use cogs?
what is your current code?
it wont make us happy it'll just stop you getting banned by discord for API spam
async def on_member_join(member):
await member.create_dm()
em = discord.Embed(title="TICKET BOT", description=f"[Hello {member.name}, Please be understanding of the Rules, To join the The Official Support Server Please Click Here]()".format(), color=0x00a8ff)
await member.send(embed=em)```
thats my current code,
@earnest phoenix if you using cogs simply reload them
@shadow shale he ment to turn commands on and off for servers
e.g
if i have a nsfw command
Oh
^
just store setting for guilds in a db like with custom prefixes
Sqllite
if guildId has it enabled
do it
if not
dont
might aswell store prefix and other settings together
cuz why not
Yes
confusing af π
Yes
const _ = require('lodash');
let totalSeconds = (bot.uptime / 1000);
let days = Math.floor((totalSeconds % 31536000) / 86400);
let hours = _.parseInt(totalSeconds / 3600) % 24;
totalSeconds = process.uptime();
let minutes = _.parseInt(totalSeconds / 60) % 60;
let seconds = Math.floor(totalSeconds % 60);
let uptime = `${days}d ${hours}h ${minutes}m ${seconds}s`;
Will this give the total bot uptime when when the bot is shraded?
Discord.js version 12.0.2
(node:25) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added. Use emitter.setMaxListeners() to increase limit fixed ?
help
DONT HAVE A NEW EVENT FOR EVERY COMMAND
sorry caps
but yes
dont use a new event for each thing
@heavy marsh https://tryitands.ee/
for me?
thats basically what its saying @cunning glen
We need more development channels
@earnest phoenix Example of how i have for each guild
I want to know if it will the give the uptime even when its sharded
One is not enought
just stores settings and allows each guild to turn stuff on and off
and the commands just have a simple check
if command disabled
dont do it
@cunning glen remove your many many event listeners
do you mind if i dm you ? @modest maple
const _ = require('lodash');
let totalSeconds = (bot.uptime / 1000);
let days = Math.floor((totalSeconds % 31536000) / 86400);
let hours = _.parseInt(totalSeconds / 3600) % 24;
totalSeconds = process.uptime();
let minutes = _.parseInt(totalSeconds / 60) % 60;
let seconds = Math.floor(totalSeconds % 60);
let uptime = `${days}d ${hours}h ${minutes}m ${seconds}s`;
Will this give the total bot uptime even when the bot is shared?
dbl.webhook.on("vote", async vote => {
console.log("THE WEBHOOK RECEIVED SOMETHING!!!")
if(vote.type == "test") vote.user = "312559122144821248";
manager.broadcastEval(`if(this.users.cache.get(${vote.user})){((require("./server.js")).handleVote)(${vote.user})}`);
});
``` Can someone tell me why doesn't this work? There's no error in the console and stuff and I know the handleVote() function is not running because i have a console.log on the function's first line
@earnest phoenix #topgg-api
@modest maple well
but the problem is at the broadcastEval part @tight plinth
What doesn't work
the handleVote function
@cunning glen both me and tonkku just told you
it wont load
remove your extra listeners and just use one
Does it exists
Show code if the function
oops
async function handleVote(user){
const db = mongo.db("main");
let stats = await db.collection("users").findOne({_id: user});
let player = client.users.cache.get(user);
console.log("hi");
if(player && stats){
let now = new Date();
let cooldown = (24 * 60 * 60 * 1000);
if(now - stats.lastVoted < cooldown) return;
console.log("epic");
let embed = new Discord.MessageEmbed()
.setTitle(`Thanks for voting Beycord, ${player.username}!`)
.setDescription("Beycord would not be here without people like you who vote for Beycord every day.\n\nYou received :valtz:250 and 800 EXPs as a voting reward!")
.setAuthor(player.tag, player.displayAvatarURL())
.setColor("#7f7fff")
.setFooter("Make sure to turn on the voting reminder by doing ;reminder.")
.setTimestamp();
console.log("super");
db.collection("users").updateOne({_id: user}, {$set: {coins: stats.coins + 250, xp: player.xp + 800, lastVoted: now}});
player.send(embed);
console.log("deja vu");
if(stats.premium == true){
db.collection("users").updateOne({_id: user}, {$set: {coins: stats.coins + 250, xp: player.xp + 800}});
player.send("You received a doubled reward because you have a Premium membership. Yay!:tada:");
}
if(stats.reminder == true){
setTimeout(() => {
let remind = new Discord.MessageEmbed()
.setTitle("24 hours had passed since your last vote which means... YOU CAN VOTE AGAIN NOW!")
.setURL("https://top.gg/bot/570115430786531340/vote")
.setColor("#7f7fff");
player.send(remind);
}, 86400000)
}
}
}
module.exports.handleVote = handleVote;
I could not @modest maple
its not a choice thing
you have to remove the extra listeneres
otherwise you're gonna keep that issue
@modest maple :/ how do I not know about that topic ?
@heavy marsh maybe
hmm ok
any ideas on how can I make a bot to send DM massages to all server members ? I'm new on this topic I want to try it out , I use descord.js
Don't
Just don't
@mortal stump doind this is an api abuse, bad idea
that will get you banned for API abuse
It's useless and obnoxious and spammy
oh π¦
And if you add your bot here it'll get declined because of this
but any Ideas how to send notification my server has more than 1k members
^
Do your users a favor and let them read changelogs/announcements themselves
ok π
make custom cache?
can you explain more pls
*custom message cache
like make a map of old messages
and then store message id, content and author.
hmm ill try, tnx
Cannot find module cherrio
Because in mode_noduels it's in
Did you installed it global?

Did you select your Bot Folder path and installed it then?
Or did you just installed it?
π’
That's Heroku though
That's Heroku though
is it?
Yes?

then just add the plugin?
brother
calm down
package.json
not node_modules
heroku installs modules based on the package.json file
You dont even need to upload the node_modules file
....... ok
π
didn't someone sent a link for that
lukas and flazepe slowly losing their mind?
nah
yeah
already lost my god damn mind
Wait that's package.json
yeah
Why did I just think it was packages.json
my brain is disintegrating
neehsi
read the link shivaco sent
click on the link and read whats in there
Oof
how can i add nsfw on my bot π
<_<
did you understand a single thing from that article?
d o c s
add the module then
Just add your needed module there and restart the dyno
so you hosted your bot via heruko using github
Tone it down with the caps and bold font
^^
32 bit?
32 bit?
tbf i run my bots on 32 bit
you don't need GitHub desktop
use vps
^
still gonna use 32 bit :P
what's "i see queue"?
go back and do it all over again
that's what you get for using GitHub with heroku
what's "i see queue"?
thats what the mods always say
people should use github
because it teaches people version control
which is the gold standard if you want to work with others or just run a good system
then you probably have 2 instances running or so
cause you run it with heroku and with your computer
π’
???
ad boooo
Can I get a user using client.users.cache.get() using a snowflake directly?
discord.js v12
my brain is disintegrating
@pale vessel hows your brain now
it's an ice cream now. pretty good tbf
@cunning glen #topgg-api
sendEmbed has been deprecated for a long time
deprecated doesnt mean removed
deprecated is a warning telling you it will be removed in the future
you ignored the warning, and now it was finally removed
yes, so use channel#Send, it works with embeds.
.send(embed) or .send({embed:embedObject})
what is ksoftsi lyrics TypeError: Cannot read property 'length' of undefined
Cannot read property 'length' of undefined explains everything
uh
in what line does the error appear?
ksoft lyrics get
I am lately getting this issue with mongooes ```js
[24/03/20 12:43:14] [ERROR] MongooseError [MongooseServerSelectionError]: connection timed out
Mongooes v - 5.9.6
Discord.js v - 12.0.2
const mongoose = require('mongoose');
bot.db = mongoose;
mongoose.connect('xxx',
{ useNewUrlParser: true , useUnifiedTopology: true },
err => {
if (err) return console.error(err);
console.log(`Connected to MongoDB database on shard ${bot.shard.ids}!`);
});```
if (!data.data.length) throw new Error('No results');```
is this for me π
no bro
ahh ok
I don't know mongo
...
geez i tried to switch hosts, instantly regretted that decision
never going that again
no ad intended, but i use private-hosting normally, i tried to switch to geographically "my neighbours" in hops of saving a bit of money
i regretted that
bot doesnt respond at all
before
after
oof
you sure its not DNS
if you're using localhost:port it can fuck DNS up and make latency insane
do u use localhost:port for your directs or 127.0.0.1
Could someone help π
use 127.0.0.1:port and try it again
so for example http://localhost/api.php?req
it makes a big diffrence with latency
How do you count all users on discord.js 12?
not corrent
i mean it's not just the status request, it's also the ssh session that dies
then fetch
You likely won't be able to get an accurate result without having to waste resources
yuuup, i fucked my main vps
How can I tell if the emoji used in a message is a global emoji? The emojis of the global discord I mentioned here. (discordjs)
for example:
_emote sadasd
msg not global emote
and
_emote β€οΈ
msg this global emote
ew firefox xd
it's good
lol jk
how do I count all members accurately, not client.users.size
because, client.users.size slowly goes up, then resets when i restart the bot
You likely won't be able to get an accurate result without having to waste resources
A for loop could work
Your current approach is just cached users
and I need to only do it ever x seconds
@quartz hill regex
You could also add up member counts of each server but that will contain duplicates
therefor still not being accurate
So what should I do?
Emoji for everyone. https://twemoji.twitter.com/. Contribute to twitter/twemoji development by creating an account on GitHub.
The only real way would be to cache every user so you can make sure that there's no duplicates
which means wasting resources
Ask yourself if this number matters to begin with
ok thx
Β―_(γ)_/Β―
@heavy marsh
we cannot answer your question, you shall wait for someone that can do so though.
@modest maple which one do u prefer local host or that IP
that ip
it negates the localhost dns
it mades a big diffrence to latency at times
e.g
the diffrence betweem 1200ms and 5ms
aight, i shall try it with the ip
Can you provide more information on what your connection string looks like @heavy marsh just censor/replace the sensitive information
const mongoose = require('mongoose');
bot.db = mongoose;
mongoose.connect('mongodb+srv://xxx@cluster1-mmwsa.gcp.mongodb.net/test?retryWrites=true&w=majority',
{ useNewUrlParser: true , useUnifiedTopology: true },
err => {
if (err) return console.error(err);
console.log(`Connected to MongoDB database on shard ${bot.shard.ids}!`);
});
I did sharde the bot yesterday. It gave me errors few hours ago
it was working fine
geez still a big delay, changing back
Note that if you specify useNewUrlParser: true, you must specify a port in your connection string, like mongodb://localhost:27017/dbname. The new url parser does not support connection strings that do not have a port, like mongodb://localhost/dbname.
quoted from https://mongoosejs.com/docs/connections.html, maybe this is causing the issue?
that should cause the issue
i had that once too
when i added the port it worked
so now i need help
client.on("ready", () => {
console.log("online!");
client.user.setActivity(`!!help | ${client.guilds.size} Servers`);
})```
For some reason it gives me an 'undefined' output
client.guilds.cache.size
alright I'll try
@heavy marsh make sure u are putting the proper username and password
Oh, now it worked, thank you
I did but i am trying to see how to do that ...
https://discordapp.com/channels/264445053596991498/272764566411149314/691998928832430121
mongoose.connect('mongodb+srv://xxx@cluster1-mmwsa.gcp.mongodb.net/Cluster1?retryWrites=true&w=majority',
So like this ?
mongoose.connect('mongodb+srv://xxx@cluster1-mmwsa.gcp.mongodb.net:27017/Cluster1?retryWrites=true&w=majority',
yes
How can I do that a bot send every day at 8am: "Goodmorning!" ?
setInterval function
ye
or check the day time
there's probably any package that makes it easier
lemme search...
@agile orchid port is not required
Which one is better:
const Discord = require('discord.js');
const client = new Discord.Client();
client.login("token").then(() => {
console.log("I am ready");
var guild = client.guilds.get('guildid');
if(guild && guild.channels.get('channelid')){
guild.channels.get('channelid').send("Good Morning").then(() => client.destroy());
} else {
console.log("nope");
//if the bot doesn't have guild with the id guildid
// or if the guild doesn't have the channel with id channelid
}
client.destroy();
});
OR
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('message', message => {
//...
});
client.on('ready', () => {
setTimeout(function(){ // in leftToEight() milliseconds run this:
sendMessage(); // send the message once
var dayMillseconds = 1000 * 60 * 60 * 24;
setInterval(function(){ // repeat this every 24 hours
sendMessage();
}, dayMillseconds)
}, leftToEight())
})
function leftToEight(){
var d = new Date();
return (-d + d.setHours(8,0,0,0));
}
function sendMessage(){
var guild = client.guilds.get('guildid');
if(guild && guild.channels.get('channelid')){
guild.channels.get('channelid').send("Good Morning");
}
}
client.login("token");
Which one is better?
no
the 2nd one
?
the first one is wrong
you only have to do client.guilds.get('id').send('message');
the .on("ready") event was created for that reason
On stack overflow, he says the first one
MongooseError [MongooseServerSelectionError]: connection timed out
at new MongooseServerSelectionError (/home/container/node_modules/mongoose/lib/error/serverSelection.js:22:11)
at NativeConnection.Connection.openUri (/home/container/node_modules/mongoose/lib/connection.js:823:32)
at Mongoose.connect (/home/container/node_modules/mongoose/lib/index.js:333:15)
at Object.<anonymous> (/home/container/bot.js:54:10)```
same error
you only have to do
client.guilds.get('id').send('message');
@agile orchid Who, me?
ye
well i use an older version of d.js on my other bot
if it doesn't work then that's why
But then the bot doesn't will send the message at 8am?
guilds dont have a send method lol

you need to find a channel to send in
What if guild.send got the guild's system message channel and sent message there
you already have guild.systemChannel.send lol
And how can I do that the bot will send the message in a channel: #chat and not in a channel: [id] ?
Simplicity!
i'm pretty sure you need to pass a function instead
get would be much easier
depends
@wide wharf you need to use the ready event, not the login event. then you need to find a channel to send the message to
if you know the channel by id, use guild.channels.cache.get (if you're using v12) or guild.channels.get (if you're using v11)
if you dont know the channel id, and want to get it by name, use .find instead of .get, but with a function. ie: guild.channels.cache.find(channel => channel.name === "name")
you cant
crashes = offline
if you have a process manager or something to auto-restart it, you can make it dm you when it restarts
on the ready event, send a dm to yourself
yes
yes, get your user by id
although catching errors and preventing crashes in the first place would be preferable lul
MongoNetworkError: failed to connect to server [cluster1-shard-00-02-mmwsa.gcp.mongodb.net:27017] on first connect [MongoNetworkError: connection timed out
geez you're damn lazy
stop being lazy and asking us todo it for you
god damn it.
s m h
it was
oh good
I'm sorry. It's my fault for managing the My bot. My bot(YBOT) was hacked just now, causing damage to test 1 room of testing. I am truly sorry. I'll do my best to make sure it doesn't happen in the future. <@&304313580025544704>
-atmods
Please do not mention (ping) more than one or two moderators for help, unless there is an emergency.
Here are some examples of emergencies:
- Raids / Multiple members mass spamming.
- Severe disruption of Discord's ToS (NSFW content, etc)
- Anything that requires more than 2 moderators to handle.
don't ping mods smh
Oof
Still wondering, how do you even manage to get hacked, just use your token as an argument for the program instead of implementing it straight in the code
@modest maple i think it was really just cloudflare being stupid, works perfectly now.
Hey there
is in the Discord JDA an catchall event ? or something
how i get ID of mentioned channel? python
docs should be able to help you
ok
@earnest phoenix the bot sees the mention as [#123423455646](/guild/264445053596991498/channel/123423455646/)
i kwno ||sorry my bad english xd||
haha
then just use replace to strip the <#
split message at " "
replace "<#" and ">"
leaves you with id
@client.command()
async def getid(ctx, channel: discord.TextChannel):
await ctx.send(f'ID: {channel.id}')
this work?
try it out
work
That was the link i was searching furiously 
Lol
it has been here multiple times
fortnite master bot is offline how to change that
DM the Bot owner, uno momento
wrong server
or server
OK, thanks
Hi, how can I get some support as the bot not working in our server?
https://hasteb.in/ugireqis.js can anyone tell me why my console retruns me an error saying IdentityJS.generateID() is not a function?
you guys do understand this is the wrong server
wut
hey
File "bot.py", line 18
return logs[str(message.guild.id)_(channel.id)]```
error in _

return logs[str(message.guild.id)_(channel.id)]
^
SyntaxError: invalid syntax```
@uneven wyvern I dont think .generateID() is a function
what language @earnest phoenix
ok
@earnest phoenix that is not how that works
@earnest phoenix that is not how that works
@modest maple how?
because you cant just add a _ between two variables and have it go yay
with open('logs.json'. 'r') as f:
^
SyntaxError: invalid syntax```
@client.command()
async def setlogs(ctx, channel: discord.TextChannel):
with open('logs.json'. 'r') as f:
logs = json.load(f)
logs[str(ctx.guild.id)(channel.id)] = channel.id
with open('logs.json', 'w') as f:
json.dump(logs, f, indent=4)```
python seems so strange
so you dont use js or py
Ignoring exception in command setlogs:
Traceback (most recent call last):
File "/app/.data/d3c27b63733278df68d1fa9f5eeb8d41-site-packages/discord/ext/commands/core.py", line 79, in wrapped
ret = await coro(*args, **kwargs)
File "bot.py", line 222, in setlogs
logs[str(ctx.guild.id)(channel.id)] = channel.id
TypeError: 'str' object is not callable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/app/.data/d3c27b63733278df68d1fa9f5eeb8d41-site-packages/discord/ext/commands/bot.py", line 863, in invoke
await ctx.command.invoke(ctx)
File "/app/.data/d3c27b63733278df68d1fa9f5eeb8d41-site-packages/discord/ext/commands/core.py", line 728, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/app/.data/d3c27b63733278df68d1fa9f5eeb8d41-site-packages/discord/ext/commands/core.py", line 88, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'str' object is not callable```
when i use p!setlogs <#mention>
:u
Might want to learn more about python
https://discordapp.com/channels/264445053596991498/272764566411149314/692013902065827850
Why open the file twice
@slender thistle cough read cough cough write
why even use json files π€·ββοΈ
yes
help
this error throws only when another user than the author is sending a message
d.js@v11.6.3
@earnest phoenix U want to send all or only a word? @earnest phoenix
it's an array of strings split by a space
if you access [1], you're only going to get one of the strings
[0] would be the command name
No
@sudden geyser with the 0 i don't have the command name
I have the first arg...
(Ty the slice)
you're only slicing the prefix from the string, not the actual command name. Try logging args and you'll see the command name as the 0 element.
Do you want to send the entire "hey there" string.
let args = message.content.split(' ').slice(1);
(Ty the slice)x2
if you want to send the entire string, just use the .join() method. Look up the method online
@earnest phoenix [0] is command name
prefix.length means number of characters in the prefix
As the error shows
misn't defined
@late hill the await m.delete() is on line 40
there is nothing that defines m as message in the screen shot
the error says u have a problem with m
with r.first().delete()
no
await m.delete() is on line 40
and the error is on line 41
didnt see the full error so oki
can someone help me and do a bot for me?
it's the full error
why do you need m if I have problems with r
@finite bough calm the fuck down jesus no need to be rude
let text = args.join(" ").slice(1); ?
@earnest phoenix use args[2] to remove say
@weary wolf 1st of all read the channel topic, 2nd i am not being rude talking offtopic can lead to mute
If u want u can just use this:
let args = message.content.split(' ').slice(1);
args.join(" ");
:/
@earnest phoenix use args[2] to remove say
args[0]
@finite bough 1st it wasnt off topic 2nd u were rude 3rd idc about the mute 4th im a beginner 5th why u keep pinging? ffs
Okay okay
beginner is something else
Leave him alone Shiemi
alex is that the full error?
He's not being rude
(Sorry)
@earnest phoenix args[number]
we're here to help
number of words u want it to skip
if u do let text = args[1] yes
then bot starts awaiting for a response
.join(' ') is used to send all the words after the single word
if someone other than the message author sends a message, bot doesn't ignore the message
even if I put a filter
and it throws that error
@topaz fjord ok buddy there's also something called paying someone but yeah.. never heard of that did you?
You never offered in the message
this is a development channel, not a searching for developers one
If you want someone to do a bot for you, you contact the owner to get it posted in #434058442764714002
then add .join(' ')
http://alex.is-bad.com/A8aq27e.png
http://alex.is-bad.com/443XEw8.png
when I execute the command the bot starts awaiting for a message. If a another user than the command message author writes a message, bot doesn't ignore his message and it throws the error. If the command message author writes a message, it won't throw that error
d.js@v11.6.3
help pls
k
they have some differences
and its a good practice to use ===
can u show ur text code?
not args?
you can't call .join on a string. pls learn js
if(!text){
return message.channel......
}
wwrewewasdasd
console log args
args.slice(1).join(' ')
no
yes
you slice after joining
yes
if the command is args[0]
you have to slice it?
do a console.log(args)
and give the output then
console log args
and give the output
http://alex.is-bad.com/A8aq27e.png
http://alex.is-bad.com/443XEw8.png
when I execute the command the bot starts awaiting for a message. If a another user than the command message author writes a message, bot doesn't ignore his message and it throws the error. If the command message author writes a message, it won't throw that error
d.js@v11.6.3
help ples
if args is an array, like this [1,2,3,4,5] then args[0] will give you the first element 1, args[1] the seconds element 2 and so on. args.join() will join the array by whatever you define, lets say args.join("") gives you 12345 (join with nothing), or args.join(" ") to join with a space giving you 1 2 3 4 5. then there is the slice function which removes an item from the array, for example args.slice(1) will remove the first item, making it [2,3,4,5]. so to obtain a string from the array, minus the first element, you simply do array.slice(1).join(whatever)
@earnest phoenix
i told you
var text = args.slice(1).join(' ')
.-.
np
?
actually yes
I spoon fed you
:)
http://alex.is-bad.com/A8aq27e.png
http://alex.is-bad.com/443XEw8.png
when I execute the command the bot starts awaiting for a message. If a another user than the command message author writes a message, bot doesn't ignore his message and it throws the error. If the command message author writes a message, it won't throw that error
d.js@v11.6.3
tho
because there's no collected message to delete
@quartz kindle You killed my brain there
@wheat jolt does awaitMessages stop waiting if another user answers?
yes
It should ignore the messages sent by other users than the command message author
because there's no collected message to delete
@pale vessel this info was clear to me since I got the error first time
can you console.log both author ids?
try doing js let filter = message => { console.log(message.author.id,msg.author.id); return message.author.id === msg.author.id }
sure, hold on
359812392504524811 399868039484538884
the ids are different
another user sent the message
and the filter still passed?
your version is v11.4 right?
11.6.3
well, this explains the problem
should i downgrade to v11.4?
aah
if you dont know the channel id, and want to get it by name, use .find instead of .get, but with a function.
ie: guild.channels.cache.find(channel => channel.name === "name")
@quartz kindle so it would be for me:guild.channels.cache.find(channel => channel.name === "chat")




