#development
1 messages · Page 800 of 1
well, people here will help you, provided you've made an effort at it first
Throwback to help vampires
I noticed it from my first message
@slender thistle what
Nothing in particular, just remembering people who would straight up say "gice code for X" in here 
yea..
anyone here using contabo?
I changed the password for my VPS using my control panel, and it says it would take at most 10 minutes. I've been waiting for like an hour, should I contact their customer support? Sshing into it doesn't work
@me if anyone has gone through this process before please!
Why would you use the control panel to change your password?
just ... use... passwd
Exactly.
or ssh keys?
No, ssh keys are pretty bad.
more secure than a password
Not really.
yes really.
unless your password hapepens to be A&^I^&BYTya6u47i8w73 uyb4 t5874w8o esir 3243e7uruod
Considering it took less than 30 seconds for my friend to get in without one.
My passwords are always like that just longer.
Okay, I'm sticking to a password as this far I've not had any account hacks.
SSH I have.
if someone got your ssh key in '30 seconds' they had the private key.
Nope.
then something else happened.
Literally nothing else happened. I gave them the IP they signed in using "ssh", without private key.
then something wasnt set up properly.
thats like me walking into your house cuz you left the door unlocked and you claiming i picked the lock
The OOPs just concern the channels?
wha?
no
oop is a type of programming
so
for instance
you have classes and instances
a class would be something like People
you and me are People
People is the class
and you and me would be instances of that class
discord.Guild is also a class
its a type of thing
@client.command()
async def p_channel(ctx):
channel = await discord.Guild.create_text_channel('test')
await ctx.message.delete()
That's actually a pretty decent explanation ^^
Ok, but what I don't understand what I can do everything except create channels
discord.Guild is a class, and you need an instance of that class
aka ctx.guild
on another note, i didnt realize the client architecture was still a thing
hey um
@hoary elm
What's up?
good status
Lol I know 🤦🏻♂️
;p
@dull terrace thanks
Lol
@earnest phoenix I realized I forgot a = after I set it was just to lazy to fix it 😂
xD
I had not seen my error, thank you.
It seems more coherent to me
Anyway, I don't understand how adding attributes will help me create a channel x)
but it may be worth looking into how cogs work
basically change your discord.Guild. to ctx.guild.
yes
It work
No need to tell me "will learn the oop ..." for just a ctx error
Anyway thank you, I learn from my most basic mistakes
@hoary elm I'm inspired by you, look at my status
😂😂👌
I could go on with my OOP and how not learning it while using an OOP language could cause you more shit than good deeds but eh
Some people just prefer trial and error over the old fashioned read and learn method
I just want a bot that works and is effective, I don't ask to code with oop, just a SIMPLE thing
I mean I agree with you you should learn before you go trying to do it as you should with any coding language, API ect. But some people like learning the hard way
You are agree with me ?
No Shivaco
¯_(ツ)_/¯
Ah ok x)
Not that I honestly care by now
Lol fair enough
Anyway, 3/4 of the people I talked to about my concerns, my just said "go learn the oop"
Because the best way to learn what you need to do is via their docs
what doc?
Docs, Guides, Tutorials. Whatever they offer
@grizzled raven didn't notice that, thx
Anyway, I don't plan to use oop to code bots for now x)
Lol
So next time I hope that when I ask a question they will attack me with the phrase "go learn oop ..."
And I thank the people who will do it, the others looked at my status
what the heck did i just read
I'm not sure this conversation has any more purpose
you cant use an object oriented programming language without knowing how object oriented programming works.
Je préfère en Français perso
Yeah you need to know OOP, which is why you've been told to go learn it
Donc je disais, "Et je remercie tout ceux qui le feront, les autres regarder mon status"
Tes français toi
your status still makes no sense
Why are we still at it tbh
idk xD
It's their problem from here on
until they ask for help again
Ouais, ça se passe souvent comme sa quand je demande de l'aide
Yeah, it often happens like its when i come
i feel like your english was better than google translate's ngl
thx
Je suis français à la base, je sais que l'anglais est une langue international mais c'est plus simple quand on né dans un pays anglophone
Bref, la discussion devient hors sujet
?
@client.event
async def on_message(message):
log = client.get_channel(682224555552538639)
if "n!".casefold() in message.content:
await client.process_commands(message)
if "https://tenor.com/view/".casefold() in message.content or "https://media.tenor.com/images/".casefold() in message.content or "https://www.gstatic.com/allo/stickers/".casefold() in message.content:
pass
general = client.get_channel(618053458972377098)
bot_command = client.get_channel(682251992260804608)
if message.channel == general or message.channel == bot_command:
if "https://".casefold() in message.content:
embed = discord.Embed(
colour = discord.Colour.red()
)
embed.set_author(name="Lien bloqué")
embed.add_field(name="Membre", value=f"{message.author.mention}", inline=True)
embed.add_field(name="Action", value="a envoyé un lien dans", inline=True)
embed.add_field(name="Salon", value=f"{message.channel.mention}", inline=True)
embed.add_field(name="Message", value=f"{message.content}", inline=True)
await message.delete()
await log.send(embed=embed)
For me is this x)
o.k.
im just waiting till you see all the object oriented programming in that code
your eyes hurt ?
yes but not cuz "oop" but cuz the client architecture
cogs are so much easier to maintain IMO
https://github.com/crazygmr101/AnsuraBot/blob/master/main.py
https://github.com/crazygmr101/AnsuraBot/blob/master/cogs/minecraft.py
what is it ?
my bot. it uses cogs which are basically modules
each cog can be enabled/disabled individually
So I have to wait when I upload my bot?
@dull terrace That python? I never liked it so I never was serious about learning it
I can read python though
Yes, but python that hurts the eyes
how does it hurt the eyes?
because it's easy to maintain?
because it makes use of the lilbrary's full feature set?
o
you speak of my code ?
you were replying to everyos
nvm
no i thoght you were replying to me saying cogs were better
i see now that you were replying to everyos
sorrrryy
I answered EveryOS ^^
@earnest phoenix Tbh most languages I think are easy to maintain
The primary exception is assembly
Though JS can quite easily become spaghetti when not organized well
How would you add arguments because the guide wasn't very specific with that.
in the await ctx.guild.create_voice_channel() , where I place the user_limit ? x)
await ctx.guild.create_voice_channel(**user_limit()) ?
I am already there
** in python means keyword args
yes
so iirc, it should be await ctx.guild.create_voice_channel("channel_name", user_limit=89327438952787348)
I use windows 10 btw, so I just add !mycommand arg1 arg2 arg3 into the bot's js file and add the arguments?
@pine bear args for what?
i have no clue catra
commands with arguments
why you use an id for user_limit ?
Ah ok
For commands with arguments the command itself is args[0] everything after that is 1 2 3 ect
So example s!help help would be args[0]
@pine bear what are you trying to set up?
Oh I see, I add the args and add the command in the args,
The bot itself or the commands?
Args usually go in the commands so for example say I wanted to make a Kick command it would go something like
if (message.content.startsWith("$kick")) {
var member = message.mentions.members.first();
var reason = args[1]
member.kick()
message.channel.send(`<@${user}> has been kicked for ${reason}`)
That is also a example of how to use args and I'm not guaranteeing that it's gonna work if you copy paste that
Oh I see, I not going to copy that
Oh thx
python: give me indents or give me errors
Lol
hopefully someone knows the reference
it's probably for the sake of time, as in using that small snippet as an example.
if (g) {
dothis();
also_do_this();
}
else {
if (a==4)
h();
}
the fact that is valid
makes me wanna commit alt+f4
Lol
that makes me want to commit sudo rm -rf / --no-preserve-root (don't run it)
😂😂😂☠️☠️☠️
This may be an off-topic thing but how do you make text colored like that?
Lol
The best is asyncio.sleep() and not time.sleep() ?
Ok thx
client.on("message", (message) => {
if (!message.content.startsWith(prefix.config.prefix) || message.author.bot) return;
const args = message.content.slice(prefix.lenth).split(' ');
const command = args.shift().toLowerCase();
else if (command === 'args-info') {
if (!args.length) {
return message.channel.send(`You didn't provide any arguments, ${message.author}!`);
}
message.channel.send(`Command name: ${command}\nArguments: ${args}`);
}
});
This is what I can find with the guide you gave me, I don't think it's right.
from my very limited knowledge of js, that looks right
yea
!prefix arg-info a a aa a
will print
Command name: arg-info
Args: a a aa a
But it ain't, the else command doesn't have a statement.
???
cause you added ; after the other statement
Oh rofl I forgot about that!
so restart it xD
How do I keep it online?
keep it running
keep it running unsure what you mean by that.
and just dont close the terminal
The terminal didn't close, strange.
did it stop cuz of an error?
Now there is an error.
im not sure how js works with blocking, but ik in python if you do something blocking, the bot can stop responding to the point where it goes offlien
Ok, understood.
i mean when the bot grows you cant run it in vs code all the time
mine runs in a terminal, using a utility called tmux to send it to the background
Ok,
i only restart it on major updates, my tesing is done with a bot with a separate token in a separate server
sorta like how rythm and rythm canary work
Oh. My bot will be limited to only my server so I don't have to worry about that too much.
ohh
I don't plan on that because this PC just sucks and doesn't have enough RAM for a bot that is in many servers.
You have to pay?
if you dont host it yourself, ye
but if you run the code on your own machine, no
So it's free, if you host the code on your machine?
Np then!
i only sent that link cuz you said about how your pc wasnt the greatest
and using a vps is a cheap way to keep it online all the time and scale as it grows
Which link?
What those links says you have to pay.
those are for machines you can run your bot on
when/if your bot grows to the point you cant run it on your own
but i just run mine on a pc
that constantly on
So, uhh. How do I get the software to keep my bot online?
well you can run it straight in a terminal
install node, and just run the command in.. command prompt should work
Np then.
if you give me the exact command you use to start your bot, i can write you little batch file that'll keep it running
wait
no
cuz
UGH
i forgot
batch files dont hold execution until a program is done
I guess I just downloaded pm2
Mhm
Thx Command prompt
is this the correct one @dusky marsh
It says this
- pm2@4.2.3
added 207 packages from 202 contributors in 72.967s
Well, I guess because it says pm2.
yep, also make sure you install it globally
ye
Yes!
Now imma go actually try to use it
So I got it down but what file am I suppose to use?
The main js file?
Because I tried that but it just said error when I ran it on command prompt.
[PM2][ERROR] Script not found: C:\Users\name\index.js
Here index.js on C:\Users\name?
I don't want my real name out there so I replaced it it 'name'
Are you sure, index.js on C:\Users\somename?
try pm2 start ./index.js
discord.js
sometimes gives an error. How can I fix it? I can’t find anything on the Internet.
/app/node_modules/opusscript/build/opusscript_native_wasm.js:8
ok can someone help me with this error:
AttributeError: 'Bot' object has no attribute 'send_message'
i have 3 variables
anyone?
Hi
The dpy server*
You're using the old, 0.16.x (async branch) version of discord.py, or appear to be trying to use methods from the async branch.
The rewrite branch (1.x.x) of discord.py was pushed to PyPi and made the master branch of discord.py on april 8th.
It is a massive breaking change
Methods such as client.send_message now have an entirely different syntax and style.
If you want support here, it is required that you migrate to the new version of discord.py.
See the migrating guide for instructions on how to do so.
https://discordpy.readthedocs.io/en/latest/migrating.html
The async branch, 0.16.x, is no longer supported here.
Doesn't matter
ok can someone help me with this error:
AttributeError: 'Bot' object has no attribute 'send_message'
This error means that you're trying to use async methods
well i tried message.send() but it can only hold 1-2 variables
i also use on_ready() i forgot to mention that
@stable horizon ^
😧
plz tell me what to do so i can sleep
@earnest phoenix code?
Tbh idek how to use @client
ok
I just use @bot and cogs
Make sure you actually have rewrite installed tho
Same shit just different variable names
await client.send_message(channel, '{} has leveled up to level {}'.format(user.mention, lvl_end))
Nope.
Change that to await channel.send(message)
well i tried
message.send()but it can only hold 1-2 variables
@earnest phoenix
Remove the channel argument
ok ima try it
error:
AttributeError: module 'discord.message' has no attribute 'channel'
Show me your code
await client.send_message(channel, '{} has leveled up to level {}'.format(user.mention, lvl_end))
@earnest phoenix
Send the whole function?
await message.channel.send(channel, '{} has leveled up to level {}'.format(user.mention, lvl_end))
Full code is needed
why?
It has no context.
@client.event
async def on_member_join(member, guild):
with open('users.json', 'r') as f:
users = json.load(f)
await update_data(users, member)
with open('users.json', 'w') as f:
users = json.dump(users, f)
@client.event
async def on_message(message):
with open('users.json', 'r') as f:
users = json.load(f)
await update_data(users, message.author)
await add_experience(users, message.author, 5)
await level_up(users, message.author, message.channel)
with open('users.json', 'w') as f:
users = json.dump(users, f)
async def update_data(users, user):
if not user.id in users:
users[user.id] = {}
users[user.id]['experience'] = 0
users[user.id]['level'] = 0
async def add_experience(users, user, exp):
users[user.id]['experience'] += exp
async def level_up(users, user, channel):
experience = users[user.id]['experience']
lvl_start = users[user.id]['level']
lvl_end = int(experience ** (1/4))
if lvl_start < lvl_end:
await message.channel.send(channel, '{} has leveled up to level {}'.format(user.mention, lvl_end))
users[user.id]['level'] = lvl_end
await client.process_commands(message)
Ok
I see the issue
You don't b pass a message to levelup
Just change it to
channel.send(jdjdjdjdhdhfhr)
?
That line. Change it to
await channel.send("message")
umm 1 sec
error:
Also send new code
After error
TypeError: send() takes from 1 to 2 positional arguments but 3 more given
Send the new code too
@client.event
async def on_member_join(member, guild):
with open('users.json', 'r') as f:
users = json.load(f)
await update_data(users, member)
with open('users.json', 'w') as f:
users = json.dump(users, f)
@client.event
async def on_message(message):
with open('users.json', 'r') as f:
users = json.load(f)
await update_data(users, message.author)
await add_experience(users, message.author, 5)
await level_up(users, message.author, message.channel)
with open('users.json', 'w') as f:
users = json.dump(users, f)
async def update_data(users, user):
if not user.id in users:
users[user.id] = {}
users[user.id]['experience'] = 0
users[user.id]['level'] = 0
async def add_experience(users, user, exp):
users[user.id]['experience'] += exp
async def level_up(users, user, channel):
experience = users[user.id]['experience']
lvl_start = users[user.id]['level']
lvl_end = int(experience ** (1/4))
if lvl_start < lvl_end:
await channel.send(channel, '{} has leveled up to level {}'.format(user.mention, lvl_end))
users[user.id]['level'] = lvl_end
await client.process_commands(message)
Ok.
Change that line to EXACTLY what I said
i just copied edited and pasted
await channel.send("message")
why?
NOT await channel.send(channel, message)
Because that's how the new model works.
so channel.send? no await?
Omg.
await channel.send("message")
@earnest phoenix
That
NOT await channel.send(channel, message)
@earnest phoenix
Not this
so it would be like await channel.send('{} has leveled up to level {}'.format(user.mention, lvl_end)))?
Yes.
ooooh
Mhm.
that just spams @WhitePhantom#6367 level up forever
That's cuz your bot is responding to itself.
and there is an error about 'author'
Make the first line of your onmessage be:
if message.author.bot: return
but i have logging
wont that affect the logging?
No. It makes the onmessage function not apply to bots.
ooo
new problem
.. Hm?
now everytime someone sends a message it responds thier level
That's a logic issue.
Probs cuz you call level up on every message.
hmm
i dont know how to fix that
https://github.com/crazygmr101/discbot/blob/master/experience.py
Have a look at that.
It's not the most elegant thing
It was my first discord bot, hard-coded for a server
But the gainxp function might be worth looking at
It's called on every message
Anyway it's 1:30am. Gn :p
ok gn
My bot keeps periodically giving the message " (node:4) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions
2020-02-28T07:43:28.726715+00:00 app[web.1]: at /app/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15
2020-02-28T07:43:28.726716+00:00 app[web.1]: at /app/node_modules/snekfetch/src/index.js:215:21
2020-02-28T07:43:28.726717+00:00 app[web.1]: at runMicrotasks (<anonymous>)
2020-02-28T07:43:28.726717+00:00 app[web.1]: at processTicksAndRejections (internal/process/task_queues.js:97:5)
2020-02-28T07:43:28.726718+00:00 app[web.1]: at emitUnhandledRejectionWarning (internal/process/promises.js:149:15)
2020-02-28T07:43:28.726718+00:00 app[web.1]: at processPromiseRejections (internal/process/promises.js:211:11)
2020-02-28T07:43:28.726719+00:00 app[web.1]: at processTicksAndRejections (internal/process/task_queues.js:98:32)"
Discord API error
Any ideas how to trace this error or what permissions are missing?
I used process to determine the method, which was POST
and the url was /api/v7/channels/681783138531278858/messages
if anyone has any ideas, please let me know!
initially I thought it could be my bot not having permissions to DM someone (after people vote, they get a DM). But I'm not quite sure
@wide ridge that means your bot is missing the send messages permission
just check if your bot has send message person when someone runs a command
Jas anyone got a script for making a bot link to YouTube pls dm me
wat
lol "Script"
aight
im looking into it.
To make snipe command?
Ok
alright so,
@summer torrent i tried a lot
what you want to be doing is is logging deleted messages
I used fs and Map()
then returning the last one
Both failed
what context is this in
I think my code was wrong
fs and map to do what?
To store messages
I tried
may i see the code?
do you get any error
^
I have copied only one code
Showing you
client.snipes = new Discord.Collection();```
module.exports = (client, message) => {
client.snipes.set(message.channel.id, {
content: message.content,
sender: message.author
});
};```
i see.
i would be saying you should use FS to save changes to a JSON file
And the second one is in messageDelete event
you can use a library like selfreloadjson when you need to read it in real time
client.on("messageDelete", (messageDelete) => {
//put the code in here
});```
seeing as you are using nodejs
I replaced it to Discord.Collection() from Map()
you can use the inbuild FS commadns
But both not worked
@lethal stratus tried
i will show you a snippet of some of my old code that interacted with filesystem
Ok
to illistrate how you do it.
const fs = require('fs');
var pre = require('./prefix.json');
fs.writeFile('./prefix.json', JSON.stringify(pre), function (err) {
if (err) return console.log(err);
console.log('writing to ./prefix.json');
});```
so what you do here
is you are defining a file
then you are writing to the file any changes
Here i got a problem.. can't find "./snipe.json" module
are oyu trying my code
modify it to fit yours
Ok
so in your case
const fs = require('fs');
var snipe = require('./snipe.json');
//here, you can do something like snipe.lastMessage = "whatever you want", then you can use the below code to save the changes.
fs.writeFile('./snipe.json', JSON.stringify(snipe), function (err) {
if (err) return console.log(err);
console.log('writing to ./snipe.json');
});```
I tried this..
It looks same as yours
Is there something wrong?
(node:25835) UnhandledPromiseRejectionWarning: Error: Cannot find module './snipe.json'
Got this err
@lethal stratus
../snipe.json
back
Oh
you need to put where the file is actually
because i dont know where your snipe file is
and ./ targets the folder its being executed from
@summer torrent trying it
so you need to change ./snipe.js to wherever it is actually stored
@charred jetty
If I add a command that detect the word kms with no prefix will my bot get mute or someone?
@lethal stratus ik
Ok I am gonna dm a admin now
ok
Do I Dm a mod or admin?
Ask a moderator
Ok
Yes he can get a mute @earnest phoenix
You can ping one mod
If he answer to a Word without prefix
Now
so there is the answer @earnest phoenix
Jump Toat Client.module.exports.message (/app/events/message.js:21:9)4:25 PM
at Client.emit (events.js:194:15)4:25 PM
(node:26088) 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: 1)4:25 PM
(node:26088) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
Yeah, don't have public commands without prefix
This err
ok
show actual error
Yes but you can block the command for only be usable by ur id @earnest phoenix
(node:26088) DeprecationWarning: Collection#find: pass a function instead4:25 PM
Jump To(node:26088) UnhandledPromiseRejectionWarning: SyntaxError: /app/snipe.json: Unexpected end of JSON input4:25 PM
at JSON.parse (<anonymous>)4:25 PM
at Object.Module._extensions..json (internal/modules/cjs/loader.js:720:27)4:25 PM
at Module.load (internal/modules/cjs/loader.js:600:32)4:25 PM
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)4:25 PM
at Function.Module._load (internal/modules/cjs/loader.js:531:3)4:25 PM
at Module.require (internal/modules/cjs/loader.js:637:17)4:25 PM
at require (internal/modules/cjs/helpers.js:22:18)```
U mean this?
The upper err
@charred jetty show snipe.json
ye
It's blank
add {}
thats the issue
Ok
yes
Jump To(node:26088) UnhandledPromiseRejectionWarning: SyntaxError: /app/snipe.json: Unexpected end of JSON input4:25 PM
this is the issue
Can I make the command so you need to ping the bot first and say the word kms?
its because its blank
Can I make the command so you need to ping the bot first and say the word kms?
that makes it a command
so sure
just type {} to json
@earnest phoenix yes you can
Lemme check that Command
just type {} to json
^
Now
...
(node:26394) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '0' of undefined
client.on("messageDelete", (message) => {
if (message.author.bot) return;
var snipes = require("../snipe.json");
snipes[`${message.channel.id}`] = [`${message}`, `${message.author.tag}`];
var fs = require('fs');
var fileName = '../snipe.json';
fs.writeFile(fileName, JSON.stringify(snipes, null, 2), function(error) {
if (error) {
return console.log('oops')
}
});
});```
I think it should write there something
i see the issue
you need to store something in the file, not over the top
var snipes = require("../snipe.json");
snipes[`${message.channel.id}`] = [`${message}`, `${message.author.tag}`];
var snipes = require("../snipe.json");
snipes.snipy[`${message.channel.id}`] = [`${message}`, `${message.author.tag}`];
more like this
but dont forget to define snipy
Ok
wow
var snipes = require("../snipe.json");
var snipy;
snipes.snipy[`${message.channel.id}`] = [`${message}`, `${message.author.tag}`];
know what
Then in the write file?
yes
but i dont know if i can do this, to help you make this work
it may work in the end
but it will be the most crappy slow garbage
because i suck at coding
@pliant gorge
i feel like someone else would be better at heklping
fs.writeFile(fileName, JSON.stringify(snipes, null, 2), function(error) {
if (error) {
return console.log('oops')
}
});
I am talking about the snipes
@modern sable selfbot ^
oh
¯_(ツ)_/¯
banned
lol
anyways
@lethal stratus what will be done to the snipes then?
you may have to get help from someone else because im super tired and as i said, i dont want to teach you my bad coding practices
Lol
Can I make the command so you need to ping the bot first and say the word kms?
I am doing the command now but I can’t figure out who to do it with message.content.includes and it works like @ bot kms but not working if there’s if there’s a word between the ping and the word kms
use isMentioned()
try indexOf
I am customising the code into db
do you need the snipe thing to work through bot restarts/crashes?
do you need it to save ALL messages, or only X latest messages ?
what are your requirments?
It's hard to save multiple deleted messages per users for snipe command ?
Per users or per Channel *
not hard, just takes resources
also you need to consider if you want to save only text, or also embeds and files
and if you want to save them in a database, or if you're ok with losing them if the bot crashes
and also the limit of how many messages per channel do you want to save
Oof embed and files i think we have To download this automaticly and this is really hard for memory if he have multiple files deleted
What do you want @earnest phoenix i have screenshot 
ugh
ok..
Why you want To ping hop?
Him*
testing
.....
lol

const snipy = JSON.parse(fs.readFileSync("./snipe.json", "utf8"));
client.on("messageDelete", (message) => {
if(!snipy[message.channel.id]) snipy[message.channel.id] = {content: `${message.content}`,sender: `${message.author.tag}`};
var fs = require('fs');
var fileName = './snipe.json';
fs.writeFile(fileName, JSON.stringify(snipy), (error) => {
if (error) {
return console.log('oops')
}
});```
@summer torrent
Me?
are there any deno discord libraries yet?
I haven't experience for fs
@summer torrent oh
fs.readFile(fileName, 'utf8', function (err,data) {
if (err) {
return console.log(err);
}
var result = data.replace(/string to be replaced/g, 'replacement');
fs.writeFile(fileName, result, 'utf8', function (err) {
if (err) return console.log(err);
});
});```
I searched on google and this comes
But i don't understand how to use it in my code
@copper cradle snipe command
@charred jetty did you see my messages?
do you need the snipe thing to work through bot restarts/crashes?
do you need it to save ALL messages, or only X latest messages ?
what are your requirments?
also, do you need to save embeds and files or only text?
I saved it in file
But it's not replacing new deleted messages
@quartz kindle and im sorry.. i didn't saw the messages
@quartz kindle i want to save the only X latest deleted message

only the last message on each channel?
or the last message from each user on each channel?
you want to save the deleted message?
because in order to get the deleted message in the first place, the message has to be saved before its deleted
thats the problem with sniping, you need to save the messages before they are deleted
ok, but your method will only work on cached messages
Yes
meaning, if you restart the bot, and someone deletes message, your bot will not see it
it will only see messages sent after the bot starts
Yes
ok, show your current code
const snipy = JSON.parse(fs.readFileSync("./snipe.json", "utf8"));
client.on("messageDelete", (message) => {
if(!snipy[message.channel.id]) snipy[message.channel.id] = {content: `${message.content}`,sender: `${message.author.tag}`};
var fs = require('fs');
var fileName = './snipe.json';
fs.writeFile(fileName, JSON.stringify(snipy), (error) => {
if (error) {
return console.log('oops')
}
});```
Yeah
remove the if
Ok
The if broke all lol
You need the if only in the command
Personnaly just message is okay
just js snipy[message.channel.id] = {content: `${message.content}`,sender: `${message.author.tag}`};
if it doesnt exist, it will be created, it it exists it will be replaced
For the snipe
show snipe command
const fs = require("fs");
let snipy = JSON.parse(fs.readFileSync("./snipe.json", "utf8"));
exports.run = async(client, message, args) => {
let chn = `${message.channel.id}`;
var snipechannel = snipy[chn]; // to call an specific deleted message I guess
if (!snipechannel) {
message.channel.send("What? There are no deleted messages atm");
} else {
const embed = {
"color": 5608903,
"footer": {
"text": `Sniped by: ${message.author.tag}`
},
"fields": [{
"name": `${snipechannel.sender}`,
"value": `${snipechannel.content}`
}]
};
await message.channel.send({
embed
});
fs.writeFile('./snipe.json', JSON.stringify(snipy), (error) => {
if (error) {
return console.log('oops');
}
});
}
}```
this is the problem
the file gets read only once, and then all snipe commands will use the same loaded file, never the updated one
Oh
you should use the same snipy variable you create in your messageDelete event
so you dont need to re-load files
Ok
in your main file, you can do something like client.snipy = JSON.parse(fs.readFileSync())
and then in the snipe command, you use client.snipy to check it
and in the messageDelete event, you use client.snipy[message.channel.id] = {...} and save the JSON.strinfigy(client.snipy)
the readFileSync should only be used once, in the top of your main file, right after you create client
Ok
@quartz kindle is there any way to delete the client.snipy[message.channel.id] ?
Total channel information
delete client.snipy[message.channel.id]
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'iconURL' of null```
what is this
it shows error then also the commands sends the guid icon
show full code
k
var embed = new Discord.RichEmbed()
.setColor("RANDOM")
.setThumbnail(message.guild.iconURL)
.addField(`Server name:`,`** ${message.guild.name}**`, true )
.addField(`Server Id: `,`**${message.guild.id}**`, true )
.addField(`Server Created at:`, `**${message.guild.createdAt}**`)
.addField('You Joined On:',`${message.guild.joinedAt}`)
.addField(`Server owner:`,`**${message.guild.owner.user.username}**`)
.setTimestamp();
if (message.content === `${config.prefix}serverinfo`) {
message.channel.send(embed);
}```
@summer torrent
message.guild is null
@summer torrent wdym it is null?
Are you running this command in DM
no
🤦🏻♂️ why would he use a server info command in DM
fact
even though error shows i am getting output but sometimes the error stops the whole bot
why
@earnest phoenix that's odd actually I have a few private bots with server info commands that use message.guild.iconURL and it works errorless 🤔
Does the server have a picture set?
what?
@earnest phoenix https://www.npmjs.com/package/statuses
That is of course assuming you're reffuring to d.js
🤷🏻♂️ to lazy to make the picture bigger and look
bruh..
did you install it
if i have Hello {1:poo} shouldn't /1:poo/g work to find it regex wise
It works for me, unless you mean something else.
please give me status code
my code is bugged

Which permission corresponds to EMBED_LINKS in the role settings?
Embed Links
what do you mean? is it not the same?
Actually I am not sure my Discord is in another language
bot.user.setStatus("dnd");
console.log(`${bot.user.username} is online`);
let statuses = [
`$help | ${bot.guilds.size} guilds`,
`$help | rasdas`,
`$help | ${bot.users.size} users`
];
setInterval(function() {
let status = statuses[Math.floor(Math.random() * statuses.length)];
bot.user.setActivity(status);
}, 3000);
}); ```

no work
give me error
They just translated it badly
So I am unsure
I guess it's my equivalent of send file 
tried to get a role by id, returned undefined with Error: Request to use token, but token was unavailable to the client.
I'll look into the lib for the error throw
but it acts weird
learn how variable scoping works in JavaScript @earnest phoenix
i have module
sigh
🤦🏻♂️
changing activity in every 3 seconds is API abuse
@hoary elm ?
if I use ksoft.si API using my valid token to request some images, it gives me this (https://prnt.sc/r939ij) error. How can I fix that? Are glitch servers affected by this APi?
Looks like an issue with the website, not you.
tell me what doesn't work
what is up with the low iqsm today
@tight plinth known issue - people are working it out with glitch/cloudflare/whatever
Yeah all g
how do you show what servers the bot is in
i code in discord.js
dm me if u know how
client#guilds
so it will show all servers the bot is in
Why does everyone use glitch?
I has virtually 0 disk space
yes @bitter lark
Why does everyone use glitch?
I has virtually 0 disk space
@slate oyster because it is free
Thats even worse
My phone actually has disk space
But uptime...
I tried glitch via it's cmd
spare laptop ftw
It didn't even get past downloading the gradle files
I mean if you have a reliable data connection it's not too bad an idea if you're tight on money
My uptime is quite decent
Replit tab open on my pc ftw
O.o
Just kidding im using my vps
google cloud gives you free subscription for 1 year
Isn't it like they give you $300 credit
But that requires use of a credit card to sign up
Yeah not everyone has a cc
True that
30 minutes a good amount of time to reset automod configs in your opinions?
1hr
Ok
are u using a json database?
The current version stores all data in one json file
The rewrite, which will be what I submit, will store across multiple files/folders in json.
Why?
No
I said that earlier
Glitch ran out of disk space when downloading gradle files
gradle? on glitch?
Yea
through terminal
didnt knew glitch compiled java
.
lemme show you
why don't you guys use sqlite tho?
I would use firebase
personal preference ig
If I did use an actual db
although firebase isn't completely free
but kinda hard
and sqlite is fast af
imagine using google drive
geez
imagine using multiple lines
what kind of library are you getting with gradle lol
Discord4J
same
I use jda
I like to stick to the basics
Which version of java does he use? ^^^^
1.8.0_241
Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
Java HotSpot(TM) Client VM (build 25.241-b07, mixed mode)```
It says it was compiled in a different version
a newer version
which version
then it may have been compiled in java 9+
hold on
java version "13.0.2" 2020-01-14
Java(TM) SE Runtime Environment (build 13.0.2+8)
Java HotSpot(TM) 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing)```
you have java 13
@earnest phoenix you need java 13.0.2
ew
then it will work
Can i seek ms excel related help here ?
no
no
hey guys can i get help, just went to work on my bot and its coming up with this error when i try to run it ?
internal/modules/cjs/loader.js:800
throw err;
^
Error: Cannot find module 'C:\Users\Jason'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
at Function.Module._load (internal/modules/cjs/loader.js:690:27)
at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
at internal/main/run_main_module.js:17:11 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}```
thats Java SE
that being said, i am certified in excel @toxic seal so you're welcome to dm me
Please direct me to appropriate server if possible. I'm lost
@pure gust can you show the code main code of your bot that causes the error?
@earnest phoenix thats so kind of you
not even the same type? wow
@crimson vapor idk where it would be, ill remove the stuff i added to see if that will change but i doubt it
ok
yes @earnest phoenix
internal/modules/cjs/loader.js:800
throw err;
^
Error: Cannot find module 'C:\Users\Jason'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
at Function.Module._load (internal/modules/cjs/loader.js:690:27)
at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
at internal/main/run_main_module.js:17:11 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}```
no lke
Maybe i need to update something idk?
the code
not the error ;p
and it looks like its not finding the code. are you running the node . command in the directory with the code?
That would cause it
throw err;
^
Error: Cannot find module '/mnt/c/Users/<user name>'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
at Function.Module._load (internal/modules/cjs/loader.js:862:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}``` is what I got
ive always used node . in the terminal to run it?
i can send code if u want
but gimme am min so i can take out private info
no, just make sure you are in the right directory @pure gust
terminal
wait its not linux lmao
wdym the right directory? like the code has always been in the same place lmfao since day 1
but are you using the node . command in the right folder
yeh
like
Im opening the .js file via vsc and opening terminal in there
unless the terminal thats opened
is wrong place
do ls
'ls' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\Jason>````
dir
you said you were in the terminal in vsc
ls should have worked but try dir like he said
Volume in drive C is OS
Volume Serial Number is B4B0-5282
Directory of C:\Users\Jason
27/02/2020 16:44 <DIR> .
27/02/2020 16:44 <DIR> ..
07/01/2020 21:42 197 .bash_history
20/12/2019 23:30 <DIR> .cache
11/03/2018 17:33 <DIR> .config
07/01/2020 21:30 304 .gitconfig
04/09/2018 20:49 <DIR> .InstallAnywhere
17/01/2020 12:03 42 .node_repl_history
04/01/2019 19:12 <DIR> .oracle_jre_usage
15/07/2018 15:33 <DIR> .Origin
15/07/2018 15:33 <DIR> .QtWebEngineProcess
17/06/2019 12:27 <DIR> .ssh
06/01/2020 17:10 <DIR> .vscode
03/02/2020 21:45 <DIR> 3D Objects
26/05/2018 11:04 <DIR> ansel
13/06/2019 20:59 <DIR> AppKiwiDownloads
03/02/2020 21:45 <DIR> Contacts
27/02/2020 14:47 <DIR> Desktop
27/02/2020 16:02 <DIR> Documents
27/02/2020 16:02 <DIR> Downloads
03/02/2020 21:45 <DIR> Favorites
28/02/2020 16:22 <DIR> Google Drive
28/02/2020 16:22 <DIR> iCloudDrive
03/02/2020 21:45 <DIR> Links
03/02/2020 21:45 <DIR> Music
28/02/2020 16:25 <DIR> OneDrive
03/02/2020 21:45 <DIR> Pictures
17/02/2020 20:10 <DIR> Saved Games
03/02/2020 21:45 <DIR> Searches
12/02/2018 13:05 <DIR> Tracing
17/06/2019 10:28 <DIR> Twitch
21/02/2020 15:54 <DIR> Videos
07/01/2020 21:24 214 _netrc
4 File(s) 757 bytes
29 Dir(s) 11,817,660,416 bytes free
C:\Users\Jason>````
you are in the incorrect folder I think
holy
try reopening the terminal the same way you do it normally
you good?
when i open the index.js file via literally double click
it loaded it as C:\Users\Jason>
i just manually opened folder via vsc and now its fine
omfg i feel dumb
I was about to set up args in the comand block until I saw this. do I leave it alone? Is a good question.
Both?
Yea, both
judging by the error, you messed up an argument
imma assume its serverinfoembed.addField(`Guild Name:`, message.guild.name , (message.guild.nameAcronym) , true)
which should be
serverinfoembed.addField(`Guild Name:, ${message.guild.name}, (${message.guild.nameAcronym})` , true)
np
o
oop
which should be
serverinfoembed.addField(`Guild Name:`, `${message.guild.name}, (${message.guild.nameAcronym})` , true)
there
im used to python so not having keyword args trips me up
ye i know it as
serverinfoembed.add_field(name="Guild Name:", value=f'${message.guild.name}, (${message.guild.nameAcronym})' , inline=True)
and np
the 2nd one yes
you tell me
