#development

1 messages · Page 582 of 1

hasty dust
#

possibly

#

so would javascript

#

and C

mossy vine
#

tl;dr: your first language doesnt matter. what does matter is what you want to do with programming after your first language (web development, software development, data analysis, machine learning, etc)

hasty dust
#

be a good idea

fiery quest
#

i have another question, i tried to set servers counter on my bot and i'm using this code rn, do you know why it doesnt work?

class DiscordBotsOrgAPI:

    def __init__(self, bot):
        self.bot = bot
        self.token = 'MY_TOKEN'
        self.dblpy = dbl.Client(self.bot, self.token)
        self.bot.loop.create_task(self.update_stats())

    async def update_stats(self):

        while True:
            logger.info('attempting to post server count')
            try:
                await self.dblpy.post_server_count()
                logger.info('posted server count ({})'.format(len(self.bot.guilds)))
            except Exception as e:
                logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
            await asyncio.sleep(1800)

def setup(bot):
    global logger
    logger = logging.getLogger('bot')
    bot.add_cog(DiscordBotsOrgAPI(bot))
hasty dust
#

yea, @mossy vine im interested in probably AI, and making a career out of it

slender thistle
#

@wide ruin afaik, C++, for example, is language with the most performance

wide ruin
#

what do you use it for?

slender thistle
#

@fiery quest Any Errors?

wide ruin
#

is it more games and stuff

fiery quest
#

nope, works fine the program

slender thistle
#

Yeah, C++ is widely used in videogames, I believe

fiery quest
#

but it doesnt show the server counters on discord bot page, still N/A

hasty dust
#

so... if I wanted to possibly use AI, or make video games, or something like that, would it make sense to go to java script, or python?

earnest phoenix
#

c++ is extremely lowlevel, don't take it as your first language

wide ruin
#

i mean you could use a bot to collect data

#

making sure the servers have accepted this

mossy vine
#

c is mostly for understanding how programming works at the low level. once you understand c concepts, you understand almost anything
C++ is used regularly on the backend when organizations are sufficiently large enough to justify investment in both horizontal-scaling and vertical-scaling.
C# is mostly associated with game development, mostly unity

wide ruin
#

because the gdpr are a thing

slender thistle
#

@fiery quest I would honestly recommend doing manual HTTP requests with aiohttp instead

#

dblpy is outdated

fiery quest
#

@slender thistle so what can i do?

hasty dust
#

python or java script then?

mossy vine
#

again, your first language DOESNT MATTER

#

you can go with anything

hasty dust
#

ok

wide ruin
#

that said js if you want to c# later, but still up to you

earnest phoenix
#

check out python's and javascript's syntax and pick whatever suits you more

hasty dust
#

I'll got wiith javascript then

#

any good tutorialsÉ

earnest phoenix
#

js and c# share some aspects but that's strictly with keywords, how they function is nowhere near the same

mossy vine
#

there are great javascript resources pinned in this channel

slender thistle
#

