#development
1 messages · Page 660 of 1
and is that completely separate from the database?
or you could do no caching at all
since mongo is pretty damn fast on its own
"heal":
any real db can easily handle a discord bot (unless it has millions of guilds)
groovyman
ahh okay thanks a lot from you all uwu
who dis new phone
woo boy do i love mongodb
mango de bee
it totally doesnt force me to retry transactiosn 3+ times everytime i do them
for some reason


ravy when are you making mongo-bongo
I started loving mongodb when I wrote this
mangodeebee is webscale
ravy with the better structure for it
but its just so damns imple
range of what to find
everything to find
sort the find by a property
@scenic vapor whenever I need a mongo wrapper
filter it by a limit
currently I don't
then call back
because it's handled by a framework for me
go yoink it
Natan is that SQL?
from somewhere
yes
@scenic vapor I would use a custom thing for my bot but it's open source and I want people to actually understand and be able to contribute so I use well-known stuff
How to define rank in SQL
my usage of Mongo is caveman style, but it was quick to learn

I just needed a db that had a json-type structure for player rpg stats
lord eh
no please
my king!
brb making fast.db
my emperor?
@tight heath yea. Also it has many bugs
your bad
it's princess ravy
charcoal
your highness
I'm kinda more in a caffeine wake-ish state
themselves

a plural?
I truly pity anyone trying to learn ESOL
hahaha I consider myself to have a good vocabulary, but I've never really gone into the intricacies of grammar
anyways #memes-and-media bouys and grills
👍
to on-topic ill change it
for whatever reason I had an issue with abbreviated conditionals in the past
you mean the ternary operator
hey its ya boi amature programmer here, how do i pass a variable from a function to another or make it global?
For example,
if(x === "20"){
const y = "50";
}
console.log(y)
only an example to help another issue any help appreciated thanks
huh
function? return
odd wasn't working for me
That exact codeblock won't work @scenic vapor
your example is just a conditional that outputs correctly
except y can be undefined
y won't be defined at all
it'll be a ReferenceError
as far as javascript is concerned, y doesn't exist outside that if statement
let y = some default value;
if(x === "20"){
y = "50";
}
console.log(y)```
let y;
Okay, thank you. Ill try that out, was doing that before but maybe something else was undefined.
if you'd like, you can read up on it more: https://dev.to/sandy8111112004/javascript-introduction-to-scope-function-scope-block-scope-d11
@opaque eagle Thank you, will do -- I just realized why it was returning undefined, annd thanks for the help
because that'd make no sense
You're forgetting the {}
Also what r u trying to do anyways... 1 === 1 would be true at all times
{} are not required for one-liners
Yeah but you can't define variables using a one-liner if statement
but it's good practice to always use {}
That too ^
see: CVE-2014-1266
I only use a one-liner if when I'm returning some value
if (true) throw 'natan nerd';
that's probably the most famous case of lack of {} leading to issues
in that case, ssl being completely broken
1 === 1 just to create a conditional declaration
oh nvm
if(1)
shush
if(!0)
I am a hobbyist of the hobbyist order
if(true)
dog = "sAiNt BerNaRd";
if(dog.toLowerCase() === "saint bernard")
if(__dirname !== dog)
if(0===0){zero=0}
I want to get this Store { id: 4835, name: 'Spectre', rarity: 'Sturdy', category: 'BRDailyStorefront', vbucks: 800, image: 'https://cdn.thetrackernetwork.com/cdn/fortnite/ECF94835_large.png' },
i used let imagine = shop.filter(s=> s.id == 'image')[0]; => undefined
but isn't working
Details
0:Store {id: 11583, name: "Dream", rarity: "Sturdy", …}
1:Store {id: 11584, name: "Astral Axe", rarity: "Quality", …}
2:Store {id: 11582, name: "Arcana", rarity: "Quality", …}
3:Store {id: 868, name: "Shadow Ops", rarity: "Quality", …}
4:Store {id: 11585, name: "Shard Break", rarity: "Sturdy", …}
5:Store {id: 11581, name: "Luminos", rarity: "Quality", …}
6:Store {id: 5340, name: "Waterworks", rarity: "Handmade", …}
7:Store {id: 354, name: "Stealth", rarity: "Handmade", …}
8:Store {id: 11019, name: "Slap Happy", rarity: "Sturdy", …}
9:Store {id: 10897, name: "Munitions Major", rarity: "Handmade", …}
10:Store {id: 4835, name: "Spectre", rarity: "Sturdy", …}
11:Store {id: 5400, name: "Noir", rarity: "Quality", …}```
none of the ids are equal to image
i just want to get the images from all 12 array
Hi guys
Can someone explain to me what does ? do in JS?
When is the release date for rule bot
]]wrongserver @sinful cairn
This server is NOT the support server for ANY bot. You need to click on the "Support Server" button on the bot's page, not the "Join Discord" button at the top of DBL.
something ? something : something
Ah conditional operators
It's like condition ? value_1 : value_2
If condition is true then value_1 is returned
If false value_2 is returned
oh thanks
At least that's how it is in C#. Not quite sure about JS
You can try and confirm I guess
it is
also known as the ternary operator 😃
(technically a ternary operator is one that has 3 operands, it just happens that it's the only operator with 3 operands in most C-based languages)
i only know that because i had to define a ternary operator type
how can i make owner buttons square (in my bot page)
please mentions me when you answer
Ah, the best way to ensure no one can access these permission levels ;)
if (message.author.id === undefined) permlvl = 7; // Reserved
if (message.author.id === Infinity) permlvl = 8; // Reserved
if (message.author.id === false) permlvl = 9; // Reserved
if (message.author.id === "230880116035551233") permlvl = 10; // Developer
if (1 === 2) permlvl = 11; // secret```

but why
i am trying to muse commands with python and i did this:
@client.command()
async def test(ctx):
await ctx.send('Toast')
i put the client = commands.Bot(command_prefix='"') but nothing appears and there are no errors
pls help
how you making this colorful text
for c# it's cs
be patient, you aren't contributing anything but just being annoying by doing that, if someone who does python and know how to resolve the issue comes across it, they will probably help you

