#development
1 messages · Page 582 of 1
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)
be a good idea
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))
yea, @mossy vine im interested in probably AI, and making a career out of it
@wide ruin afaik, C++, for example, is language with the most performance
what do you use it for?
@fiery quest Any Errors?
is it more games and stuff
nope, works fine the program
Yeah, C++ is widely used in videogames, I believe
but it doesnt show the server counters on discord bot page, still N/A
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?
c++ is extremely lowlevel, don't take it as your first language
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
because the gdpr are a thing
@fiery quest I would honestly recommend doing manual HTTP requests with aiohttp instead
dblpy is outdated
@slender thistle so what can i do?
python or java script then?
ok
that said js if you want to c# later, but still up to you
check out python's and javascript's syntax and pick whatever suits you more
js and c# share some aspects but that's strictly with keywords, how they function is nowhere near the same
there are great javascript resources pinned in this channel
i also reccommend w3schools.com and sololearn.com
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
ok, so using the following link : https://discordbots.org/api i'll send a header content my api token, right? @slender thistle
obv with /bots/botid/stats, i think
at the end
Yep, but replace botid with your bot ID
yesyes
And also add 'Authorization': 'application/json' in your header
oh, ok, so after that i could be able to see servers counter on my html page right?
should*
Should be able to
shivaco M.Today at 8:31 PM
And also add 'Authorization': 'application/json' in your header
Content-Type*
Oh, whoops
Auth will be DBL token
When was the last time I worked with headers, I wonder 
@slender thistle @mossy vine Where should I write my code then, I hard visual studio code is good
I mean, you could go with Sublime Text or Visual Studio Code
i personally reccommend visual studio code. its lightweight, has many extensions, and is customizable to your liking
or literally anything that you want
first you should download the tools required to use the language you chose
I already got vs code on here, so I ll just use that
it's a personal preference
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 👆
I'm pretty sure it just sees them as regular emojis
try console.logging them
it seems them as unicode
hey guys does anyone have any ideas on sharding a bot between different hosts
@misty anvil I'm doing that rn
What does it even mean tho
I'm guessing separately a bot's shards across multiple machines
Ah
wdym
like what language
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?
Could someone teach me how to customize my "page" in dbl?
Introducing: HTML and CSS
thank you
.hasPermission
that finds the role tho i thought
no
ok
https://goo.gl/z2r8SY
discord.js
More information about the command can be found here
ok
thanks
@night imp
if (message.author.hasPermission('ADMINISTRATOR') === false) return message.channel.send('No')
well
I think hasPermission checks admin by default unless you disable it
Well for users
@modern sable Can i test a command in here?
oh ty
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.
if(command === "duo") {
Message.channel.send("$user do you accept the duo by $user?");
}
Command Is Not Defined Error.
Then command isnt defined
How do I define it?
Do you know what language you're writing this bot in
.JS
Yes.
Because defining variables is usually the first thing you learn
(o/o)
({})
?
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.
Of course of course, I wouldnt make such a big deal over it. https://www.w3schools.com/js/js_variables.asp
Have fun
Dude it's literally in there
👋 You are an amazing person that deserves all the help I offer. Now have fun creating your bot
You offered no help but a link.
The link is useless info or I would have gone there myself.
Well the issue was that command was not defined, you never made a variable called command. I'd say that link is pretty useful.
hi @earnest phoenix read rules 1 and 7 kthx
yea maybe he will over the next 2 hrs, dw
ah
my bot got muted and i fixed the issue, what do i do to get it unmuted
DM(offline) or ping the mod (online) who muted it
what do you mean by offline and online?
DM if the mod is offline currently ping if they are online
should i ping in here
Or another mod may be able to look at it that's just what I was told before
and what should i say
I fixed my issue with bot @opal zinc could you please unmute it?
Ig
???
I guess
ok
ok
Help me
Ok
yeah i cant help with python
😦
@oblique gulch
Cogs (classes) must subclass commands.Cog
I see you like Neffex too
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
can you send a example?
Literally class Test(commands.Cog):
Your Test class will be a subclass of commands.Cog
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
You must make all of your cogs derive from commands.Cog (subclass, like you did just now)
Yep
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)```
@oblique gulch all listeners in cogs must have a commands.Cog.listener() decorator
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
i'm noob in python sorry
Look up in Google what Python decorators look like
Well that's unfortunate because d.py is not really beginner-friendly
fuck
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?
Hi
how can i set this http://prntscr.com/mszdoo any help 😕
I don't know how anyone could explain it better.
There's an API endpoint and a token, just POST to it...
but where i post it
😕
can u send me pictures of to that work
I dont speak english i use google translate when i read this :/
What discord library are you using @earnest phoenix
You don’t know how to make a POST request?!
it's easier than using a discord lib, tbh
Yeah
@dusky marsh js
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
But where to paste that code
dont spoonfeed
Oops
is it healthy for an sqlite database to be spammed with SELECT 3 times at once, lets say, when the user joins some server?
I think sqlite databases can handle up to some 30000 interactions or something like that at once
@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
that's still quite vague to me, does this mean they can't commit at once or just doing any general writing?
I think sqlite pools does some funky stuff to allow more than one write, havent looked into it completely tho
3 selects at once are nothing
if they only use primary key it's even more insignificant
but what about the writing part?
only one can write at once, but for most cases the write happens too fast for the lock to be noticeable
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
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
@earnest phoenix store their permission level somewhere
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...
...```
in a json @amber fractal
if they arent in the json, they dont have that permission level
oh
but not even one message sends
In the json, make the perms the number as the key
Let me make an example
the bot responds to its own message
Help i'm just getting pinged over and over again now please help
so how do you do it
you can just return; if the message author is a bot
just at the beginning
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
<User>.bot is a boolean for whether the user is a bot use that and just stop if it is
dont create a discord bot while you learn

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
{
"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
Oh wait
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
doesnt make a difference dvrx
the perm level thing confuses me
my team and i are now struggling to get a bot done
its better that u learn
I think I misunderstood
like, this https://geedees.succ.world/i/ybz4.png
i regret starting it but i'm somehow still coding
what you meant
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
You can just check if their id matches any of them in the array for the permission that you want them to have
look in #starboard -_-
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
hm
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
thats my goal
but im too retarded
idk how
i suck with SQL, maps and stuff like that
its not even that hard
Then learn them
its same as exports.run
but you change the run into a property instead of a function
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
hm
// 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
sorry, but thats not the kind of permissions im talking about
same logic
hm
same logic but simpler
that would return a boolean
if(exports.perms = true) {
command
}
// 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
then add the admins on the array of your config.admins
i did that
didnt you understand what you coded?
i did
config.admins is an array of your admins since I saw you used .includes
so BOT_OWNER is the perm "variable" of the command
"BOT_OWNER" is just a variable to instruct the command handler to look for config.admins 
read the code pls
BOT_OWNER is the owners ID, but I want to use IDs in case I get falsely banned from discord again
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 
hm
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
anyone know if its possible to log in a bot in a user account instead of as a bot?
thats against TOS and we would not teach you how to do it
so it's possible? lol
it is possible but you are on your own, and we are not liable if you get ip banned of some sort
I'm too retarded to figure out how to do it anyway lmao
@earnest phoenix well doesnt matter, we wouldnt tell you anyways
he said that already no need to ping
And you still pursued.
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
hardly lmao
i find no results on internet
This type of logging would easily get you ratelimited
"creted" might be the problem
created* dont look at the syntax, im not english, sorry
when using guildmemberadd, is it message.guild.id that is the guild ID?
there is no such thing as message in the params of the guildmemberadd
member is

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 😃
As a beginner, maybe. But you should define the prefix in a seperate variable
Well that shouldnt be a command handler either way imo
yeah
@amber fractal I am a beginner, so I'm trying to do it in a simple way for now
Thanks!
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?
var is function scoped, let is lexically scoped
I see. I’ve been using let thinking it was function scoped. Thanks
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
I want to design my bot page how can i do that?
html and css
Any docs?
google is your friend
Docs on how to impliment it in my bot page..
just use html and css
@quasi stirrup
@earnest phoenix ya?
Yes i will
you don't have to buy a domain haha
Lol
so in links you usually replaces spaces with %20
what are those %number things called?
nevermind got it http://krypted.com/utilities/html-encoding-reference/
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
Listen for member joins
If it's in your server
Assign the role
if they are on the list ofc
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
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
Replace these member.guild.roles.find(role => role.name === "eveREEone")
With just the id of the role
As a string
member.guild.roles.find(role => role.name === "eveREEone").id would work as well.
is rethinkdb good for economy?
Can someone help me program my bot.
Its my first time making one and i need help
You should learn a programming language first. There are many websites where you can learn
Could i get a link to one possibly?
I heard a lot about codecademy
Any reason why my bot would start responding twice randomly? I didn't change anything or restart anything
or heroku
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?
He awaits eval
Ya
It doesn't do anything.
Ive had that bigger chunks of code
Managed to send back empty results
Cause it wouldn't wait for the eval result
Yes because it makes no difference
Doesn’t eval return a promise though? or am I just confused again
Alright
I believe so but not sure 100%
if the code in the eval returns one, it will
const promise = eval('Promise.resolve(1)')
anyone know how i can set on a background image the opacity? beacause i add {opacity: 0.5 ;}
but it take all the div*
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
Are you in a python virtual environment
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
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
I shall intervene and say no
Unless you want to suggest the old version of the library
pip install -U git+https://github.com/Rapptz/discord.py@rewrite#egg=discord.py[voice]
I don't think it matters that much but eh
Compare message content to message author mention
ok
Unless you mean if they mention themselves while using a command
yeah
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
ok
s
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
@bright spear how did you get a background on your html page in bot long description? mine is remaining as white
Yeah I put a ton of css in the long description
@empty owl client.users.get('id')
@sinful lotus can save u here 😛
(implements TextBasedChannel)
Represents a user on Discord.
𝗣𝗿𝗼𝗽𝗲𝗿𝘁𝗶𝗲𝘀: client id username discriminator avatar bot lastMessageID lastMessage `createdTime...
No
ok
he saved me as well
ok
client.users.get(vote.user).username
Yw
yw

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
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.
make it good
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
and worth to support for
So donations then?
yes possibly
A lot of devs have a patreon
And yeah I do make quality stuff. I care about every detail.
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 
Honestly tho, patreon can be good
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?
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
I'm not talking about making it a paid bot 
Just with something to not make it a waste of time
that applies to non paiid and donations
And here I am coding for fun
but tbh I feel I just create my bot on my own preference
But then I thought I'd at least gain something from developing new bots
and users do like it
I don't think users would care to donate
You'd be surprised
Really?
I mean maybe at least with patreon, not traditional donations, just to acknowledge them
If it's a bigger bot, you could list their server or something.
Tbh currently I'm thinking about a very simple bot that I don't think it's worth making premium features and stuff
users would donate if they seem feel the bot is worth it
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.
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
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
what language are u speaking
@late hill Lmao, that was very helpful. i found out anyway, needs perm manage roles
are channel-ids unique per guild or global?
thx
https://goo.gl/UtqtRO
Discord Developer Portal — Documentation — Reference
Integrate your service with Discord — whether it's a bot or a game or your whatever you wildest imagination can come up with.
Read the snowflakes section
Anyone here familiar with Lavalink?
yes
How would I add tracks to the queue?
Pls help
U saying me ?
Ok
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
Check their npm page
wait you dont know how to read the lavalink object?
Tag and ask pls
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"
How I install
why even bother cloning git repositories with code you don't understand if you cant even install a module
I am new
How did you get the bot developers role if you dont even know how to install a module
thats the most basic one
i am a js developer
k
@sinful lotus nah I've watched the github repo but I cant find anything describing that
Thanx for the ||REPLY||
@kind wyvern Show me some of your code
Yeah I looked at that
@slender thistle DM
Any command or whatever
this is what I used for my implementation and I never had problems
look deeper next time
I didnt see this earlier 🤔
@sinful lotus lmaoo u got rickrolled
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' }
Read it maybe?
Where am I supposed to put the certs on my vps
nginx
@amber fractal Thanks i didn't know that i have to read errors
Are you joking?
Yes
I know that is a missing permissions but from where
even I myself is having a hard time tracking those
It tells you exactly what i would
Somewhere you make a request to guilds
life tip: .catch() things
even you catch that you need to track that request
.catch(() => {}) 
Yes the path tells me but I don't know how
All the request I do has a permissions check
tbh
and catch() everything you can
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
Ok thanks @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
I thnk the path is weird
you gotta skim and find what part of code you access a channel
XD thats the point my bots main function is something with channels
then you fix the issue on that regard
@kind wyvern i really hope you found out how to install the module by now
use the rewrite branch
@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);
};
you return message.reply
it means you will still send a message even the bot has no perms on it 
I check that in the message event LOL
yes but you return message.reply
it means the bot will try to send the message on that channel
even it has no perms
But not if i dont have SEND_MESSAGES
if (!message.channel.permissionsFor(client.user.id).has("SEND_MESSAGES")) {
return;
};
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
Your code is saying if you don’t have any permissions send a message, it can’t if it has no perms
so what is the point of checking for perms
if you send a message even it has no perms to send it?
Because I check before if I can send a message
read your code and try to understand what you did
Dude
I already explained the code you sent step by step
I will explain it in more newbie way
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
message.reply() is msg.channel.send()
I think you guys don't understand
with mention
We understand, you don’t.
Zixe are you saying you’re checking SEND_MESSAGES in two separate if statements
the absence of semicolons triggers me :>
I removed it at the rewrite
I use semicolons before
but now I just use it when compiler dont understand what I want
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
then it makes no sense to check again for SEND MESSAGE for the second line
^
@robust breach no I check it ones
you check for send message the first time
No sorry 2
you just said it checks twice
then check it again
change your perm checking into something more "readable"
that don't checking anythink
then it’s one of the other perms you aren’t checking for
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
I also check in events for permissions if needed
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
@rotund ferry you’re probably doing something before the permissions check that is erroring it
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.
Thats the why I double check for send permissions
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
The first is channel based and second is server based
but thats useless if you can just return on global 👀
O my god did you read what i'm typing
you said one is channel 2nd is server based
the global is useless
channel overrides everything
The first code is in aa command end the second is in the message event
its better to check for channel than global for send messages, embed, and other stuff
I dont and I will check it
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
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
I know that and thanks for telling
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
embeds also needs perms just incase you wonder
you’re checking for perms in two separate spots but you’re only checking for send_messages at the beginning
I know embeds need permissions
EMBED_LINKS
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
Not thats not in I already checked
why don’t you check for every perm you require at the beginning of the message event
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
@robust breach Because My bot doesn't need al the permissons if I just won't the send a message
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
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
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)
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
if it’s not 100% reproducible on your end it might be something like that
Still I'm gonna rebuild the permissions checks
good idea
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.
Jep
i see thnaks
can i check if role is lower or not using the order that i retrieve from guild.roles?
Yes you can check that
neat thanks
the .comparePositionTo(role) is also something to look at
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 . . .
SyntaxError: Unexpected token )
at new Script (vm.js:79:7)
I have a red mark at the end I can't seem to fix.
did you try deleting the comma?
can you send your whole code minus the things like your token?
Here or PM? @mossy vine
here please
here so if i cant help someone else can
^
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)
Yep
oh theres a bunch of syntax stuff there
and you are using deprecated functions as well
same with guildCreate
lul
I guess not a good one lOL
yeah. seems to be old since guild.defaultChannel has been deprecated for a long time
I had a feeling it was wrong.
Yeah
default channels are not a strongly enforced concept on discord anymore
servers are not guaranteed to have one
they dont even exist on discord anymore
it used to refer to the undeletable #general channel in servers which is not a thing anymore
huh
but they just don't function like they did before
yeah thats what i basically meant
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 😂
I have a question
I work with Node.js and can not get bann and kick. Can someone help me?
There are plenty of tutorials for that online, it's pretty simple.
how do i start with sqlite? do i do const bDB = new sqlite3(CREATE NEW TABLE IF NOT EXISTS blacklist (id INTEGER, author INTEGER)?
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
hm
let me just look if I still have that program
https://sqlitebrowser.org/dl/ basically grab this one
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
it would look like this if it successfully set
although its better if you read more about sql here http://www.sqlitetutorial.net/what-is-sqlite/
hm
@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
the only reason im using sql is to make a blacklist system for servers and users
ok so change msg.author.id to whatever you need to use for guilds
obviously you can add or subtract as many items to the db as needed. This code inserts 3
hm
ok is it better to use json like i do now? As long as I can add users and servers to blacklist
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
hm
the problem with json is that it can crash and fail, and delete itself
oh
o
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
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?
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
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
python3 -m pip install -U discord.py
using this still i add it to path too
@kind wyvern try running it just as python -m pip ... or py -m pip...
what languages have discord support?
most of em
Even a few obscure ones, so chances are, there is a framework for your language of choice.
What?
@earnest phoenix
sql.get(SELECT * FROM tablename WHERE userId ="${msg.author.id}")dont use this syntax
- use better-sqlite3
@earnest phoenix

Wow
So, if people does -blacklist SELECT * FROM blacklist DELETE on my bot, would they delete all Blacklisted users?
thats not the syntax for it 
depends how your query looks like
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
did you look at any message i sent besides that
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.
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
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
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