Look up some aiohttp examples and/or read the docs for it (if you don't know how to use it) and send an API request to DBL @fiery quest

hasty dust
#

thanks guys!

#

appreciate the help

fiery quest
#

obv with /bots/botid/stats, i think

#

at the end

slender thistle
#

Yep, but replace botid with your bot ID

fiery quest
#

yesyes

slender thistle
#

And also add 'Authorization': 'application/json' in your header

fiery quest
#

oh, ok, so after that i could be able to see servers counter on my html page right?

#

should*

slender thistle
#

Should be able to

earnest phoenix
#
shivaco M.Today at 8:31 PM
And also add 'Authorization': 'application/json' in your header

Content-Type*

slender thistle
#

Oh, whoops

#

Auth will be DBL token

#

When was the last time I worked with headers, I wonder bcStandingCat

hasty dust
#

@slender thistle @mossy vine Where should I write my code then, I hard visual studio code is good

slender thistle
#

I mean, you could go with Sublime Text or Visual Studio Code

mossy vine
#

i personally reccommend visual studio code. its lightweight, has many extensions, and is customizable to your liking

amber fractal
#

or literally anything that you want

mossy vine
#

first you should download the tools required to use the language you chose

hasty dust
#

I already got vs code on here, so I ll just use that

amber fractal
#

it's a personal preference

earnest phoenix
#

Hi

#

what :d

split hazel
#

How does the bot see default discord emotes?

#

I tried to blacklist every emote that starts with :point as people overuse it.
so i did if(message.content.toLowerCase().includes(":point"))
The actual :point gets deleted but not in emote form

#

aka 👆

amber fractal
#

I'm pretty sure it just sees them as regular emojis

quartz kindle
#

try console.logging them

inner jewel
#

it seems them as unicode

earnest phoenix
#

So set for each emote id

#

:point_down:

#

Oh no id😂

#

So for each rmore

misty anvil
#

hey guys does anyone have any ideas on sharding a bot between different hosts

amber fractal
#

What do you mean

hushed berry
#

@misty anvil I'm doing that rn

amber fractal
#

What does it even mean tho

hushed berry
#

I'm guessing separately a bot's shards across multiple machines

amber fractal
#

Ah

misty anvil
#

^

#

@hushed berry what are you doing it in?

hushed berry
#

wdym

misty anvil
#

like what language

fiery quest
#

tell*

earnest phoenix
#

How can I make it so when I shut down my bot since i'm developing it via local host it will tell the chat the bot has been shut off?

amber fractal
#

Introducing: HTML and CSS

earnest phoenix
#

thank you

empty owl
#

hey

#

how do u check if someone has admin? discord.js

night imp
#

.hasPermission

empty owl
#

that finds the role tho i thought

night imp
#

no

empty owl
#

ok

night imp
#
#

More information about the command can be found here

empty owl
#

ok

#

thanks

#

@night imp

#

if (message.author.hasPermission('ADMINISTRATOR') === false) return message.channel.send('No')

amber fractal
#

well

#

I think hasPermission checks admin by default unless you disable it

#

Well for users

earnest phoenix
#

@modern sable Can i test a command in here?

modern sable
earnest phoenix
#

oh ty

glacial venture
#

does anyone know anything about sqlite? (i have no idea what this is nor how to use it) i would like to store data with my bot but i'm clueless as to how.

amber fractal
#

Have fun

earnest phoenix
#

if(command === "duo") {
Message.channel.send("$user do you accept the duo by $user?");
}

#

Command Is Not Defined Error.

amber fractal
#

Then command isnt defined

earnest phoenix
#

How do I define it?

amber fractal
#

Do you know what language you're writing this bot in

earnest phoenix
#

.JS

amber fractal
#

Atleast you know that

#

Have you ever done anything related to js in the past?

earnest phoenix
#

Yes.

amber fractal
#

Because defining variables is usually the first thing you learn

earnest phoenix
#

(o/o)
({})

amber fractal
#

?

earnest phoenix
#

Instead of making a big deal over it can you not just help me out here?

#

I'm trying to get some stuff on it done tonight.

#

I would appreciate instead of just making a big deal over it.

amber fractal
#

Have fun

earnest phoenix
#

Fuck you

#

Smart ass.

amber fractal
#

Dude it's literally in there

#

👋 You are an amazing person that deserves all the help I offer. Now have fun creating your bot

earnest phoenix
#

You offered no help but a link.

#

The link is useless info or I would have gone there myself.

coral hedge
#

Well the issue was that command was not defined, you never made a variable called command. I'd say that link is pretty useful.

bright spear
#

hi @earnest phoenix read rules 1 and 7 kthx

fiery birch
#

yea maybe he will over the next 2 hrs, dw

bright spear
#

ah

undone hearth
#

my bot got muted and i fixed the issue, what do i do to get it unmuted

night imp
#

DM(offline) or ping the mod (online) who muted it

undone hearth
#

what do you mean by offline and online?

night imp
#

DM if the mod is offline currently ping if they are online

undone hearth
#

should i ping in here

night imp
#

Or another mod may be able to look at it that's just what I was told before

undone hearth
#

and what should i say

night imp
#

I fixed my issue with bot @opal zinc could you please unmute it?

undone hearth
#

ok

#

should i ping them in here

night imp
#

Ig

undone hearth
#

???

night imp
#

I guess

undone hearth
#

ok

bright spear
undone hearth
#

ok

oblique gulch
#

Help me

mossy vine
#

Ok

oblique gulch
#

i'm started programing in python today

mossy vine
#

yeah i cant help with python

oblique gulch
#

😦

slender thistle
#

@oblique gulch

#

Cogs (classes) must subclass commands.Cog

#

I see you like Neffex too

oblique gulch
#

e-e

#

I love Neffex

#
from discord.ext import commands

import discord

class Test:
    def __init__(self, matteo):
        self.matteo = matteo

    @commands.command(name='test', aliases=['mds', 'vaiporra'], description='Teste mesmo', usage='Sla')
    @commands.cooldown(1, 6, commands.BucketType.channel)
    @commands.bot_has_permissions(embed_links=True)

    async def _test(self, matteo):
        await ctx.send('Eae!')

def setup(matteo):
    matteo.add_cog(Test(matteo))```
#

correct?

#

@slender thistle

slender thistle
#

To class Test

#

Add (commands.Cog)

oblique gulch
#

can you send a example?

slender thistle
#

Literally class Test(commands.Cog):

#

Your Test class will be a subclass of commands.Cog

oblique gulch
#

oh

#

wait

#

i'm testing

#

I've done an aquivo.py with cooldown functions and etc in my cogs folder .... Do I have to add (commands.Cog)?

#

@slender thistle

slender thistle
#

You must make all of your cogs derive from commands.Cog (subclass, like you did just now)

oblique gulch
#

correct?

slender thistle
#

Yep

oblique gulch
#

not send the message

#

e-e

slender thistle
#

Huh

#

Of

#

Ph

#

Ffs

oblique gulch
#
    async def on_command_error(self, ctx, error):
        if isinstance(error, cmd.CommandOnCooldown):
            m, s = divmod(error.retry_after, 60)
            return await ctx.send(f"{self.matteo._emojis['vermelho']} **{ctx.author.name}**, aguarde **`{int(s)}`** segundo(s) para poder usar o comando **`{ctx.invoked_with}`** novamente.", delete_after=8)```
slender thistle
#

@oblique gulch all listeners in cogs must have a commands.Cog.listener() decorator

oblique gulch
#

wait

#

5 secs

#
from discord import errors, Embed
from discord.ext.commands import errors as cmd
from discord.ext import commands

class Erros(commands.Cog.listener()):
    def __init__(self, matteo):
        self.matteo = matteo

    async def on_command_error(self, ctx, error):
        if isinstance(error, cmd.CommandOnCooldown):
            m, s = divmod(error.retry_after, 60)
            return await ctx.send(f"{self.matteo._emojis['vermelho']} **{ctx.author.name}**, aguarde **`{int(s)}`** segundo(s) para poder usar o comando **`{ctx.invoked_with}`** novamente.", delete_after=8)```
#

not send the message

slender thistle
#

I didn't say subclass

#

Your on_command_error needs the decorator I mentioned

oblique gulch
#

i'm noob in python sorry

slender thistle
#

Look up in Google what Python decorators look like

#

Well that's unfortunate because d.py is not really beginner-friendly

heady basalt
#

fuck

spare goblet
#

this isn't really a development question but
if you don't have 2fa enabled and do make ur bot have perms that allegedly required so, what happens?

earnest phoenix
#

Hi

earnest phoenix
coral trellis
earnest phoenix
#

and

#

i dont know how can i do that

opaque eagle
#

I don't know how anyone could explain it better.

#

There's an API endpoint and a token, just POST to it...

earnest phoenix
#

but where i post it

amber fractal
earnest phoenix
#

😕

#

can u send me pictures of to that work
I dont speak english i use google translate when i read this :/

dusky marsh
#

What discord library are you using @earnest phoenix

opaque eagle
#

You don’t know how to make a POST request?!

halcyon torrent
#

it's easier than using a discord lib, tbh

opaque eagle
#

Yeah

earnest phoenix
#

@dusky marsh js

opaque eagle
#

Your language doesn’t matter at all

#

Just send a POST request to the api endpoint

earnest phoenix
#

But how can i send

#

show me

dusky marsh
#

The one for js is ez if all you wanna do is post your server count

#

If you look at the link to the documentation that someone sent earlier , it has some code that you can pretty much just copy

earnest phoenix
#

But where to paste that code

rotund sinew
#

Anywhere

#

Dont put it in a function

earnest phoenix
#

dont spoonfeed

rotund sinew
#

Oops

ruby dust
#

is it healthy for an sqlite database to be spammed with SELECT 3 times at once, lets say, when the user joins some server?

dusky marsh
#

I think sqlite databases can handle up to some 30000 interactions or something like that at once

#

@ruby dust

ruby dust
#

all I'm aware of is that sqlite tends to lock up when you try to commit too frequently, which is why I'm asking if that'd be an issue if I do anything that fast without committing

amber fractal
ruby dust
#

that's still quite vague to me, does this mean they can't commit at once or just doing any general writing?

amber fractal
#

I think sqlite pools does some funky stuff to allow more than one write, havent looked into it completely tho

inner jewel
#

3 selects at once are nothing

#

if they only use primary key it's even more insignificant

ruby dust
#

but what about the writing part?

inner jewel
#

only one can write at once, but for most cases the write happens too fast for the lock to be noticeable

earnest phoenix
#

hey can someone help me with my code and tell me what's wrong with it

const Discord = require('discord.js');
const client = new Discord.Client();

client.on('ready', () => {
  console.log(Logged in as ${client.user.tag}!);
});

client.on('message', msg => {
  if (msg.content === 'Hello') {
    msg.reply('Hello! I am HakPak, and I do not understand much!');
  } else {
    msg.reply('I am HakPak, and because I have not been fully coded yet, I cannot respond to your message. I am very sorry.');
  }
});

client.login('TOKEN');

i have the token inserted
i just removed it so you all couldn't see

inner jewel
#

it'll spam forever

#

you get message events for your own messages

earnest phoenix
#

How do I create a permission level system? like, if I add permissionlv: 10 in the end of a command i want it to only allow the people in a json array

#

oh

#

I've fixed the json array thing, but idk how to make the level thing

amber fractal
#

@earnest phoenix store their permission level somewhere

earnest phoenix
#

how do i fix that then

#

also it's not even messaging

inner jewel
#
user: a
bot: I am HakPak...
bot (triggered by it's own message): I am HakPak...
bot (triggered by it's own message): I am HakPak...
bot (triggered by it's own message): I am HakPak...
...```
earnest phoenix
#

in a json @amber fractal

#

if they arent in the json, they dont have that permission level

#

oh

#

but not even one message sends

inner jewel
#

oh

#

console.log(Logged in as ${client.user.tag}!);

amber fractal
#

In the json, make the perms the number as the key

inner jewel
#

you need to make it a string

#

that's invalid js

earnest phoenix
#

oh

#

hm

#

so owner ID is 10, admin ID is 9 etc

#

instead of oID and aID

amber fractal
#

Let me make an example

earnest phoenix
#

ok

#

Wait, so what's making it loop

slim heart
#

the bot responds to its own message

earnest phoenix
#

Help i'm just getting pinged over and over again now please help

#

so how do you do it

slim heart
#

you can just return; if the message author is a bot

earnest phoenix
#

like elseif not hakpak?

#

huh

#

dude stop adding else's

slim heart
#

just at the beginning

earnest phoenix
#

also

#

i'm just getting a steady string of pings help me ?

#

wait i don't understand

#

omfg

#

bruh i'm new to coding

#

well js

#

learn the language first

slim heart
#

<User>.bot is a boolean for whether the user is a bot use that and just stop if it is

earnest phoenix
#

dont create a discord bot while you learn

amber fractal
#

Obviously

#

it's different

earnest phoenix
#

wait

#

im retaraded

amber fractal
ruby dust
#

it's the mistake that everyone makes, you think you are capable of making a bot right away but when you get better you start to regret it, or at least that's what happened with me

earnest phoenix
#
{
  "token" : "töken",
  "prefix" : "-",
  "1" : "295164014462369792",
  "2" : ["221285809364402186", ""],
  "bServers" : [],
  "bUsers" : []
}

#

when you come to this channel it is expected of you to know the language you are working with

otherwise its very important to take a step back, learn the knowledge you lack and then continue making a project

#

thats my config.json

amber fractal
#

Oh wait

earnest phoenix
#

1 is owner

#

2 is admin

#

i want it to read from the json

#

no the thing is, we have a hackathon in 2 weeks

#

lol

#

i know how it reads the json

#

but

slim heart
#

doesnt make a difference dvrx

earnest phoenix
#

the perm level thing confuses me

#

my team and i are now struggling to get a bot done

slim heart
#

its better that u learn

amber fractal
#

I think I misunderstood

earnest phoenix
grim aspen
#

i regret starting it but i'm somehow still coding

amber fractal
#

what you meant

earnest phoenix
#

the thing is, it's not like umm

#

we won a hackathon to advance to this one

#

so yeah, we have to gamble and go big

#

thats irrelevant to what we are telling you

#

i understand

amber fractal
#

You can just check if their id matches any of them in the array for the permission that you want them to have

earnest phoenix
#

yeah

#

i know that

#

but i want to be lazy

grim aspen
earnest phoenix
#

and just add permissionlv: 1 in the end of the command file

#

or something like that

#

like this

#
exports.run = async (client, message, args) => { // eslint-disable-line no-unused-vars
  const msg = await message.channel.send("Pinging..");
  msg.edit(`Pong! ${msg.createdTimestamp - message.createdTimestamp}ms`);
};
permlv: 1
#

something like this

amber fractal
#

this is a little example

earnest phoenix
#

hm

sinful lotus
#

one easy way to do it is
exports.perms = 3
then get the command if you save it in map like const cmd = commands.get(command)
if (cmd.perms === 3) // check if user have perms

earnest phoenix
#

thats my goal

#

but im too retarded

#

idk how

#

i suck with SQL, maps and stuff like that

sinful lotus
#

its not even that hard

topaz fjord
#

Then learn them

sinful lotus
#

its same as exports.run

#

but you change the run into a property instead of a function

earnest phoenix
#

yeah

#

idk how

#

xd

sinful lotus
#

you dont know how to change exports.run to exports.perms ?

#

you may want to learn about exports more fi thats the case

#

its literally just adding a property

earnest phoenix
#

hm

sinful lotus
#
// command
exports.run = async () => {};
exports.perms = "KICK_MEMBERS"
//  command handler
const cmd = commands.get(command)
if (cmd.perms) {
  if (!msg.member.hasPermission(cmd.perms)) return
}

if you cant understand this simple snippet, I even used the actual perms as a variable, then I advice you stop trying to do it, and read more about module.exports

earnest phoenix
#

sorry, but thats not the kind of permissions im talking about

inner jewel
#

same logic

earnest phoenix
#

hm

sinful lotus
#

same logic but simpler

earnest phoenix
#

OH

#

exports.perms = config.admins.includes(message.author.id)?

sinful lotus
#

that would return a boolean

earnest phoenix
#

if(exports.perms = true) {
command
}

sinful lotus
#
// command
exports.run = async () => {};
exports.perms = "BOT_OWNER"
//  command handler
const cmd = commands.get(command)
if (cmd.perms) {
  if (cmd.perms === "BOT_OWNER") {
    if (!config.admins.includes(msg.author.id)) return
  }
}

this is a much more simpler approach and more better in long run

#

that would work but on owner commands only

earnest phoenix
#

what if I want to add admins to the bot

#

that's basically why I want to add this

sinful lotus
#

then add the admins on the array of your config.admins

earnest phoenix
#

i did that

sinful lotus
#

didnt you understand what you coded?

earnest phoenix
#

i did

sinful lotus
#

config.admins is an array of your admins since I saw you used .includes

earnest phoenix
#

yeah

#

i know that

sinful lotus
#

so BOT_OWNER is the perm "variable" of the command

earnest phoenix
#

yeah

#

but I think that IDs are better for some reason

sinful lotus
#

That checks ID oh my goodness

earnest phoenix
#

wait

#

so

sinful lotus
#

"BOT_OWNER" is just a variable to instruct the command handler to look for config.admins DoubleFacepalm

#

read the code pls

earnest phoenix
#

BOT_OWNER is the owners ID, but I want to use IDs in case I get falsely banned from discord again

sinful lotus
#

ahhhh no no no

earnest phoenix
#

yeah

#

i know that

sinful lotus
#

no you dont know since BOT_OWNER is just a string

#

you wont put id there

#

its just BOT_OWNER

#

then when you get the command from cache

#

the command handler will check if command.perms or exports.perms exists

#

if it do exists check what it contains

#

if it contains BOT_OWNER, check if the msg.author.id is included in the array of config.admins

#

thats how simple it is DoubleFacepalm

earnest phoenix
#

hm

sinful lotus
#

add a exports.perms = "something" on your command
then on your command handler, use console.log() to log what is the variable of the command

#

that would help you understand better

earnest phoenix
#

anyone know if its possible to log in a bot in a user account instead of as a bot?

sinful lotus
#

thats against TOS and we would not teach you how to do it

earnest phoenix
#

so it's possible? lol

sinful lotus
#

it is possible but you are on your own, and we are not liable if you get ip banned of some sort

earnest phoenix
#

I'm too retarded to figure out how to do it anyway lmao

amber fractal
#

@earnest phoenix well doesnt matter, we wouldnt tell you anyways

earnest phoenix
#

he said that already no need to ping

amber fractal
#

And you still pursued.

fiery quest
#

anyone know if it is possible to make the print all the commands executed in a "log channel" creted specifically in my discord?

#

with python 3

earnest phoenix
#

hardly lmao

fiery quest
#

i find no results on internet

amber fractal
#

This type of logging would easily get you ratelimited

sinful lotus
#

just make it log something when a user executed a command

#

although ratelimits

grim aspen
#

"creted" might be the problem

fiery quest
#

created* dont look at the syntax, im not english, sorry

earnest phoenix
sinful lotus
#

there is no such thing as message in the params of the guildmemberadd

earnest phoenix
mossy vine
#

yes

#

it is

earnest phoenix
#

ok

#

thanks

sinful lotus
#

member is

earnest phoenix
#

nvm

hushed berry
earnest phoenix
#

how do you think this code will be for an identifier

#
var msg = '!spam';
var tf = msg.charAt(0) === '!';
console.log (tf);
#

like, not exactly this code, of course, but a tweaked version with an if statement

#

i'm new to bot development, so thanks for your help 😃

amber fractal
#

As a beginner, maybe. But you should define the prefix in a seperate variable

#

Well that shouldnt be a command handler either way imo

earnest phoenix
#

yeah

#

@amber fractal I am a beginner, so I'm trying to do it in a simple way for now

#

Thanks!

glacial venture
#

What is the difference between const, let, and var? I know they are all for variables and that const variables can’t be changed. So I guess just what’s the difference between var and let?

inner jewel
#

var is function scoped, let is lexically scoped

glacial venture
#

I see. I’ve been using let thinking it was function scoped. Thanks

inner jewel
#

you should be using let

glacial venture
#

huh

#

Ok I guess I was right then thanks

earnest phoenix
#
  if (msg.content.charAt(0) === '!') {
#

is this incorrectly coded lol

#

i'm pretty sure it is

#

you don't have a.b.c(d) do you

#

or no

quasi stirrup
#

I want to design my bot page how can i do that?

inner jewel
#

html and css

quasi stirrup
#

Any docs?

inner jewel
#

google is your friend

quasi stirrup
#

Docs on how to impliment it in my bot page..

mossy vine
#

just use html and css

earnest phoenix
#

@quasi stirrup

quasi stirrup
#

@earnest phoenix ya?

earnest phoenix
#

I believe you can type html and css into your description

#

and it will change

quasi stirrup
#

Yes i will

earnest phoenix
#

you don't have to buy a domain haha

quasi stirrup
#

Lol

mossy vine
#

so in links you usually replaces spaces with %20
what are those %number things called?

earnest phoenix
#

I made a working blacklist, but how do I make so that when they join the support server, they get the Blacklisted role?

#

The Blacklisted role shows a channel to appeal for your blacklist

#

So this is needed

late hill
#

Listen for member joins

#

If it's in your server

#

Assign the role

#

if they are on the list ofc

earnest phoenix
#

Yeah

#

But it doesn't give the role for some reason

#
  if(member.guild.id == "548841765424070656") {
    member.addRole(member.guild.roles.find(role => role.name === "eveREEone"));

    if(config.bUsers.includes(member.id)) {
      member.addRole(member.guild.roles.find(role => role.name === "Blacklisted"));
    }
  }
#

Also using an ID is easier but I forgot how

late hill
#

I think addRole accepts role id's as arg

#

And maybe not roles

#

So preferably you should change it to member.addRole(whateverTheIdOfTheRoleIs)

#

But just adding .id to your role search should also work

earnest phoenix
#

Hm

#

so i should change member.addrole(member.guild.roles Etc) to addrole("id")

late hill
#

Replace these member.guild.roles.find(role => role.name === "eveREEone")

#

With just the id of the role

earnest phoenix
#

With id

#

Ok

late hill
#

As a string

crimson gull
#

member.guild.roles.find(role => role.name === "eveREEone").id would work as well.

amber fractal
#

It takes a role resolvable, so a role or id

#

So that should work.

late hill
#

I guess that would depend on the library

#

Which is why I said maybe

earnest phoenix
#

is rethinkdb good for economy?

#

Can someone help me program my bot.
Its my first time making one and i need help

quartz kindle
#

You should learn a programming language first. There are many websites where you can learn

earnest phoenix
#

Could i get a link to one possibly?

quartz kindle
#

I heard a lot about codecademy

earnest phoenix
#

Okay thank you

#

is rethinkdb good for economy?

amber fractal
#

Any reason why my bot would start responding twice randomly? I didn't change anything or restart anything

earnest phoenix
#

maybe because it is running on 2 vps

#

Ex: glitch and another vps

amber fractal
#

Glitch Thonk

#

I dont have an account

earnest phoenix
#

or heroku

amber fractal
#

I've never hosted this bot anywhere else

#

it's been running for 3 months

earnest phoenix
#

either way the only main cause of that is its being run on 2 vps

#

or ran twice

tepid laurel
#

Soooo

#

Just a weird thing that im not getting

#

With djs

#
.on('message', async msg => {
    if(!msg.content.startsWith('_eval')) return;
    if(msg.author.id !== '148899587283877888') return;
        const evaled = await eval(msg.content.split(' ').slice(1));
        return msg.channel.send(`\`\`\`js\n${evaled}\n\`\`\``);
  });
#

This just keeps sending back the very input that was given to evaluate

#

Which it shouldnt it should send back the result

#

Any ideas why?

amber fractal
#

idk why, but why do you use await

#

It's not a promise

harsh nova
#

He awaits eval

tepid laurel
#

Ya

amber fractal
#

It doesn't do anything.

tepid laurel
#

Ive had that bigger chunks of code

#

Managed to send back empty results

#

Cause it wouldn't wait for the eval result

amber fractal
#

await 1 = 1

#

Awaiting it doesn't do anything

tepid laurel
#

Wew

#

Whole discussion about an await

#

🤷🏼‍♂️

amber fractal
#

Yes because it makes no difference

harsh nova
#

Doesn’t eval return a promise though? or am I just confused again

amber fractal
#

N

#

No

harsh nova
#

Alright

tepid laurel
#

I believe so but not sure 100%

inner jewel
#

if the code in the eval returns one, it will

amber fractal
inner jewel
#

const promise = eval('Promise.resolve(1)')

fiery quest
#

anyone know how i can set on a background image the opacity? beacause i add {opacity: 0.5 ;}

#

but it take all the div*

tepid laurel
#

So it can still return a promise

#

Anywaywa

#

Anyways

#

Its not what my question was tho😂

#

Nevermind

#

Figured it out

#

Slice returns an array of the sliced string

#

Thus eval returns the array

#

Cause its not a string

earnest phoenix
#

anyone know why am getting this

pine leaf
#

Are you in a python virtual environment

earnest phoenix
#

im in a cmd

#

i put in conda

pine leaf
#

Being windows you do have installed right?

#

*git

#

Honestly that's about as far as I'm willing to go for troubleshooting, I am dogshit in Windows environments

earnest phoenix
#

idk how to install get

#

or how to check

pine leaf
#

If you're not sure how to install git it's a safe bet you don't have it installed

#

Also what python module are you trying to install? If you're just trying to install the discord.py module you should just be able to run pip install discord.py

slender thistle
#

I shall intervene and say no

earnest phoenix
#

Don't do that

#

That's outdatef @pine leaf

slender thistle
#

Unless you want to suggest the old version of the library

pine leaf
#

Oh shit it is

#

My bad

#

Where's the new library?

slender thistle
#

pip install -U git+https://github.com/Rapptz/discord.py@rewrite#egg=discord.py[voice]

knotty steeple
#

remove [voice] if ur not making a music bot

#

or anything with voice

slender thistle
#

I don't think it matters that much but eh

slender thistle
#

Compare message content to message author mention

copper cradle
#

ok

slender thistle
#

Unless you mean if they mention themselves while using a command

copper cradle
#

yeah

slender thistle
#

In which case I would think you will need to split message content, iterate through the list/array it gives you and compare its elements to message author mention

#

Or just check if message content includes message author mention

#

See which one will be good for use in your case

copper cradle
#

ok

empty owl
#

s

obsidian comet
#

weird question but does anyone know if its possible to stop a docker container from inside itself

#

like shutdown -h now for inside the container

#

something to run like docker exec <container> shutdown

dense dove
#

@bright spear how did you get a background on your html page in bot long description? mine is remaining as white

empty owl
#

.-.

#

inspect element

#

css

dense dove
#

i did

#

oh wait

#

lmao

#

brb

empty owl
#

body {
}
works

#

¯_(ツ)_/¯

bright spear
#

Yeah I put a ton of css in the long description

empty owl
#

yea

#

it would be nice if

#

console.log(`User with ID ${vote.user} just voted!`);

bright spear
#

@empty owl client.users.get('id')

empty owl
#

would do username

#

do i do vote.username

dense dove
#

@sinful lotus can save u here 😛

bright spear
#
#

No

empty owl
#

ok

dense dove
#

he saved me as well

empty owl
#

ok

bright spear
#

client.users.get(vote.user).username

empty owl
#

ok

#

thx

bright spear
#

Yw

empty owl
#

yw

dense dove
sinful lotus
#

for?

#

I do have a ready made vote handler that if you guys are talking about that

amber fractal
#

I put css in my long description for the part the long description is is but it stayed white

#

Even woth important

#

So I gave up

earnest phoenix
#

What's a good way to profit from developing bots without it being too much and turning users away?

#

I honestly don't care that much about profit, I just want something.

sinful lotus
#

make it good

amber fractal
#

Idk if most people would pay anyways, theres tons of free bots that probably could tend to their needs. However, it really depends on your skills and what they want

sinful lotus
#

and worth to support for

earnest phoenix
#

So donations then?

sinful lotus
#

yes possibly

amber fractal
#

A lot of devs have a patreon

earnest phoenix
#

And yeah I do make quality stuff. I care about every detail.

amber fractal
#

But do your users think the same?

#

It doesnt matter what the dev thinks, the users have more say or they wouldnt use your bots. Seems like democracy at it's best mmLol

#

Honestly tho, patreon can be good

earnest phoenix
#

I mean I'm here to get feedback. I know what devs say doesn't matter but I'm looking for options.

#

Patreon seems good, but how to incorporate it in a bot? Premium features and stuff?

sinful lotus
#

tbh no matter how good the bot

#

they will still kick it

#

so all you can do is

#

make it as great as you can

earnest phoenix
#

I'm not talking about making it a paid bot nepyay

#

Just with something to not make it a waste of time

sinful lotus
#

that applies to non paiid and donations

amber fractal
#

And here I am coding for fun

earnest phoenix
#

I do code for fun as well

#

All my previous bots were for fun

sinful lotus
#

but tbh I feel I just create my bot on my own preference

earnest phoenix
#

But then I thought I'd at least gain something from developing new bots

sinful lotus
#

and users do like it

earnest phoenix
#

I don't think users would care to donate

amber fractal
#

You'd be surprised

earnest phoenix
#

Really?

amber fractal
#

Well if your community isnt terrible

#

Not that not donating makes them terrible

earnest phoenix
#

I mean maybe at least with patreon, not traditional donations, just to acknowledge them

amber fractal
#

If it's a bigger bot, you could list their server or something.

sinful lotus
#

tbh Im nearly 40k and I only have 6 patreons

#

and my bot isnt locked by donations

earnest phoenix
#

Tbh currently I'm thinking about a very simple bot that I don't think it's worth making premium features and stuff

sinful lotus
#

users would donate if they seem feel the bot is worth it

earnest phoenix
#

I'm going with donations but I feel I need to have patreon to give users who support special stuff

#

Yeah I thought about it. No premium features at all, just patreon role in the support server, and maybe also showing it beside the user's name when they do stuff using my bot.

#

Thanks for the discussion.

lilac geyser
#

Is there a global manage permissions thing

#

global = for the whole server

#

if not, besides administrator and giving manage permissions for that channel, is there another way to do it?

#

i just mean that is there a permission that will override and enable manage permissions for all channels besides administrator

late hill
#

No

#

Why not just give them manage messages then what

#

wait what

#

what do u even mean manage permissions

#

what are u trying to do

earnest phoenix
#

what language are u speaking

lilac geyser
#

@late hill Lmao, that was very helpful. i found out anyway, needs perm manage roles

late hill
#

okay well

#

manage permissions was also very helpful

viral spade
#

are channel-ids unique per guild or global?

bright spear
#

Global @viral spade

#

All IDs are global

viral spade
#

thx

bright spear
#

Read the snowflakes section

shadow dust
#

Anyone here familiar with Lavalink?

earnest phoenix
#

yes

kind wyvern
shadow dust
#

How would I add tracks to the queue?

kind wyvern
#

Pls help

sinful lotus
#

use arrays maps

#

for doing those

kind wyvern
#

U saying me ?

sinful lotus
#

nah

#

on the other guy

kind wyvern
#

Ok

shadow dust
#

Well I mean I know what structure to use im just not sure how to for say get a track object based on a url

earnest phoenix
#

Check their npm page

kind wyvern
#

Anyone help

sinful lotus
#

wait you dont know how to read the lavalink object?

kind wyvern
#

Tag and ask pls

sinful lotus
#

Im not a python proficient but even I can tell whats your problem

#

look on bot.py line 1 thats your error because you dont have a module named "discord"

kind wyvern
#

How I install

marble needle
#

why even bother cloning git repositories with code you don't understand if you cant even install a module

kind wyvern
#

I am new

sinful lotus
#

How did you get the bot developers role if you dont even know how to install a module

#

thats the most basic one

kind wyvern
#

i am a js developer

sinful lotus
#

dont ask me for how since I dont do python

#

use your google

kind wyvern
#

k

shadow dust
#

@sinful lotus nah I've watched the github repo but I cant find anything describing that

kind wyvern
#

Thanx for the ||REPLY||

sinful lotus
slender thistle
#

@kind wyvern Show me some of your code

shadow dust
#

Yeah I looked at that

kind wyvern
#

@slender thistle DM

slender thistle
#

Any command or whatever

sinful lotus
#

this is what I used for my implementation and I never had problems

shadow dust
#

oh there we go

#

Thanks

sinful lotus
#

look deeper next time

shadow dust
#

I didnt see this earlier 🤔

earnest phoenix
#

@sinful lotus lmaoo u got rickrolled

rotund ferry
#

Can someone here help me with this error

unhandled rejection: { DiscordAPIError: Missing Permissions
    at item.request.gen.end (C:\Users\rene\Documents\ServerStatsV3.1.0\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:79:15)
    at then (C:\Users\rene\Documents\ServerStatsV3.1.0\node_modules\snekfetch\src\index.js:215:21)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  name: 'DiscordAPIError',
  message: 'Missing Permissions',
  path: '/api/v7/guilds/<serverid>/channels',
  code: 50013,
  method: 'PATCH' }
amber fractal
#

Read it maybe?

carmine echo
#

Where am I supposed to put the certs on my vps kek nginx

rotund ferry
#

@amber fractal Thanks i didn't know that i have to read errors

carmine echo
#

Are you joking?

rotund ferry
#

Yes

amber fractal
sinful lotus
#

if you ask me

#

where that comes from

carmine echo
rotund ferry
#

I know that is a missing permissions but from where

sinful lotus
#

even I myself is having a hard time tracking those

amber fractal
#

It tells you exactly what i would

sinful lotus
#

but with the path

#

Im sure it tells you where

amber fractal
#

Somewhere you make a request to guilds

carmine echo
#

life tip: .catch() things

sinful lotus
#

even you catch that you need to track that request

carmine echo
#

.catch(() => {}) kek

rotund ferry
#

Yes the path tells me but I don't know how

carmine echo
#

for example if it's a ban, always check if the member is bannable

#

or manageable

rotund ferry
#

All the request I do has a permissions check

sinful lotus
#

tbh

carmine echo
#

and catch() everything you can

sinful lotus
#

I have that issues as well and I cant track where are those from

#

so even you ask here, it would be hard to pinpoint where exactly in code

#

thats just how it is

#

but in path

rotund ferry
#

Ok thanks @sinful lotus

sinful lotus
#

it says where it is

#

what kind I mean

#

path: '/api/v7/guilds/<serverid>/channels', this tells you that you are accessing somewhat a channel

rotund ferry
#

I thnk the path is weird

sinful lotus
#

you gotta skim and find what part of code you access a channel

rotund ferry
#

XD thats the point my bots main function is something with channels

sinful lotus
#

then you fix the issue on that regard

rotund ferry
#

Not this one

#

This one is a f*ck boy

robust breach
#

@kind wyvern i really hope you found out how to install the module by now

#

use the rewrite branch

rotund ferry
#

@sinful lotus This is the check I do before accessing the channels

if (!message.guild.me.hasPermission("ADMINISTRATOR") && !message.guild.me.hasPermission(["MANAGE_CHANNELS", "VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS", "CONNECT"])) {
    return message.reply(client.strings.noBotPermissions);
};
sinful lotus
#

you return message.reply

#

it means you will still send a message even the bot has no perms on it heheheh

rotund ferry
#

I check that in the message event LOL

sinful lotus
#

yes but you return message.reply

#

it means the bot will try to send the message on that channel

#

even it has no perms

rotund ferry
#

But not if i dont have SEND_MESSAGES

sinful lotus
#

not really

#

you confused your own

rotund ferry
#
if (!message.channel.permissionsFor(client.user.id).has("SEND_MESSAGES")) {
    return;
};
sinful lotus
#

it says

if (!message.guild.me.hasPermission("ADMINISTRATOR") && !message.guild.me.hasPermission(["MANAGE_CHANNELS", "VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS", "CONNECT"]))

when you have no perms that you specified in this channel

{
    return message.reply(client.strings.noBotPermissions);
};

do this

jagged birch
#

Your code is saying if you don’t have any permissions send a message, it can’t if it has no perms

sinful lotus
#

so what is the point of checking for perms

#

if you send a message even it has no perms to send it?

rotund ferry
#

Because I check before if I can send a message

marble needle
#

read your code and try to understand what you did

jagged birch
#

Dude

sinful lotus
#

I already explained the code you sent step by step

#

I will explain it in more newbie way

marble needle
#

you are checking if you do not have the permission to send a message. if said check returns true you try to send a message

sinful lotus
#

message.reply() is msg.channel.send()

rotund ferry
#

I think you guys don't understand

sinful lotus
#

with mention

jagged birch
#

We understand, you don’t.

robust breach
#

Zixe are you saying you’re checking SEND_MESSAGES in two separate if statements

sinful lotus
#

thats a more better way of doing that

#

one liner and effective

marble needle
#

the absence of semicolons triggers me :>

sinful lotus
#

I removed it at the rewrite

#

I use semicolons before

#

but now I just use it when compiler dont understand what I want

rotund ferry
#

First someone types something (message event trigger)
Message event checks if the bot can send messages.
Then my commend triggers
Then the bot checks if he has permissions the do the thinks in de command if not send no permissions

sinful lotus
#

then it makes no sense to check again for SEND MESSAGE for the second line

robust breach
#

^

rotund ferry
#

@robust breach no I check it ones

sinful lotus
#

you check for send message the first time

rotund ferry
#

No sorry 2

robust breach
#

you just said it checks twice

sinful lotus
#

then check it again

rotund ferry
#

thats a error

#

but

sinful lotus
#

change your perm checking into something more "readable"

rotund ferry
#

that don't checking anythink

robust breach
#

then it’s one of the other perms you aren’t checking for

sinful lotus
#

as well there are numeorous events

#

it could not be triggering at message but also in other events

#

or some module u created

#

a lot of factors play on that

rotund ferry
#

I also check in events for permissions if needed

sinful lotus
#

yes but based on what I think on what you sent

#

its not impossible you did something wrong

#

you even check SEND_MESSAGE twice

#

thats what makes me think something is wrong even the error tell that

#

so double check

robust breach
#

@rotund ferry you’re probably doing something before the permissions check that is erroring it

sinful lotus
#

thats a factor too

#

thats why double check

rotund ferry
#

I can tell you why the double check, in discord you can overwrite perms in chennels.
The first check in for the channel where the command in send and the second is global.

robust breach
#

huh

#

how is that related to what we’re telling u

rotund ferry
#

Thats the why I double check for send permissions

sinful lotus
#

I mean no offense but

if (!message.guild.me.hasPermission("ADMINISTRATOR") && !message.guild.me.hasPermission(["MANAGE_CHANNELS", "VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS", "CONNECT"])) {
    return message.reply(client.strings.noBotPermissions);
};

if this is your global

if (!message.channel.permissionsFor(client.user.id).has("SEND_MESSAGES")) {
    return;
};

and this is what is in your command

rotund ferry
#

The first is channel based and second is server based

sinful lotus
#

but thats useless if you can just return on global 👀

rotund ferry
#

O my god did you read what i'm typing

sinful lotus
#

you said one is channel 2nd is server based

#

the global is useless

#

channel overrides everything

rotund ferry
#

The first code is in aa command end the second is in the message event

sinful lotus
#

its better to check for channel than global for send messages, embed, and other stuff

rotund ferry
#

I dont and I will check it

sinful lotus
#

as well you are creating a lot of not needed lines which will make the maintenance more hard

#

most likely you are facing that issue due to that as well

#

my advice is

#

use channel based permission checker instead of msg.guild.me.hasPermission

#

as well you dont need to create lots of

if (!message.channel.permissionsFor(client.user.id).has("SEND_MESSAGES")) {
    return;
};
#

just put that on the beginning of your message event

rotund ferry
#

I only have one in the message event

#

and it's @ the start

sinful lotus
#

yes but the second stuff you gave which is the admin blabla doesnt make any sense since you also check for send_message there which is idk why you did that. so I would advice to rewrite your code a bit

#

its you who will have the hardtime not us

#

if you dont rewrite it a bit

rotund ferry
#

I know that and thanks for telling

robust breach
#

Zixe if you’re only checking for SEND_MESSAGES and you’re erroring it’s definitely because you aren’t checking for the permission required before doing something

sinful lotus
#

embeds also needs perms just incase you wonder

robust breach
#

you’re checking for perms in two separate spots but you’re only checking for send_messages at the beginning

rotund ferry
#

I know embeds need permissions

sinful lotus
#

ok what permission?

#

to double check if you really know

rotund ferry
#

EMBED_LINKS

sinful lotus
#

ok good but you dont check it on the beginning

#

if you send embeds that could be "one" of the issue

#

so just run a quick view on all your code because that kind of errors will not show you a stack trace of where in code

rotund ferry
#

Not thats not in I already checked

sinful lotus
#

your code wont throw error

#

if you check properly

robust breach
#

why don’t you check for every perm you require at the beginning of the message event

sinful lotus
#

but the point is it throws error

#

so you are saying you are right and the code have loose screw on its own?

#

if it throws error it means theres something wrong

#

it wont throw error for no reason

rotund ferry
#

@robust breach Because My bot doesn't need al the permissons if I just won't the send a message

sinful lotus
#

and what I meant by quick view not only on message event

#

check the whole code

rotund ferry
#

But thanks for the info and I will check all the permissions checks and if the error is still there then I will come back here

sinful lotus
#

to make it quick, if it still errors then you still missed a perm

#

because that will really not throw error if it will not execute something that it doesnt have the perms to do so

rotund ferry
#

If i look at the error message I has to be a permissions problem

#

Yes I know but thats the think I don't understand my bot is in 550+ server and the bot works fine but the error will only happens on some new server (rarely)

robust breach
#

My bot errors when somebody takes perms away from it having already used a command and tries to click one of the reactions

#

could be something ridiculous like that

rotund ferry
#

Yes I was thinking I that can happens

#

Because maybe it's that

robust breach
#

if it’s not 100% reproducible on your end it might be something like that

rotund ferry
#

Still I'm gonna rebuild the permissions checks

robust breach
#

good idea

viral spade
#

what permission do i need to be able to assign roles to members? i have the manage_roles but it seems to only let me create or edit a role, not assign.

sinful lotus
#

manage_roles does that

#

unless your bot is lower than role u want to assign

rotund ferry
#

Jep

viral spade
#

i see thnaks

#

can i check if role is lower or not using the order that i retrieve from guild.roles?

rotund ferry
#

Yes you can check that

viral spade
#

neat thanks

rotund ferry
#

the .comparePositionTo(role) is also something to look at

earnest phoenix
#

Can someone help me fix this issue please

SyntaxError: Unexpected token )
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:283:19)

  • VV - Bot Stopped - VV -
    Press any key to continue . . .