@indigo geyser send whole code
ok
from keep_alive import keep_alive
import discord
import os
from discord.ext import commands
import asyncio
import random
client = commands.Bot(command_prefix='"')
@client.event
async def on_ready():
print ('I am', client.user)
time = 0
while time == 0:
await client.change_presence(activity=discord.Game(name='Tanto siamo anti Raid'))
await asyncio.sleep(5)
await client.change_presence(activity=discord.Game(name='"help'))
await asyncio.sleep(5)
@client.command()
async def test(ctx):
await ctx.send('Toast')
@client.event
async def on_message(message):
if message.content.lower().startswith('"ping'):
emb = discord.Embed(title='*~~{}~~ PONG*'.format(message.author), colour = 0x846a15)
emb.set_image(url = 'https://cdn.discordapp.com/attachments/552786907424358401/587360986458226739/pong.gif')
await message.channel.send(content=None, embed=emb)
token = os.environ.get("secret")
client.run(token)
keep_alive()
token = os.environ.get("secret")
client.run(token)
@slender thistle
What the fuck
whole
Why keep_alive and multiple .runs
When it's literally blocking and the docs say so
because i was trying if it works with two difference runs
Yeah that ain't happening. Use only ONE client OR Bot instance
fixed
Also, you assign the test command to bot but client runs first
So either use bot or client, not both
i edited the message
working
trying something to see if it works
no longer working
CTRL + Z the fuck out of your file
@indigo geyser I don't have an answer to your question, but wouldn't that status change abuse the api
^ there should only be 5 status change maximum every minute
or else its counted as an API abuse
Legit said why it doesn't work
is there an if to check if the user's DMs are closed?
Negative
oof
You'll have to send a message and then see if it errors out with a Forbidden
(node:3908) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send messages to this user
at item.request.gen.end (C:\Users\Dany\Desktop\DiscordBot\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:85:15)
at then (C:\Users\Dany\Desktop\DiscordBot\node_modules\snekfetch\src\index.js:215:21)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:3908) 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: 4)
not surprised at all
i'd just like the bot to return instead of sending this
@sudden geyser it's a private bot
my bot that is here (@keen talon) wait 25 secs
@slender thistle i understood that if there is the on_message the commands doesn't work
i don't understand why
seems
client.users.get('IDHERE").username
only seems to work when the bot is in the same server as that user, otherwise it throws a "username undefined" what am i doing wrong?
Obviously because you don't use bot.process_commands(message) when using on_message
ok
@old geyser are you joking?
@warm marsh nuh mate, learning, hence why i asked for help
The bot can only access users it shares guilds with.
Thats all i needed to know
Alright. Good luck.
@earnest phoenix send(...).catch(() => null)
@warm marsh wrong
@old geyser are you using discord.js
if so try client.fetchUser(id)
it fetches from the api
thanks @sick cloud
err at ```"scripts": {
"start": "node index.js"
},
{
"name": "god",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"abbrev": "^1.1.1",
"abort-controller": "^3.0.0",
"agent-base": "^4.3.0",
"ajv": "^6.10.0",
"ansi-regex": "^2.1.1",
"ansi-styles": "^3.2.1",
"aproba": "^1.2.0",
"are-we-there-yet": "^1.1.5",
"arrify": "^2.0.1",
"ascli": "^1.0.1",
"asn1": "^0.2.4",
"assert-plus": "^1.0.0",
"async": "^0.2.10",
"async-limiter": "^1.0.0",
"asynckit": "^0.4.0",
"aws-sign2": "^0.7.0",
"aws4": "^1.8.0",
"balanced-match": "^1.0.0",
"base64-js": "^1.3.0",
"bcrypt-pbkdf": "^1.0.2",
"better-sqlite3": "^5.4.0",
"bignumber.js": "^7.2.1",
"bindings": "^1.2.1",
"brace-expansion": "^1.1.11",
"buffer-equal-constant-time": "^1.0.1",
"bytebuffer": "^5.0.1",
"cacheable-request": "^6.1.0",
"camelcase": "^2.1.1",
"canvas": "^2.5.0",
"node": "^12.6.0"
},
"devDependencies": {},
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/927gaming/godtypecode4.git"
},
"author": "GOD",
"license": "ISC",
"bugs": {
"url": "https://github.com/927gaming/godtypecode4/issues"
},
"homepage": "https://github.com/927gaming/godtypecode4#readme"
}
@tight heath thanks it worked
err = `jq: error (at package.json:1): Cannot index string with string "engines"
parse error: Expected string key before ':' at line 1, column 10`
idk why err at package.json
because that's not valid json
??
...
json objects have no ordering
and you can't just randomly paste stuff in the file and expect it to work
ok
Anyone care to help me with this ping command that is just making me want to yeet myself out a window
import discord, random, asyncio
from discord.ext import commands as client
from Cogs.config import conf
#Imports
class Ping(client.Cog):
def __init__(self, bot):
self.b = bot #Please no touchy thx
@client.command()
async def ping(ctx):
embed = discord.Embed(
colour = discord.Colour.pink()
)
embed.add_field(name='Pong!', value=f'`{round(client.latency * 1000)}ms`', inline=False)
await ctx.send(embed=embed)
def setup(bot):
bot.add_cog(Ping(bot))
File "maid.py", line 42, in <module>
client.load_extension(f"Cogs.{name}")
File "/usr/local/lib/python3.6/dist-packages/discord/ext/commands/bot.py", line 617, in load_extension
lib = importlib.import_module(name)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 674, in exec_module
File "<frozen importlib._bootstrap_external>", line 781, in get_code
File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/root/alt-bots/sayonika/Cogs/ping.py", line 20
await ctx.send(embed=embed)
^
SyntaxError: invalid syntax
I know its probably obvious, but i'm new to this stuff
import discord, random, asyncio
from discord.ext import commands as client
from Cogs.config import conf
#Imports
class Ping(client.Cog):
def __init__(self, bot):
self.b = bot #Please no touchy thx
@client.command()
async def ping(ctx):
embed = discord.Embed(
colour = discord.Colour.pink()
)
embed.add_field(name='Pong!', value=f'`{round(client.latency * 1000)}ms`', inline=False)
await ctx.send(embed=embed)
def setup(bot):
bot.add_cog(Ping(bot))
updated file
your indentation is completely wrong
- I suggest importing
commandsas it is - Functions in a class must have an argument that refers to the class of the command, which is usually either
clsorself - FiX yOuR iNdEnTs
@earnest phoenix if the issue is still up
still existing
So, Can you remove bots from client.guilds.reduce((prev, next) => prev + next.memberCount, 0);?
or would I have to change memberCount to members.filter(member => !member.user.bot).size?
This should do the same thingjs client.users.filter(user => !user.bot).size
No need to reduce
That only gets cached users.
same with Guild.members iirc
Idk, It was discussed a few days ago.
nvm
users are rarely not cached
I used to think Guild.memberCount was a getter that just returned the size of this.members, but I guess it's provided with the Guild object itself
https://discordapp.com/developers/docs/resources/guild
memberCount doesn't rely on cache, members.size does
Yeah, i know now
But memberCount includes bots.
Yep
so does members
So this is why I asked.
not if they're filtered.
members.filter(member => !member.user.bot).size
That's why I suggested filtering
well that doesn't modify members itself but yes it returns a new collection
If you're gonna iterate through client.guilds and filter members, you might as well just iterate through client.users
As I said, It doesn't get all the users.
There was another guy that also had this question and the response was to reduce guilds
with memberCount
the only way to count members without bots is to fetch all members
afaik, guilds provide a method to fetch all members without caching them
<Guild>.fetchMembers('', size)
how do I call a function from my index.js to my command handler?
Attach it to your client or module.export it
oh wait I can just make the function inside the module.export.run
I need help. My program won't go inside bot.on('ready)
whats your full code
bot.on('message', async msg =>{
if(msg.author.bot) return undefined;
if(!msg.content.startsWith(PREFIX)) return undefined;
var cont = msg.content.slice(PREFIX.length).split(" ");
var args = cont.slice(1);
if(msg.content.startsWith(`${PREFIX}play`))
{
const voiceChannel = msg.member.voiceChannel;
if (!voiceChannel) return msg.channel.send("Puff! (I need to be in a voice channel to sing!)");
const songInfo = await ytdl.getInfo(args[0]);
const song = {
title: songInfo.title,
url: songInfo.url
};
if(!serverQueue) {
const queueConstruct = {
textChannel: msg.channel,
voiceChannel: voiceChannel,
connection: null,
songs: [],
volume: 5,
playing: true
};
queue.set(msg.guild.id, queueConstruct);
queueConstruct.songs.push(song);
try{
var connection = await voiceChannel.join();
queueConstruct.connection = connection;
play(msg.guild, queueConstruct.songs[0]);
} catch (error) {
queue.delete(msg.guild.id);
msg.channel.send(`I could not join the voice channel.`)
}
} else {
serverQueue.songs.push(song);
console.log(serverQueue.songs);
return msg.channel.send(`${song.title} has been added to the queue!`);
}
return undefined;
}```
tis does
nice token leak
function play(guild, song){
const serverQueue = queue.get(guild.id);
if(!song){
serverQueue.voiceChannel.leave();
queue.delete(guild.id);
return;
}
console.log(serverQueue.songs);
const dispatcher = connection.playStream(ytdl(song.url, {filter : 'audioonly'}))
.on('end', () => {
console.log('Song ended');
serverQueue.songs.shift();
play(guild, serverQueue.songs[0])
})
.on('error', error =>{
console.error(error);
});
dispatcher.setVolumeLogarithmic(5 /5);
msg.channel.send(`Puff, puff puff! (Now playing: ${songInfo.title}!)`);
}
bot.login(token);
})
I'll just change it then
anyway yeah
const Discord = require('discord.js');
const ytdl = require('ytdl-core');
const bot = new Discord.Client();
const fs = require('fs');
const queue = new Map();
bot.commands = new Discord.Collection();
fs.readdir('./commands/', (err, files) =>{
if(err) console.error(err);
var jsfiles = files.filter(f => f.split('.').pop() === 'js');
if (jsfiles.length <= 0) {return console.log('No commands found.')}
else {console.log(jsfiles.length + ' commands found.')}
jsfiles.forEach((f, i) => {
var cmds = require(`./commands/${f}`);
console.log(`Command ${f} loading...`);
bot.commands.set(cmds.config.command, cmds);
})
})
const PREFIX = 'puff.'
const token = 'token-here';
var version = '1.0.0'
var servers = {};
bot.on('ready', msg =>{
console.log('Jigglypuff is online.');
bot.user.setActivity('Super Smash Bros. Ultimate', {type: "PLAYING"});
})
bot.on('message', msg =>{
var cont = msg.content.slice(PREFIX.length).split(" ");
var args = cont.slice(1);
const serverQueue = queue.get(msg.guild.id);
if(!msg.content.startsWith(PREFIX)) return;
var cmd = bot.commands.get(cont[0])
if(cmd) cmd.run(bot, msg, args);
}
)```
there fixed
i'm trying to make a windows forms, visual studio 2017, c# text editor and i need to know if a file was opened with the program or the program got opened normally
i think it happened when i renamed one of my command handles and automatically updated stuff, but I already deleted that. I also checked my package.json if the main file has been changed but it hasn't
I really have no idea how to fix it this time
That code makes me wanna die
same
since i just started it, what i have rn is this
Why are you logging in with your play function
but I'm gonna refactor once I get my bot running again
And do you have a message event in every file
yes I do
Ok no
@earnest phoenix That's literally nothing
you don't need a message event in every file
Just call the message object from your run function
what even is the problem viciou
you never said it lol
oh yeah I accidentllay removed it
accidentally*
anyway my main problem is it won't go through the bot.on('ready)
@hollow saddle
thank you
ye
No errors actually
It just won't
4 commands found.
Command greet.js loading...
Command info.js loading...
Command skip.js loading...
Command stop.js loading...
PS C:\Users\Viciou\Downloads\Files\_Discord Bots\Smash PH Music Bot>```
that's it
I just console.logged if the .js files in my commands folder are read
bot.on('ready', msg =>{
console.log('Jigglypuff is online.');
bot.user.setActivity('Super Smash Bros. Ultimate', {type: "PLAYING"});
})
``` why are you using msg
ready doesn't take any params iirc
What the
well, before I deleted my play.js, it worked
You don't need to use Type
Playing is default yeah
It's because you have the client login in your play function
That literally gives me an anerism
If I could spell
function play(guild, song){
const serverQueue = queue.get(guild.id);
if(!song){
serverQueue.voiceChannel.leave();
queue.delete(guild.id);
return;
}
console.log(serverQueue.songs);
const dispatcher = connection.playStream(ytdl(song.url, {filter : 'audioonly'}))
.on('end', () => {
console.log('Song ended');
serverQueue.songs.shift();
play(guild, serverQueue.songs[0])
})
.on('error', error =>{
console.error(error);
});
dispatcher.setVolumeLogarithmic(5 /5);
msg.channel.send(`Puff, puff puff! (Now playing: ${songInfo.title}!)`);
}```
it's not, though. this is my play function
https://pastebin.com/xsP5r4Kx @hollow saddle
Your login is inside your second message event
You don't need 2 message events
48: bot.on('message', async msg =>{
133: bot.login(token)
136: )}
Take bot.login out of that messag eevnt
And if you have a command handler why aren't you using it
Yeah. That's a big one https://img.rookmine.com/190723050142.png
@hollow saddle still kind of confused with parameter passing from the index.js' function if I call it to my command handler
you have that
so
One sec
run: async (bot, msg, args) => {
...
},
};```
your actual code will look like that in your command file
And whatever you run goes in the brackets
You can either bind the function to the client
bot.play = (params) => {
Or export it then require the file
// index.js
module.exports = play(params);
// play.js
const play = require('../index.js')
If my logic serves me right
Yes
Not 50 million message events
Only one is needed to capture the message object
All right I fixed that part now thanks!
and on another hand,
const ytdl = require('ytdl-core')
const index = require('../index.js')
module.exports.run = async (bot, msg, args, queue, serverQueue) => {
const voiceChannel = msg.member.voiceChannel;
if (!voiceChannel) return msg.channel.send("Puff! (I need to be in a voice channel to sing!)");
const songInfo = await ytdl.getInfo(args[0]);
const song = {
title: songInfo.title,
url: songInfo.url
};
if(!serverQueue) {
const queueConstruct = {
textChannel: msg.channel,
voiceChannel: voiceChannel,
connection: null,
songs: [],
volume: 5,
playing: true
};
queue.set(msg.guild.id, queueConstruct);
queueConstruct.songs.push(song);
try{
var connection = await voiceChannel.join();
queueConstruct.connection = connection;
index.play(msg.guild, queueConstruct.songs[0]);
} catch (error) {
queue.delete(msg.guild.id);
msg.channel.send(`I could not join the voice channel.`)
}
} else {
serverQueue.songs.push(song);
console.log(serverQueue.songs);
return msg.channel.send(`${song.title} has been added to the queue!`);
}
}
module.exports.config = {
command: 'play'
}```
msg.channel.send(`I could not join the voice channel.`) it always goes inside this catch block
The catch block catches any error from the try block
I'm guessing it originates from your play function again since I saw that you used msg in there
So add a new param called msg
so
function play(msg, guild, song)
Or just
since you can grab the guild from the message object with msg.guild
Not to mention that you call the play function inside of itself
Which would definietly throw an error
Which is why it's throwing the catch block
I think I got it only with one problem
if I do this index.play(params), it gives me TypeError: index.play is not a function
while if I only use play(params) it gives me ReferenceError: play is not defined
note that I imported my index.js const index = require('../index.js')
@hollow saddle
maybe play isn't an exported function in index.js
Try adding it to module.exports
module.exports inside the index.js? or my .js file inside my commands folder?
in ur index.js
Thank you for repeating that
I was agreeing with you saying that's what viciou needs to do 
and then put this in my whatevercommand.js
const index = require('../index.js')(guild, song)? or shall I remove the parameters of the play functions beside the index.js?
Remove the params
And then use index.play(params)
And you need to add an msg param since you call msg.channel.send in your play function
Replace it with guild since you can get the guild with msg.guild
replace what param with guild?
msg
yeah that's what I did
Replace guild with msg
Not the other way around
Use msg, not guild
For the param
ohhhh
I get this though ReferenceError: msg is not defined
function play(msg, song){
const serverQueue = queue.get(msg.guild.id);
if(!song){
serverQueue.voiceChannel.leave();
queue.delete(msg.guild.id);
return;
}
console.log(serverQueue.songs);
const dispatcher = serverQueue.connection.playStream(ytdl(song.url))
.on('end', () => {
console.log('song ended');
serverQueue.songs.shift();
play(guild, serverQueue.songs[0]);
})
.on('error', () => {
console.error(error);
});
dispatcher.setVolumeLogarithmic(5 / 5);
}``` here's the function in my `index.js`
Wait so msg wasn't in the play command 
yeah...
God I guess your indentation fucked me up in the pastebin
yup sorry
Alright fine keep guild but don't call the play function inside of itself
lol no probkem
well this is where I use the play function, inside my play.js
module.exports.run = async (bot, msg, args, queue, serverQueue) => {
const voiceChannel = msg.member.voiceChannel;
if(!voiceChannel) return msg.channel.send(`not vc`);
const songInfo = await ytdl.getInfo(args[0]);
const song = {
title: songInfo.title,
url: songInfo.video_url
};
if(!serverQueue) {
const queueConstruct = {
textChannel: msg.channel,
voiceChannel: voiceChannel,
connection: null,
songs: [],
volume: 5,
playing: true
};
queue.set(msg.guild.id, queueConstruct);
queueConstruct.songs.push(song);
try {
var connection = await voiceChannel.join();
queueConstruct.connection = connection;
index.play(msg.guild, queueConstruct.songs[0]); //<--------
} catch (error) {
console.error(error);
queue.delete(msg.guild.id);
return msg.channel.send(`${error}`);
}
} else {
serverQueue.songs.push(song);
console.log(serverQueue.songs);
msg.channel.send(`${song.title} added to queue.`);
}
return undefined;```
Which is fine (apart from returning undefined. You should just use return; instead of retruning undefined) but I was talking about this
// in play function
const dispatcher = serverQueue.connection.playStream(ytdl(song.url))
.on('end', () => {
console.log('song ended');
serverQueue.songs.shift();
play(guild, serverQueue.songs[0]); <==========================
You call the play function inside of itself
but won't I need to recursive if I want the next song to play again after the current song is playing has ended?
Sure but you can put it in a loop
Calling a function inside of itself doesn't work as far as I know
well it worked on the tutorial I was trying to follow, our only difference is I'm using command handlers, while he's not. that's why I'm having problems
I'm practicing command handlers too
and for another reason, `const serverQueue = queue.get(msg.guild.id);
^
TypeError: Cannot read property 'guild' of undefined`
Did you replace guild with msg or flipped it back
yeah I did
if I also add a parameter to my module.exports, it goes like this:``` module.exports = exports = play(msg, song);
^
ReferenceError: msg is not defined```
uhhh that's not how you export a function
damn stackoverflow baited me
what is that even supposed to do
so shall I use (msg, song) instead?
a module per guild and song?
nope those are params for the play() function
then why are you calling it
so it must only be module.exports = play()?
yes I want to pass that function into my other .js file
then pass the function
don't call it
you're passing the value returned by the play function if called without arguments
they said I should do module.exports inside my index.js file, where the play function resides, and use index.play(params) inside my play.js (command) file
Well uhh I just realized how much of a massive idiot i am and how big of a brainfart I had
are embeds sent the same way as raw text?
nah dude I'm the idiot one for not knowing how to use these shits
In index.js you can do
module.exports.play = play;
which exports the function
And in play.js you can do
const index = require('../index.js')
index.play(guild, song)
Or you can just put the entire play function in your play.js file and not have to worry about exporting it if you only need it for that file
My brain forgot how node works 
const Discord = require("discord.js");
const botconfig = require("../../config.json")
module.exports = {
config: {
name: "addrole-*",
Description: "Fügt jeden User eine rolle hinzu",
accessableby: "ADMIN",
aliases: ["addrole*"]
},
run: async (bot, message, args) => {
var guild = message.guild;
// Get role ID
const match = /(?:\s+([\s\S]+))/.exec(message.content);
if (!match) return message.reply("Invalid role given");
// Retrieve role
let role;
role = message.guild.roles.get(match[1]);
if (!role) role = message.guild.roles.find(r => r.name === match[1]);
if (!role) return message.reply(`No role found with a name or ID matching the input: \`${match[1]}\``);
var members = await guild.fetchMembers();
let i = 1;
// _______________________________HERE I NEED HELP________________________________________________________
for (let m of guild.members.values()) {
console.log("Doing", i++, "/", guild.members.size);
if (m.roles.has(role)) continue;
await m.removeRole(role);
if (i % 5 == 0) {
const wait = t => new Promise(r => setTimeout(r, t));
if(i == 1) message.channel.send(`_ _`).then( msg =>{
setTimeout(() => {
msg.edit(`rolle hinzugefügt an ${i} von ${guild.members.size}`);
}, 4400);
} )
await wait(5550) // 5 second of waiting
}
}
}}
//__________________________________________________________________________________________
can you guys pls help me ... i m trying to send a message and then edit it every 4,5s too the var i or i++ i don´t now if its difficult
😒
That would be API spam bro
await wait(5550) // 5 second of waiting
Still spamming the api to edit a message every 5 seconds
hmmm
why not wait(5000)
i mean still api abuse lol
@hollow saddle yeahh... about that I still get ReferenceError: guild is not defined
Are you using msg as a param or guild
anyone know if i can send the embed payload on the sendmessage action with JDA?
Ok but you need to get the guild object which can be done using msg.guild so
// in play.js
index.play(msg.guild, song)
nvm got it
yep it's currently that index.play(msg.guild, queueConstruct.songs[0]);
Where is the error being thrown from
for some reason it won't join the voice channel so I dunno where to even start anymore
holy fucking crap
even the error is getting an error
what monstrosity is this
Hello I made a command to be able to send random images with a random image link and unfortunately the code does not work
I do not know how to see that I know nothing in development
then learn the language.
Discord.js
I said learn the language
Image api isnt that hard
As long as you use the right one (eg, mine for anime/nekos) you will be fine
I tried and I can not do it
Then keep trying
We dont know the api you are using to draw the image
Or any errors
So we can't help you
I know people have been havin gprobs with discord authentication and express so i wrote a quick boilerplate example using passport to handle discord auth https://github.com/GagePielsticker/Node-Web-Application-Base
question: if I update Heroku server via Git am I exposing my token?
(git repository)
Only if the repo is public
Heroku's repositories are private
maybe use config vars on heroku just to be safe?
@hollow saddle ok so it works. thanks! only problem is that it won't queue another song and whenever I tried to command play another song, the bot disconnects
ReferenceError: songInfo is not defined
Define songInfo
What you are trying to do is await.title?
more like something like this msg.channel.send(${song.title} added to queue.);
msg.channel.send(`${song.title} added to queue.`); *
@swift topaz then do directly songInfo.title
@wheat jolt i still get it ReferenceError: songInfo is not defined
bot.on('message', async msg =>{
if(msg.author.bot) return undefined;
if(!msg.content.startsWith(PREFIX)) return undefined;
const args = msg.content.split(' ')
const serverQueue = queue.get(msg.guild.id);
if(msg.content.startsWith(`${PREFIX}play`))
{
const voiceChannel = msg.member.voiceChannel;
if(!voiceChannel) return msg.channel.send(`not vc`);
const songInfo = await ytdl.getInfo(args[1]);
const song = {
title: songInfo.title,
url: songInfo.video_url
};
if(!serverQueue) {
const queueConstruct = {
textChannel: msg.channel,
voiceChannel: voiceChannel,
connection: null,
songs: [],
volume: 5,
playing: true
};
queue.set(msg.guild.id, queueConstruct);
queueConstruct.songs.push(song);
try {
var connection = await voiceChannel.join();
queueConstruct.connection = connection;
play(msg.guild, queueConstruct.songs[0]);
} catch (error) {
console.error(error);
queue.delete(msg.guild.id);
return msg.channel.send(`${error}`);
}
} else {
serverQueue.songs.push(song);
console.log(serverQueue.songs);
msg.channel.send(`${songInfo.title} added to queue.`);
}
return;
}``` and...
function play(guild, song){
const serverQueue = queue.get(guild.id);
if(!song){
serverQueue.voiceChannel.leave();
queue.delete(guild.id);
return;
}
console.log(serverQueue.songs);
const dispatcher = connection.playStream(ytdl(song.url, {filter : 'audioonly'}))
.on('end', () => {
console.log('Song ended');
serverQueue.songs.shift();
play(guild, serverQueue.songs[0])
})
.on('error', error =>{
console.error(error);
});
dispatcher.setVolumeLogarithmic(5 /5);
msg.channel.send(` (Now playing: ${songInfo.title}!)`);
}```
@wheat jolt there is more info provided than that. Look at the line which the error occurred
From looking at your code I can already see which line it is
msg.channel.send(` (Now playing: ${songInfo.title}!)`);
Nearly the last line
Oh lmao sorry for the wrong ping Alex
any insights what's wrong with that part?
You defined songInfo outside of the function, and then didn't re-defined it in your function
before if(msg.content.startsWith(`${PREFIX}play`)) you need to put: let songInfo and change change const songInfo = await ytdl.getInfo(args[1]); to songInfo = await ytdl.getInfo(args[1])
You did push it to your song array as song.title
so use song.title instead of songInfo.title
when I did both of your changes, the bot won't even join the voice channel anymore
what
my other problem that I luckily saw was, I had 2 play functions
one inside the bot.on, one outside
I removed the one inside the bot.on
then retained the one outside
I guess that's what caused the bot to not run
yeah nope
what I said was stupid
your play function contains this http://owo.sh/61FgXJk.png
msg.channel.send((Now playing: ${song.title}!));
I changed it now
I don't know where's the incorrect part anymore
nvm it works now
@swift topaz send the error
How do I solve the problem that when my bot is playing music and I get kicked out of the call it happens that I have to relinquish it as I solve it?
it's working as intended now actually. all I'm debugging right now is it won't play the next song in the queue @earnest phoenix
for the reason that no command works after i do that
@swift topaz Okay didn't see the message after.
Send code.
Can someone help me?
@earnest phoenix I don't understand what you're asking
const ytdl = require('ytdl-core')
const index = require('../index.js')
module.exports.run = async (bot, msg, args, queue, serverQueue) => {
const voiceChannel = msg.member.voiceChannel;
if(!voiceChannel) return msg.channel.send(`not vc`);
const songInfo = await ytdl.getInfo(args[0]);
const song = {
title: songInfo.title,
url: songInfo.video_url
};
if(!serverQueue) {
const queueConstruct = {
textChannel: msg.channel,
voiceChannel: voiceChannel,
connection: null,
songs: [],
volume: 5,
playing: true
};
queue.set(msg.guild.id, queueConstruct);
queueConstruct.songs.push(song);
try {
var connection = await voiceChannel.join();
queueConstruct.connection = connection;
index.play(msg, msg.guild, queueConstruct.songs[0]);
} catch (error) {
console.error(error);
queue.delete(msg.guild.id);
return msg.channel.send(`${error}`);
}
} else {
serverQueue.songs.push(song);
console.log(serverQueue.songs);
msg.channel.send(`${song.title} added to queue.`);
}
return;
//current problem: won't play the next song
}
module.exports.config = {
command: 'play23'
} ```
filename: play.js
function play(msg, guild, song){
const serverQueue = queue.get(guild.id);
if(!song){
serverQueue.voiceChannel.leave();
queue.delete(guild.id);
return;
}
console.log(serverQueue.songs);
const dispatcher = serverQueue.connection.playStream(ytdl(song.url))
.on('end', () => {
console.log('song ended');
serverQueue.songs.shift();
play(msg, guild, serverQueue.songs[0]);
})
.on('error', () => {
console.error(error);
});
dispatcher.setVolumeLogarithmic(5 / 5);
msg.channel.send(`(Now playing: ${song.title}!)`);
}
this is inside my index.js
like I have a music command later I put a song when I kick the call bot without the command to leave the api it doesn't work and I have to resign it like he doesn't give more command
Can you use proper grammar
Where is queue defined the function?
where are you calling play?
I call it inside the play.js
Okay i see, play takes the 3 params
yes
here, it adds the second music to the queue, and states that it's playing it, but it doesn't have sound
hello guys i need help
how the bot can read a msg in DM
i made my own bot but i don't know the location of the DM how it calls
i know that general chat in sublime called message.channel but i don't know the DM what called
it's either it has no sound or is not playing
but there is green outline around my bot
@robust quiver DM's are treated like channels as well
But the channel type is DM. Check the docs of the library you're using for channel type
[client].on("message", async message => {
if(message.channel.type === "dm"){
//code
}
})
message.channel ??? @pale marsh
yep there isn't any sounds is the problem, cuz in my console log, it said that the song has ended
Yes
okey thanks
oh it works now @earnest phoenix
for some reason, changing setVolumeLogarithmic to setVolume fixed it
I still am confused with what setVolumeLogarithmic does
@earnest phoenix hey how can i set awaitmessage from dm
?
@swift topaz So it was playing just no volume ?
yes it is
@earnest phoenix like i wanna make a ban command that the bot get confirmation from server owner in dm and this is where i stoped
await bot.users.get(serverowner).send(`<@${message.author.id}> want to ban <@${target}>.\nDo you accept this?\`\`(y/n)\`\``);
message.channel.send(`Waiting for confirmation from the server owner (<@${serverowner}>).`);
const msgs = await .awaitMessages(res => res.author.id === serverowner, {
max: 1,
time: 86400000
});
Um...
i was blocked
?
why do you want the server owner to accept?
like most bots allows people who is admins to use ban
or ban members
its only for me for my server i don't wanna anyone to get banned only when i confirm that
@earnest phoenix
msgs = await ?.awaitmessages....
Hold up
What's the point of trusting admins with BAN_MEMBERS perms if they need to go through you
@gray epoch I don't know exactly how but maybe
let owner = client.users.get('ownerid');
owner.createDM().then(async dm => {
console.log(dm)
dm.send('Hey')
}).catch(err => console.log(err))
If it's a message, you could just do message.guild.owner.send("Do u want to ban x?")
👍
Uhh
why make the .then() function async if ur not using async/await @earnest phoenix
awaitMessages()
oh ok
as a general question to anyone who has a multilingual bot
how do you actually determine use x language on x server
or is it a manual (in bots native language) first step in order to set it up for the server owner
You have to code it yourself.
People probably store the data inside a database with the guild id that has a chosen language.
i mean know how to make it
but whats the onboard method normally look like is more the issue
internationalization
basically make a dir full of json files that translate each string, and in your code you would use something like
translate(StringNameHere, guild/user language)
i know how to make it thats not the issue ive done it plenty before for web sites
@valid frigate question is how do they set it up
like how can you tell a server owner change the language to german if your bot is in english and they dont know it
hence whats the onboarding normally look like
make the help command respond to help in multiple languages, and at the bottom maybe put in every language you provide "to change bot language, type lang something
since a lot of people type help first
so have the word "help" in each language and go from that?
makes sense thanks
seems a really clean way of onboarding
gl 
internalisation usually isnt that bad done it plenty
normally people have a request language tag though in web
you could also default to the guild region @shy rose
voice regions aren't country specific
they are
they're located in a country
yes
however they don't define which language the guild will use
i hope you're aware a region has multiple countries which have their own language
imagine being in the uk and having your bot speak german
@earnest phoenix , no, it doesn't
what you're thinking about is all client, the server doesn't do anything, dragon
the method of checking the language in channel names is very unreliable
tldr don't automatically switch the language for your bot
i went over this, you can't use regions to set the language automatically
that ^
or set default to english and note it can be changed
if they dont speak the language then they wouldnt understand its saying set the language and discard it as some welcome message
also choosing a channel to send that in is a whole nother problem in it self
think the Multilanguage help command as suggested above is the most seemless way in
if they're on an english page with a bot description that's in english, they're aware the bot is in english when they invite it
ergo they can read comprehensible english
chrome auto translate pages
or just being sent the direct invite link by a friend
the user is the fault for most issues tbh
like unticking all the permissions you ask for then instantly complaining it cant do the features listed
Np.
db.fetch('..').then(data => //do somethin');
async function run(){
let data = await db.fetch('..');
}```
Just incase
right, got another oofing problem owo
Alright, Fire away.
code:
const discord = require("discord.js");
const db = require("quick.db");
const fs = require("fs");
module.exports.run = async (client, message, args) => {
const lb = new discord.RichEmbed();
let lb2 = new discord.RichEmbed();
let jso = JSON.parse(fs.readFileSync(__dirname + "/djinfo.json", "utf8"));
let ba;
let djs = jso.djs1;
let djs2 = jso.djs2;
let boked = jso.bookedaway;
lb.setAuthor("This weeks booked slots.");
message.channel.send("**Loading...** This will take some time!");
djs.some(async dj => {
let ba;
boked.some(d => {
if (dj === d) {
ba = " - BA";
} else {
ba = "";
}
});
let bookedtt = await db.fetch(`bookedshit_${dj}`);
let slota;
message.channel.send(bookedtt);
if (bookedtt === "null") {
slota = "0";
} else {
slota = bookedtt;
}
lb.addField(client.users.get(dj).tag + ba, slota);
});
djs2.some(async dj => {
let ba;
boked.some(d => {
if (dj === d) {
ba = " - BA";
} else {
ba = "";
}
});
let bookedtt = await db.fetch(`bookedshit_${dj}`);
let slota;
if (bookedtt === "null") {
slota = "0";
} else {
slota = bookedtt;
}
lb2.addField(client.users.get(dj).tag + ba, slota);
});
await message.channel.send(lb);
await message.channel.send(lb2);
};
output:
its prob smth obvious I am missing
whats it meant to do?
What's the value supposed to be.
there is like 20 ids in an array, its meant to do it for, and meant to be in one embed
the only difference I made is the await on db.fetch
your not waiting for the .some to complete
also why use a .some?
looks like a .forEach is more relevant
*or even a .map then you can Promise.all it
How would I go about doing that then
owo
async/await better
anyone opinions on a good database to use for storage in node.js? needs to be
-Fast
-Able to handle requests from multiple processes at once
-Able to store javascript objects (i dont care if its in JSON or something else as long as it works)
(Ping me if u answer)
mongo
json

@earnest phoenix mongo or rethink are your best options, rethink is great at multiple connections and sharding
does Client.channels.fetch get a channel even if the client never saw/can see that channel
Mongo
low key
id assume that yeah
Not entirely sure though
There is no fetch iirc
if cache is false would it do otherwise
All channels are cached in djs aren't they?
there
there's this https://discord.js.org/#/docs/main/master/class/ChannelStore?scrollTo=fetch which says that cache is an optional param
if i turned this off would it be able to fetch another channel 
Oh huh
havent tested it, but my bot is offline
Mongo is best
is there any way to target the 'Command Prefix' text when it doesn't have a class attached?
@wild tide it does have a class left-container and you can use this to select certain elements
.left-container p:nth-child(1) {
}```
yea, I just figured it out before after a quick google search, thanks for the confirmation!
Anyone ever seen a scenario when a bot doesnt send voice data? (Kotlin/JDA/Lavaplayer) But running the code locally works, just on scaleway it doesnt
Some voice servers can have issues try switching the server region and see if that fixes it
it doesnt seem to be tied to a specific server. I have gotten reports from ~10 different users across regions. Running locally it works. I just switched hosts to scaleway yesterday and it worked up until about an hour ago 
Also not getting datadog updates
This is odd
blocked ports maybe?
Maybe but for about the last 24 hrs it worked fine, but randomly (no reboots or shard disconnects) it seemed to stop wanting to talk to some stuff
I am going to just restart all of the pods
reboot didnt help. Why does this have to happen right when I want to go to sleep
does shardReady emit on every client when a shard becomes ready
smh
or just that client*
Recreating all of the pods in new VPS instances worked. I need to just make a shell script for that...
Is it possible to send an embed as a Discord user without using any code?
no
Its possible with code right? Because I did it once.
yes, but you're not allowed to login with a user token outside of the official client
wait so if you execute the embed sending code in the discord client dev tools its ok? 
maybe you could send json and just make it parse it 
[object Cyber]Today at 9:36 AM
wait so if you execute the embed sending code in the discord client dev tools its ok? :MegaThonk:```
theoretically, yes and no
how does an embed look like in JSON?
like json
you'd be modifying the client which would be breaking another TOS rule, but it would circumvent the rule of the user token @mossy vine
right
lol ok
i dont get why they just wouldnt disallow sending rich embeds for users overall api side instead of allowing you to send one but hunting you down for it
then people will abuse it
embeds are for bots only
and if you disabled it api side that just causes issues for them
wat
you... are aware that in the auth headers you define which type the token is
which is how some endpoints are available for users and not for bots
im saying they should ignore rich embeds or return a 400 if a user token sends a message with a rich embed
@earnest phoenix link previews are the same thing
which is why they were implemented in the first place
link previews arent rich embeds
yeah they are
attempt to add fields with a link preview yourself
thats why the same "embed links" permissions applies to both of them
fields in youtube/steam links are done discord side
some link previews are custom and have stuff like fields and footers
its the same embed system though

despite that, link previews work in a way where the message is first sent, then checked for links, links are checked for opengraph metatags and then a MESSAGE_UPDATE is sent saying that the message has proper link preview
which means it's being done server side
maybe theyre keeping it open for future implementation
or they just don't want servers to waste resources on logic that trivial
bruh when you have 11 million concurrent users thats resourceful
like if you can remove that condition it probably saves at least a little
that's like saying the bulk delete endpoint is heavy because it has a check to see whether the token is a user one
it's a bad point for an argument
despite that, even if it wasted resources, they would be saving database space
so it would pay off
ohh
i guess my counter point would be that that's a bot facing endpoint which probably has way less concurrent clients
hey im having a thought block on how to do a user mute for X amount of time
im using .NET and right now you can mute users in text channels but you have to unmute them
how would you setup a timed mute. I dont really want to call a database every second to see if a user needs to be unmuted
mute, offload a Task.Delay to another thread, pass an unmute method to ContinueWith on Task.Delay
e.g
public async Task Mute()
{
//your stuff here
_ = Task.Delay(ms).ContinueWith(_ => { your unmute stuff here});
}
so what I'd mute the user then call another async Task that has a delay of the required amount and once the delay is up it calls the unmute function
whats the continueWith for though
isn't it self explanatory
can i not just stick the unmute call underneath
well, no
that isn't linq
the task.delay above is being offloaded into another thread, meaning it won't block the method and hang it, instead it will return
the task.delay will be queued in another thread, ContinueWith is telling it what to do after the delay is done
which? Task.Delay? you shouldn't
as in if I were to call that Mute function
you can await that
oh i thought it would block it
sorry for all the questions just one more thing
_ = Task.Delay(ms).ContinueWith(_ => { your unmute stuff here});
why do you set it equal to an underscore
well why do you set it to any variable for that matter
it's a discard, it's telling visual studio not to complain about it not being awaited in this case
ah so thats why i can await the function
yup
Which API is best for YouTube video notification
youtube api
I think YouTube API do not have notification think
google's official yt data api does have push notifications
I think he means API wrapper maybe?
isnt it the same fucked up notification system users have access to?
wouldnt it be better to just parse the channels page for new content every x minutes
probably
Most likely
google is very dumb when it comes to realtime
multiple people have called them out for using bad methods on twatter
it's not a discord webhook
your vps will act like a server which receives webhook requests, you can then pipe those through your bot
^
It's the only way you can actually get the data
Unless you wanna request the data yourself and stuff which would be very inefficient
so im experimenting with fs.watch() a bit, and when i modify a file the callback fires 4 times (rename, change, rename, rename) and doesnt react to anything after that
does anyone know why that could be happening?
oh wait, i might be doing it completely wrong
nope
everything still fires only once
watch('server.js', (eventType, filename) => {
console.log(eventType)
if(eventType === 'change') {
console.log('shit changed')
}
}).on('change', (eventType, filename) => {
console.log('shit changed')
})
it logs twice
but nothing afterwards
On Linux and macOS systems, fs.watch() resolves the path to an inode and watches the inode. If the watched path is deleted and recreated, it is assigned a new inode. The watch will emit an event for the delete but will continue watching the original inode. Events for the new inode will not be emitted. This is expected behavior.
are you modifying it locally or via ssh?
locally with vim
then idk
i guess ill just trying using https://npmjs.com/package/node-watch
perhaps that will help
yeah, node-watch works flawlessly
const watch = require('node-watch')
watch('server.js', (evt, name) => {
if(evt === 'update') {
console.log('shit changed uwu')
}
})
??/?/
https://vinniehat.is-inside.me/OrrnDEl7.jpg Someone has been very chatty in this server lul
Eris-sharder
@abstract crow me
@small sky what did you put in the owners field?
@unique nimbus You have always been at the top of my DB lol
This time it was @south moon lol
I happened to be fooling around with an API with Express.JS and I just saw how many points lol
nice
idk how to make a level up system in python so i never thought of making levels
except maybe levels by usage
I mean for me, I just divide the level by the xp
needed*
I mean XP divided by XP needed
So like if I have 1k I divide it by 500xp(Since that it my level up xp) and I get level 2
yes
Hi,
what is the best solution, if you have lots of statistical server data in your database (that is read from and written to all the time). but have your bots running on different vps?
currently i use mysql on one vps that all shards connect to. But with more guilds added i need a distributed solution. Every shard only needs to hold/manipulate the respective rows for its assigned servers.
Id guess this problem is kinda common, how do people go about this?
How could I have the bot retrieve the message URL of a command?
Does anybody know how to make a web dashbaord? If so, please DM me some form of proof that you know what you're doing.
I am paying for somebody to start off a web dashboard on my project, you will be given credit on the bot along with PayPal payment.
@viral spade probably setup a handler on that server which all shards connect to, that manages what data is written
@copper crystal https://discordapp.com/<guildID>/<channelID>/<messageID>
@tight heath this way the database does not scale with the shards, but will soon be the bottleneck. I am asking for a solution that reduces strain on the database.
The naive approach would be what you said, but using the remote database only as backup and loading from it only at the start of each bot.
I mean my naive approach works for storing a shitload of tracks within Groovy
i am making a write for every message anyone sends
which means you need to think about hundreds to thousands of writes per second
boi we have over a million servers and need to store every track 
also that's rather your optimization
why not cache some and then send in bulk
The naive approach would be what you said, but using the remote database only as backup and loading from it only at the start of each bot. thats caching
I'm not saying cache the whole db
but let's say cache all messages in a minute and then write them to db
not the whole db, but all records accociated with all servers that bot has
instead of writing them each 10ms
i also need to access the information as often
so only dumping is no use. i need to have all the info accessible in the bot
what are you actually doing
maybe explaining that helps solve the problem more efficiently
sure. i do statistics, fe. count messages per day per channel per user
mysql is designed to handle millions of queries per day, i dont think it will reach a bottle neck that easily, but yes the best thing you can do is add an in-memory cache layer
That's not what I mean @tight heath
When someone uses a command, I want the bot to fetch the link of the command invocation.
like !get http://somewebsite?
then what I said?
the link or the contents of the link?
the structure is https://discordapp.com<guildID>/<channelID>/<messageID>
you can get the rest
then yeah what he said lol
I don't think you get what I mean.
and you get the link to the message
I want the bot to fetch the link.
there is no fetching
that link is nowhere stored on Discord
you have to create it
using those three IDs
omg
@quartz kindle
I also thought so but i am not sure because my bot really does a lot of queries. when you say millions per day i am not sure if thats enough in longterm.
-
so whenever a message is sent by anyone in any channel, it does a read to get the old score, an increment to the databse value, then a hell lot of joins to calculate old and new level (to see if theres a levelup) . this means a dozen reads and a write for each message. For lets say 100 messages per sec, this would be over 8 million messeages per day. this would be easily 100 million reads/writes per day.
-
Part of the bot is calculating users minutes in voicechannels. For this i rotate through all voicechannels with users, and tick them up a minute, and do this once per minute. This rotation, once per minute, puts my harddrive on very high usage for 20 seconds when using my 3k servers. This wont work with more than 10k servers (i can postpone the problem by incrasing the interval but still..).
I want the bot to automatically create it then
the link is obviously going to be different each time
yes so you use the different IDs each time
it's not an invite link boi
it's not random
https://discordapp.com/channels/264445053596991498/272764566411149314/603593857128726558
guild: 264445053596991498
channel: 272764566411149314
message: 603593857128726558
https://discordapp.com/channels/264445053596991498/272764566411149314/603593861582815232
guild: 264445053596991498
channel: 272764566411149314
message: 603593861582815232
THE BOT SHOULD AUTOMATICALLY RETURN THE LINK
@viral spade keep a copy of each users level in memory, and increment it locally, and only push to db once a while. if you do it every 30 seconds for example, the most it can happen is you lose 30 seconds of data in case of crash
it does automatically
boi I can write that command in 20s
you're just a big mumbodumbo
msg.channel.send(`https://discordapp.com/channels/${msg.guild.id}/${msg.channel.id}/${msg.id}`)
@viral spade as for incrementing minutes, i dont see how something like that could hang your drive for 20 seconds. do the same thing, keep a copy of the minutes in memory, and only push them to db once a while
yeetn'fleet
that makes more sense, thank you
^
Every new bot developer is using Discord.js these days
js is ez