onyx mulch
#

SyntaxError: Unexpected token )
at new Script (vm.js:79:7)

earnest phoenix
mossy vine
#

did you try deleting the comma?

earnest phoenix
#

Yes the red mark moves.

#

to the thing before it.

mossy vine
#

can you send your whole code minus the things like your token?

hushed berry
#

It's likely you missed a brace somewhere

#

or smth like that

earnest phoenix
#

Here or PM? @mossy vine

hushed berry
#

here please

mossy vine
#

here so if i cant help someone else can

hushed berry
#

^

earnest phoenix
#

const bot = new Discord.Client({disableEveryone: true});

bot.on("ready", async () => {
    console.log(`${bot.user.username} is online!`)
});

bot.on('guildCreate', guild => {

bot.on('guildDelete'), guild => {

bot.on('guildMemberAdd', member => {
  let guild = member.guild;
  guild.defaultChannel.sendMessage('Please Welcome ${member.user.username} to the guild!');
});




bot.login(TOKEN)

hushed berry
#

Yep

mossy vine
#

oh theres a bunch of syntax stuff there

#

and you are using deprecated functions as well

hushed berry
#

The guildDelete listener

#

Half of it is missing

mossy vine
#

same with guildCreate

hushed berry
#

lul

mossy vine
#

and the guildDelete is not even

#

what the

#

what guide are you using?

earnest phoenix
#

I guess not a good one lOL

mossy vine
#

yeah. seems to be old since guild.defaultChannel has been deprecated for a long time

earnest phoenix
#

I had a feeling it was wrong.

hushed berry
#

Yeah

#

default channels are not a strongly enforced concept on discord anymore

#

servers are not guaranteed to have one

mossy vine
#

they dont even exist on discord anymore

#

it used to refer to the undeletable #general channel in servers which is not a thing anymore

hushed berry
#

They definitely still exist

#

Discord definitely still sends them

mossy vine
#

huh

hushed berry
#

but they just don't function like they did before

mossy vine
#

yeah thats what i basically meant

hushed berry
#

It can just be misleading cos it might actually work in your server

#

and then after you've built your entire bot around it, you find that not every server actually has one 😂

earnest phoenix
#

I have a question
I work with Node.js and can not get bann and kick. Can someone help me?

dusky marsh
#

There are plenty of tutorials for that online, it's pretty simple.

earnest phoenix
#

how do i start with sqlite? do i do const bDB = new sqlite3(CREATE NEW TABLE IF NOT EXISTS blacklist (id INTEGER, author INTEGER)?

sinful lotus
#

Im not that proficient on sqlite but the docs can help you a lot

#

well if you can understand java a bit then wait a sec

#

first of all you create a table if it doesnt exists, so after you create one thats when you modify it

#

for ease of access you can download an sqlite program of some sort

#

and add the tables and just modify it

earnest phoenix
#

hm

sinful lotus
#

let me just look if I still have that program

#

then after that all you need to do is to use the statement as shown here to update the parameters of the db

#

guild_id and prefix are the rows if Im correct in my db

earnest phoenix
#

hm

dusky marsh
#

Yeah just follow a tutorial

#

SQLite is very easy

uneven wren
#

@earnest phoenix

Put these two lines at the beginning of your code

sql.open("./database.sqlite");```

Put this when a user types something

```sql.get(`SELECT * FROM tablename WHERE userId ="${msg.author.id}"`).then(row => { 
    if (!row) 
      {
  sql.run("INSERT INTO tablename (userId, item1, item2) VALUES (?, ?, ?)", [msg.author.id, 0, 0]);
      } 
  }).catch(() => {
    console.error;
    sql.run("CREATE TABLE IF NOT EXISTS tablename (userId TEXT, item1 INTEGER, item2 INTEGER)").then(() => {
 sql.run("INSERT INTO tablename (userId, item1, item2) VALUES (?, ?, ?)", [msg.author.id, 0, 0]);
    });  
    });

You do not have to create a sql file, the code will create it for you as long as there are write permissions on the folder location

#

This is literally the most confusing sql syntax you will (probably) have to use in your code, it gets easy once its set up

earnest phoenix
#

the only reason im using sql is to make a blacklist system for servers and users

uneven wren
#

obviously you can add or subtract as many items to the db as needed. This code inserts 3

earnest phoenix
#

hm

#

ok is it better to use json like i do now? As long as I can add users and servers to blacklist

uneven wren
#

so you'll want to do something more like this

sql.run("INSERT INTO guildblacklist (guildid, blacklisted) VALUES (?, ?)", [${administrator_inputted_text}, 0]);

where administrator_insterted_text is the guildid that you would have input

earnest phoenix
#

hm

uneven wren
#

the problem with json is that it can crash and fail, and delete itself

earnest phoenix
#

oh

uneven wren
#

all it takes is two data changes going through at the same time

#

and poof

earnest phoenix
#

o

uneven wren
#

json is fine if you're the only one manually changing stuff, but if it's a public bot and many people get to use a command that will change data in the json, there's a possibility your bot will crash and you'll lose all the data in the json

#

If you're the only one working with the blacklist you can even cheese and just hardcode the guildid's manually into an array

kind wyvern
#

ping

#

there in control panel but not deleting

earnest phoenix
#

um

#

help

#

nvm

#

no need

simple flint
#

Just looking for a bit of advice. My bot just got rejected for not sending a response after the initial setup command. Now it 100% does because I've just tested it in 4 other servers. My assumption is that the channel where the command was called the bot didn't have permission to reply there.
How would you guys get round this?
Check permissions on channel and then reply in DM, reply in first writable channel or change the permissions on the bot invite?

late hill
#

I'd imagine that they know what they're doing and their testing server would allow your bot to send messages

#

But if this does occur it would probably be best to DM

simple flint
#

yea I would of thought so too but I can't get any feedback, logs show it tried to send a message and I can't reproduce it

#

So that the only other thing I can think of is it couldn't reply to that channel

kind wyvern
mossy vine
#

@kind wyvern try running it just as python -m pip ... or py -m pip...

wide ruin
#

what languages have discord support?

hushed berry
#

most of em

dusky marsh
#

Even a few obscure ones, so chances are, there is a framework for your language of choice.

stuck lion
#

hi

#

me and my bot a Discord Bots?

smoky spire
#

What?

knotty steeple
#

@earnest phoenix

#
  1. sql.get(SELECT * FROM tablename WHERE userId ="${msg.author.id}") dont use this syntax
earnest phoenix
#

WhAt

#

Ok

#

Why not tho

knotty steeple
#
  1. use better-sqlite3
amber fractal
#

Thats a good tip

#

Much faster

knotty steeple
#

SQL injection is a code injection technique, used to attack data-driven applications, in which nefarious SQL statements are inserted into an entry field for execution (e.g. to dump the database contents to the attacker). SQL injection must exploit a security vulnerability i...

#

@earnest phoenix

earnest phoenix
#

Wow

#

So, if people does -blacklist SELECT * FROM blacklist DELETE on my bot, would they delete all Blacklisted users?

knotty steeple
#

thats not the syntax for it mmLol

earnest phoenix
#

depends how your query looks like

knotty steeple
#

basically yes

#

i always use parameterized queries GWqlabsMmLol

uneven wren
#

1. sql.get(SELECT * FROM tablename WHERE userId ="${msg.author.id}") dont use this syntax

@knotty steeple

What do you suggest to use? or do I need to update sqlite?
I don't believe I have sqlite3 because it broke everything and my bot was working just fine without it anyway

knotty steeple
#

did you look at any message i sent besides that

uneven wren
#

im asking if it's a sqlite3 vs sqlite isssue

#

<-- btw fairly new to programming so it's more of a "how can i improve" rather than a "i disagree" question.

knotty steeple
#

What do you suggest to use? or do I need to update sqlite? I don't believe I have sqlite3 because it broke everything and my bot was working just fine without it anyway its more than that

#

so are you saying you have outdated sqlite

uneven wren
#

Yes. Because my OS wasn't accepting it. I've since updated my OS, but terrified of trying to install sqlite3 again because it wrecked everything for like 3 or 4 hours before I could figure it out again

knotty steeple
#

home hosting Thonk

#

just backup ur shit and update it

uneven wren
#

thats scary tho I might in the future. Atm everything is working properly so I don't want to fiddle with it yet.
Although if for some reason one of my bots gets very popular I'd just switch to online hosting anyway