#development
1 messages Β· Page 1193 of 1
async function api(url){
let getURL = async () => {
let response = await axios.get(url);
let url = response.data;
return url;
};
var urlValue = await getURL();
return urlValue
}
if (command == 'test'){
var send = api('https://hypixel-api.inventivetalent.org/api/skyblock/bosstimer/magma/estimatedSpawn')
message.channel.send(send.estimate)
}```
how can i make this work?
there is no errors at the same time it doesnt send anything
.catch() is a function part of the Promise Object. when something returns or throws an ERROR. the catch function is tried to be called
if you don't want to do that you will need to do your own edge casing
using a debugger can also help you
.catch()is a function part of the Promise Object. when something returns or throws an ERROR. the catch function is tried to be calledif you don't want to do that you will need to do your own edge casing
@plush magnet I had solved that problem already by removing thevarand replacing it on the top so it wont get scope block
again you can remove one line of code by simpty returning the await
from this
let getURL = async () => {
let response = await axios.get(url);
let url = response.data;
return url;
};
var urlValue = await getURL();
return urlValue
}
to this
let getURL = async () => {
let response = await axios.get(url);
return response.data;
};
var urlValue = await getURL();
return urlValue
}
its just simple things like that that can make code sections much shorter
also if you have declared url with var just pass it through the getURL function like this
let getURL = async (URL) => {
let response = await axios.get(URL);
return response.data;
};
var urlValue = await getURL(url);
return urlValue;
}
hey can someone help me with some errors i am having while pushing my bot to heroku? Traceback (most recent call last):
2020-08-27T09:32:31.676478+00:00 app[worker.1]: File "bot.py", line 5, in <module>
2020-08-27T09:32:31.676479+00:00 app[worker.1]: from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackQueryHandler, Defaults,
2020-08-27T09:32:31.676479+00:00 app[worker.1]: ModuleNotFoundError: No module named 'telegram'
theres no module named telegram found
do you know why my server count don't work ?
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = 'ey.......WIO1Ra-M5JslLg8'
self.dblpy = dbl.DBLClient(self.bot, self.token)
@tasks.loop(minutes=30.0)
async def update_stats(self):
"""This function runs every 30 minutes to automatically update your server count"""
logger.info('Attempting to post server count')
try:
await self.dblpy.post_guild_count()
logger.info('Posted server count ({})'.format(self.dblpy.guild_count()))
except Exception as e:
logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(TopGG(bot))```
it doesn't do anything
did you run it inside the directory where your bot is ran
also idk anything related to python code wise so I cant help there
okay, but thanks for trying to help tho π
yeah I ran in my py file with my bot
can someone tell me a good host for 24/7
@earnest phoenix heroku
kk
async function api(url){
console.log(url)
let getURL = async (URL) => {
let response = await axios.get(URL);
return response.data;
};
var urlValue = await getURL(url);
return urlValue;
}
if (command == 'test'){
var send = api('https://hypixel-api.inventivetalent.org/api/skyblock/bosstimer/magma/estimatedSpawn')
message.channel.send(send)
}
just buy a raspberry pi
@carmine summit lowercase url here for the function let getURL = async (URL) => {
that should work
@leaden lake You're not .starting the task
Put update_stats.start() at the bottom of the init function
Is heroku 24/7 free?
Is heroku 24/7 free?
@violet maple yeah
for only 1 bot. You got 1 000 hours free per month
I typed lmao
TypeError: invalid arg type the url argument must be tye of string
@carmine summit at what line
@slender thistle so my line must be here ? def __init__(self, bot): self.bot = bot self.token = 'e........1Ra-M5JslLg8' self.dblpy = dbl.DBLClient(self.bot, self.token) update_stats.start()
yeah
Should be, as long as cache isn't involved
But that's easily bypassed with query parameters in the URL
@carmine summit at what line
@plush magnet dont know/ doesnt say
after 30minutes it will print the number of servers ?
well
if you have logging with the logging module enabled, yes
or you could use print
@carmine summit can you send me an image of the error?
in your bot's main file
yes, I only have 1 file
at let response = await axios.get(URL); i think
idk how this library works
@carmine summit is the url being logged?
logged?
you have console.log(url)
so is the url appearing in the terminal or is it printing undefined
why does it affect it lol
nono just so I know
its appering in terminal
can you show me your current code?
idk how this library works
@leaden lake You should usebot.add_cog(https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.add_cog) on theTopGGclass directly and remove thesetupfunction
and you could replace logger.info with print and not use the logging module
async function api(url){
console.log(url)
let getURL = async (url) => {
let response = await axios.get(URL);
return response.data;
};
var urlValue = await getURL(url);
return urlValue;
}
if (command == 'test'){
var send = api('https://hypixel-api.inventivetalent.org/api/skyblock/bosstimer/magma/estimatedSpawn')
message.channel.send(send)
}```
Also no need for the getURL function
async function api(url)
{
let response = await axios.get(url);
return response.data;
}```
yeah but they havent declared URL as a module? so it doesnt batter
It's default.
from what
Big Brain
they haven't imported it though?
*me sitting here confused...
yeah but they havent declared URL as a module? so it doesnt batter
nah that's not the same thing
Why it dosent work?
what doesn't work exactly
I don't recall the word but it's globally accessible in node.
built-in?
I guess
the embed
Same error?
yeah just set the urls to lowercase or whatever
What about the embed
then the return is nothing
show errors if there are any
shouldnt it respond with unhandled promise as text
that's only if there's an error
It should also return an error when trying to send.
Something to do with an empty message
let send = await api(url);
works perfectly. Thank you π
Alright nvm
Exception has occurred: ImportError
cannot import name 'Update' from 'telegram' (unknown location)
File "D:\coding\ReemBot\bot.py", line 5, in <module>
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackQueryHandler, Defaults, \
what is this issue?
python -m pip install python-telegram-bot
i have ran this code
everything should be installed
but instead it is giving me this error
god help
yeh, i am back
Where even is "Update" grabbed from that import?
import logging
import db
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackQueryHandler, Defaults,
PicklePersistence, ConversationHandler
from telegram import InlineKeyboardButton, InlineKeyboardMarkup, ReplyKeyboardMarkup, ParseMode,
ReplyKeyboardRemove
from this
There is updater not update
yes but are you running the pip in the correct sub folder
or is python using global stuff
cause I know npm installs modules into the main bots folder
but again idk hopw python works
yess
but i get another error now π
Exception has occurred: ImportError
cannot import name 'Update' from 'telegram' (C:\Users\bilal\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telegram_init_.py)
File "C:\Users\bilal\Desktop\Χ§ΧΧ ΧΧΧ bot\ReemBot\bot.py", line 5, in <module>
from telegram.ext import Update, Updater, CommandHandler, MessageHandler, Filters, CallbackQueryHandler, Defaults, \
You got the same error...
Can you send me the link to this module?
no it fisrt gave me the unknown location
Just check the docs
it exists
In the source code, __init__ does import Update so eh
Try importing Update from telegram.update instead
Ofc it does why would it be normal
ffs this is killing me
it was working yesterday
just out of the sudden it stopped working
function randomstatus() {
let status = ["BOGSCAM", "Prefix = b!", "Golf Blitz", "BOGSCAM's Cave"]
let rstatus = Math.floor(Math.random() * status.length);
client.user.setActivity(status[rstatus], {type: "STREAMING", url: "https://www.twitch.tv/bogscam"});
}; setInterval(randomstatus, 300000)
console.log('Logged in as BOGSCAM!')
})```
Ξ add this to my code it is no error my bot becomes online but the status is not set
thanks for the ping mr bog
Pls help @slender thistle
I'm not proficient in JS
@eternal osprey What's the version of your python-telegram-bot package
well firstly it should be changing every 5 minutes
message.channel.send(Pong! Latency is ${Math.round(client.ping)}ms)
^
ReferenceError: client is not defined
eeee
Any idea why my bot isn't reacting at all when I start it?
Doesn't appear as online
No errors, warnings or messages in console
can you read the error
python-telegram-bot==12.8\
Interesting
telegram== 0,02
telegram==0.0.1
oops
remove it from your requirements.txt I guess if not that
@earnest phoenix secondly this needs to be changed since length counts from 1 not zero let rstatus = Math.floor(Math.random() * status.length - 1);
What the fuck is that telegram package anyway
i am now at square 1
now it gives me the unknown location error again
i will fucking remove python-telegram-bot package
and install it again
it is running
this is a miracle
IT IS RUNNING
LETSS GOOOOO
oh floor returns a lower value thats right
took you long enough XD
AttributeError: module 'dbl' has no attribute 'DBLClient'
yeah I have, and I just installed 2h ago
my code ```import dbl
import discord
from discord.ext import commands, tasks
import asyncio
import logging
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, client):
self.bot = client
self.token = 'ey.......Ra-M5JslLg8'
self.dblpy = dbl.DBLClient(self.bot, self.token)
update_stats.start()
#self.bot.loop.create_task(self.update_stats())
@commands.Cog.listener()
async def on_ready(self):
print("Cog chargΓ© !")
@tasks.loop(minutes=3.0)
async def update_stats(self):
"""This function runs every 30 minutes to automatically update your server count"""
logger.info('Attempting to post server count')
try:
await self.dblpy.post_guild_count()
logger.info('Posted server count ({})'.format(self.dblpy.guild_count()))
except Exception as e:
logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
def setup(client):
global logger
logger = logging.getLogger('bot')
client.add_cog(TopGG(client))
Does the yeah I have part refer to Do you have any files/folders named "dbl"?
and what about your bot's folder
Hello
Some websites makes this thing where you login and have access to their dashboard
how do they do the login thing?
Discord OAuth
@leaden lake pip show dblpy
Name: dblpy
Version: 0.3.4
Summary: A simple API wrapper for top.gg written in Python
Home-page: https://github.com/DiscordBotList/DBL-Python-Library
Author: Assanali Mukhanov, top.gg
Author-email: shivaco.osu@gmail.com
License: MIT
Location: c:\users\shaal0wfr\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages
Requires: ratelimiter, aiohttp
Required-by:
Hamoodi, what's the library you mainly use?
https://discordjs.guide/oauth2/ this may be helpful
nah that's exactly what I asked
??
Try print(dbl) after you import it
Okay, thanks!.
@slender thistle <module 'dbl' from 'C:\\Users\\Shaal0wFR\\AppData\\Local\\Programs\\Python\\Python37\\lib\\dbl\\__init__.py'>
then what the fuck is wrong
I still don't understand. My bot isn't starting up with another code (same token, different libraries) or the main bot (same token, same libraries), so it really must be something with the token. I have regenerated and changed it multiple times, still nothing.
Try re-installing dblpy
okay
@robust arrow library and/or code
we can't really help you if you're not giving information on what you are trying to do
what library are you using? where the main code that you use to connect to Discord (please do redact anything sensitive)?
like discord.js v12?
yes
sorry im new
no problem, everyone started from 0 at some point
any samples to show us what code you are running? (screenshots, code snippets?)
@slender thistle Traceback (most recent call last): File "C:\Users\Shaal0wFR\Desktop\Bot Discord\test on Atom.py", line 11, in <module> import dbl File "C:\Users\Shaal0wFR\AppData\Local\Programs\Python\Python37\lib\dbl\__init__.py", line 19, in <module> from .client import DBLClient File "C:\Users\Shaal0wFR\AppData\Local\Programs\Python\Python37\lib\dbl\client.py", line 32, in <module> from .http import HTTPClient File "C:\Users\Shaal0wFR\AppData\Local\Programs\Python\Python37\lib\dbl\http.py", line 33, in <module> from ratelimiter import RateLimiter ModuleNotFoundError: No module named 'ratelimiter'
this is the top of my index file
seems nothing wrong to me, but why are you setting such a high limit for event listeners?
Someone told me it was a good idea on another server
what and why
client.on('debug', dbg => console.log);
can you put this above your client.on('ready')?
client.on('debug', console.log);
it's above client.on('ready') and I saved it, hasn't logged anything yet
@leaden lake pip install ratelimiter
it says already installed
hmm
it's just silent
is the main file called index.js?
yes
nope
successfully installed
but I got this error : NameError: name 'update_stats' is not defined
yeah I know
but I got this error : NameError: name 'update_stats' is not defined
@slender thistle
it works the same
in this case
also @robust arrow that line right after the message listener
self.bot = client
self.token = 'eyJ........1Ra-M5JslLg8'
self.dblpy = dbl.DBLClient(self.bot, self.token)
self.bot.loop.create_task(self.update_stats())```
might cause your account to be banned
self.update_stats
bot account*
what line
the line below the client on message
yeah did you try again with flazepe's code just now?
yeah dont update your presence under the message listener
self.bot = client self.token = 'eyJ........1Ra-M5JslLg8' self.dblpy = dbl.DBLClient(self.bot, self.token) self.bot.loop.create_task(self.update_stats())```
same error @slender thistle
so should I just move the setactivity
yeah, and did you try the debug one with flazepe's code?
client.on('debug', console.log);
this
@pale vessel well actually you're correct
i was brainded for a moment
yes, I've checked it multiple times
yeah ok your bot has been temp-banned
likely because you've hit rate limit
because of the setactivity
check the pins for info about ratelimits
gg
so is the 9000 seconds the duration of the "temp ban"
oh ok
self.bot = client self.token = 'eyJ........1Ra-M5JslLg8' self.dblpy = dbl.DBLClient(self.bot, self.token) self.bot.loop.create_task(self.update_stats())```
Can anyone help me ? it says NameError: name 'update_stats' is not defined
my bot changes status every 5 minutes, it will not reach the rate limit?
so if I have no setactivity, it wouldnt have tempbanned me
no its because you spammed the setactivity
to hit the limit you need to send 1000 IDENTIFY payloads (log ins basically) in a day, how tf did you do that
every time your bot received a message (even its own messages), it will call setactivity once
so effectively when someone chats (like me and you rn), its sending activity updates
86400 Γ 5
bad bad bad
oh
put it in the ready
ok
client.on ready
in it
now you wait XD
is it not reaching rate limit if my bot changes status every 5 mins
so 2 hours it is
is it not reaching rate limit if my bot changes status every 5 mins
thats fine, every minute or so is fine
dgyh's bot hit the global limit
check pins for more info
so like this
yup
thanks alot
#development message
in any decently large server with some active members, each message will take about a second
if they're running commands on your bot, thats 2 messages every command (or even more, depends on how many responses your bot sends to respond)
why you put =>{ and not => {?
nothing happens but ok
bruh
its just a formatting difference
@robust arrow Did you check your emails already? As far as I know you also get an email if you hit that limit
lemme check
why you put
=>{and not=> {?
@cinder sandal I use both
Forbidden: Forbidden (status code: 403)
Traceback (most recent call last):
File "C:\Users\Shaal0wFR\Desktop\Bot Discord\cogs\topgg.py", line 28, in update_stats
await self.dblpy.post_guild_count()
File "C:\Users\Shaal0wFR\AppData\Local\Programs\Python\Python37\lib\dbl\client.py", line 142, in post_guild_count
await self.http.post_guild_count(self.bot_id, self.guild_count(), shard_count, shard_no)
File "C:\Users\Shaal0wFR\AppData\Local\Programs\Python\Python37\lib\dbl\http.py", line 169, in post_guild_count
await self.request('POST', '/bots/{}/stats'.format(bot_id), json=payload)
File "C:\Users\Shaal0wFR\AppData\Local\Programs\Python\Python37\lib\dbl\http.py", line 143, in request
raise errors.Forbidden(resp, data)
dbl.errors.Forbidden: Forbidden (status code: 403)```
No I didn't get an email
ok weird, then I guess you have to wait the 9000 seconds and try again - You should also monitor your bot for permanent restarts
Failed to post server count
Forbidden: Forbidden (status code: 403)
403 means you donβt have access
dgyh its either rate limit or you've hit login limit (super unlikely)
Are you use the right auth headers?
@obtuse jolt ?
Isnβt the login limit like 1,000 or 10,000
yeah if you have an autorestarter
and your code breaks after logging in
it will just restart infinitely
brrrrrr
had that happen to me once already
But they also sent an email saying that my token got reset
Never happened to me
@obtuse jolt does my error says I can't try my code on another bot ?
Thatβs a nice way of sending an email
It is π
@leaden lake if it is a token thing you just have to change the token or auth header token if itβs from an api
Or if they banned you from the api you have to message them
Which could also be a thing
To cause a 403
it's my first try on the API, how to be banned before tried anything π
who knows how to use mongodb
MySQL ftw
Non-relational DBS ftw
who knows how to use mongodb
@forest drift feel free to ask
thanks, so how would i host a database that my bot can add to and read from?
how does it works ? I am on error 404 page
also, if im making a git repository to upload to glitch.com, do i have to include the node.js folder?
also, if im making a git repository to upload to glitch.com, do i have to include the node.js folder?
@forest drift git should only store source code files, or dependency configurations.
so lets say id used heroku and have a .git folder hereoku made that has the up to date code, could i just import that to git?
Git keeps it's versions in "branches" and you can update them with "commits".
So really, you can merge any branches
I'm not sure exactly what you mean by import that to git
Unless you mean GitHub which is a website
so when using heroku it made a .git folder, i wanna know if i can just add that folder to github
Yeah. You can push it to GitHub
i dont think its possible to a mongodb server on glitch
no you don't need to upload your .git on github, it's not necessary
i wanna use mongodb for hosting on heroku, so i can use heroku and still have a database
no you don't need to upload your .git on github, it's not necessary
@leaden lake <-- yeah, just push the branch to GitHub via cli
no you don't need to upload your .git on github, it's not necessary
@leaden lake would i need to upload the node.js folder?
im not sure if you can run a mongodb server on heroku
but mongodb cloud altas is free
for small databases/bots
not a mongoidb server, i wanna use heroku for my bot and use mongodb for hosting its database ;-;
@leaden lake would i need to upload the node.js folder?
@forest drift idk, I don't use node js, i program with python. But you can upload it to be sure
cause i was told heroku cant host internal databases
That's probably correct then
ah ok, so you are planning to use mongodb cloud?
Also if node.js is a folder that's generated while building then you probably don't need it
Since it'll be generated every time you build the project
@forest drift idk, I don't use node js, i program with python. But you can upload it to be sure
@leaden lake so, if i were to be making a github repository, i just upload everything in the bots file except the .git? (*btw i wanna import this github repository to glitch.com
There wouldn't be a need to keep a version control for it
@leaden lake so, if i were to be making a github repository, i just upload everything in the bots file except the .git? (*btw i wanna import this github repository to glitch.com
@forest drift pretty much
ah ok, so you are planning to use mongodb cloud?
@fluid basin well the free version... i just wanna be able to use heroku to host a bot with a database and was told to use mongodb for the database
@leaden lake so, if i were to be making a github repository, i just upload everything in the bots file except the .git? (*btw i wanna import this github repository to glitch.com
@forest drift yes, you don't need to upload the .git. I uploaded all files except the .git on github and all perfectly works on heroku
but i already have coded it for the
const sequelize = new Sequelize('database', 'user', 'password', {
host: 'localhost',
dialect: 'sqlite',
logging: false,
storage: 'database.sqlite',
});
const strvarsave = sequelize.define('strvarsave1', {
name: {
type: Sequelize.STRING,
unique: true,
},
description: Sequelize.STRING,
});
in mind, so how could i convert it so the code still works?
so, anyone can help me for this authorization ?
@forest drift yes, you don't need to upload the .git. I uploaded all files except the .git on github and all perfectly works on heroku
@leaden lake ok
oh rip
idk how this works lmao
converting databases especially from sql to nosql isnt that fun
how can i grow this banner?
add a graph showing their average groth rate
u mean add more things?
no just the size
oh ummmm idk then
ah sah
oh the image at the bottom?
hmmmmm... image manipulation?
Can anyone help me with the API reference ?
Hey, I'm having trouble setting the image at a message embed for author in discord.js latest. I want to get the profile picture of the user that called the command as image, but it does not work with msg.member.displayAvatarURL. Can someone help me?
someone know how to make a random embed command?
wdym with random?
you speak spanish?
no sorry
k
you know how to make my bot send a random embed
What do you mean with "random embed"??
like if you put l!ramdom bot cand send 1 of 3 embeds
what language are you using?
make a random number between 1 and 3, if it is 1 send out the first, and so on...?
ok thx
think u can do it with an int like this: (Math.random() * ((3 - 1) + 1)) + 1
ok
if(!message.guild.me.permissions.has(commandfile.config.perms)){
message.reply(require("../../functions/permissionMiss")(commandfile.config.perms))
}
This line of code got ignored
but checked that the bot doesnt have oerms
hmm java
@spare flicker java or javascript?
2 very different languages
i use visual studio
You don't know what language you are using to give your computer commands?
javascript
you speak spanish?
how do i turn an array full of permissions like KICK_MEMBERS to Kick Members
the only language i use is lua when i was creating a game in roblox
proof I am the dumbest guy in the world
this maybe if (!msg.member.hasPermission("KICK_MEMBERS")) return;
is that ur ip @earnest phoenix ?
@earnest phoenix why you have a golden apple in your logo?
ctx.guild.icon_url i think @drifting wedge
amount of bots?
yes
idk what u mean by that, read the docs
yes
My rob command isn't working and it says TypeError: Cannot read property 'username' of undefined
This is my code: https://hasteb.in/uqaxiwim.js
is that ur ip @earnest phoenix ?
@digital ibex no it's the ip of my repl
dont use repl
@earnest phoenix
it is horrible
and will 100% get your token leaked
and prob get u discord banned
no it wont
ever heard of a .env file?
proof I am the dumbest guy in the world
@earnest phoenix Posting your db's whitelisted IP address?
Can anyone pls help
repl hides env files
Can anyone pls help
@earnest phoenixuser.user.username
or another thing
huh
or another thing
@spare flicker They don't do that anymore
get your bot in 75+ servers
huh
@earnest phoenix what isuser.user?
.setDescription(` ${user.user.username} does not have anything you can rob`);
they do\
then go to dev portal and click verify bot or
u just dont get a badge
ok
Like saying the other people?
You're telling me that user.user is valid?
the object called user has an object property called user which has a username property?
@drifting wedge it π is π a π temporary π host
@earnest phoenix well ur bot is terrible if ull get ur token leaked]
use heroku
if u dont wanna pay
Hmm idk
But i changed it
and i have another error
use heroku
@drifting wedge lmao that is even worse
saying ReferenceError: random is not defined
then define random
repl literally encourage discord bots on their platform. heroku terminated my account for discord bots.
you can't just say something like
console.log(x)
Err: x is not defined
let x = 5
console.log(x)
Output: 5
You have to give random a value
do i have to send 100 claps again saying it is a temporary host
but its ur prob
someone know free hosts pls
you're breaking rule 1 now
someone know free hosts pls
@spare flicker we just talked about three kinda terrible ones
xd
glitch, heroku and repl ig
ok
XD in lowercase looks like you're REALLY sad
lets search youtube
someone know free hosts pls
@spare flicker free hosts = an internet stranger who lets you use their server, but also gets to see everything about your bot. Source code, logs, tokens, etc
Are you sure you want that....?
Self-host
.-.
xd
just get a cheap vps
i only have 0$
VPS are $2-3/mo
youtube pls pay me
ok
which is like $0.07/day
or just leave it on when ur using it
lets search how to win money free
@golden condor uhh i used abc.db to migrate from quick.db to mongodb and it sucks tbh why would i store every single quick.db database and key in a single mongodb collection
by working
how can i count bots
im using py
???
anyone know a Sqlite host thats free?
or somewhere where i can host a Sqlite database
sqlite is a file based db, correct?
yes
@golden condor uhh i used abc.db to migrate from quick.db to mongodb and it sucks tbh why would i store every single quick.db database and key in a single mongodb collection
@earnest phoenix why would you store it all in a single sqlite file
Β―_(γ)_/Β―
So, keep the db file with the bot locally
cant, using heroku as host
@earnest phoenix why would you store it all in an sqlite file
@golden condor you just made me shut up lol
Also i'd prefer if you didn't randomly ping me
cant, using heroku as host
@forest drift And it doesn't let you have store files arbitrarily?
it seems to completely wipe the database after around 10hrs
i ran my bot on heroku for 12 hrs, database wiped, ran it on my pc for 2 days, database safe
use pouch db
use pouch db
@plush magnet literally never heard of that before
heroku has a postgres db
ive already tried using mongodb, but it just wont work at a;;
pouch db is much easier and simple as
does heroku folderscan for "junk"?
Probably resets non-source files
i ran my bot on heroku for 12 hrs, database wiped, ran it on my pc for 2 days, database safe
@forest drift because heroku doesn't write the gh repo, it stores new files in memory and then wipes them after a few it as it restarts after a few hours
so that explains it
I use my own physical server π and it works great
I use my own physical server π and it works greate
@faint prism epic
just use a raspberry pi
^ I use a rasp pi 4
cheap and modular
pouch db is much easier and simple as
@plush magnet would i be easily able to convert my sqlite system to it? and could i then run on heroku?
it reads and saves JSON data
cheap and modular
@plush magnet im trying but strugling :/
goodbye im going to class
im talking about the raspberry pi. its cheap and modular
const sequelize = new Sequelize('database', 'user', 'password', {
host: 'localhost',
dialect: 'sqlite',
logging: false,
storage: 'database.sqlite',
});
const strvarsave = sequelize.define('strvarsave1', {
name: {
type: Sequelize.STRING,
unique: true,
},
description: Sequelize.STRING,
});
take me with you electric
xd
im talking about the raspberry pi. its cheap and modular
@plush magnet i know, i have one right next to me
wha-
whats hard about it then?
why everyone name me electric
then use it instead of heroku
.-.
*well closeish, its on the shelf next to me
why arent you using it then
it's easier to say than electricwolf082
rasp pi is essentially a cheap, lightweight server
cant get it coded, oits been factory wiped, never had software on it
cant get it coded, oits been factory wiped, never had software on it
@forest drift Install a linux dist on it
then install a software onto an sd card
:v
then install raspbian on it
cringe /s
or smth
ok
Nah, use Ubuntu Server 20.04 LTS
anyway, so how would i convert an sqlite system over to pouch db?
Depends on how you implemented it
If you used a factory-design pattern or any DI, and interfaces, it wouldn't be hard
idc about the data ive saved so far, just wondering what id have to alter in the code
do you know how to do JSON objects
If you didnt, have fun refactoring
so goodbye im going to record a video in class
my bot just sends, edits, and reads data from the sqlite database
do you know how to do JSON objects
@plush magnet yes and no?
how would i keep my bot on heroku while having pouch as the database if heroku doesnt support databases
its database is on files not memory
@forest drift because heroku doesn't write the gh repo, it stores new files in memory and then wipes them after a few it as it restarts after a few hours
@golden condor so thats why my bot sometimes just stops mid timer...
do you know how to do JSON objects
@plush magnet JSON is completely different from JS objects
its database is on files not memory
@plush magnet isnt that the same for sqlite?
im not sure I dont use it
Dont use json for a db, it is easily corrupted
eh imma just setup an old motherboard in a server rack to run my bots
JS object:
{
someProperty: someValue
}
JSON string:
{
"someProperty": someValue
}
I said it saves and reads it LIKE JSON data
there is not much difference in the case of JS
I didnt say it IS JSON
I said it saves and reads it LIKE JSON data
@plush magnet the hell
do you...
use JSON for a database
for storing userdata
why would my bot sometimes just stop mid timer when hosted on my pc? it keeps happening every now and again
grabs gun and shoots him
sigh for the love of god
almost asthough its been restarted
imAgInE sToRiNG dAtA As a StrInG???
anyways idk what that issue is
and you should def get that rasp pi working
cause you wont have many limitations
k
for now imma just try find a way to host on heroku with a database hosted somewhere else
how can i count bots
im using py
imAgInE sToRiNG dAtA As a StrInG???
@plush magnet that's just what it's called
@drifting wedge repeating the same question doesn't mean we help
try asking in the discord.py server
for now imma just try find a way to host on heroku with a database hosted somewhere else
@plush magnet if heroku completely resets files every 10hrs, would pouchdb also be reset?
cause it says on the site it syncs to the cloud
Guys can other people host my bot on github if they have some imformation?
GitHub is file storage
what do you mean host
Guys can other people host my bot on github if they have some imformation?
@hazy sparrow yea i think
like use your bot
they can steal it
if you make it public then duh they can use the code
What information?
with the info u put lol
cause its a public repo anyone can see
if your rep is public and your token is there
Like? Tokens?
they can use
@golden condor so thats why my bot sometimes just stops mid timer...
@forest drift yes
there are github scrapers that search repos for discord tokens so def dont push your token up
Its a friend who i trust ;-;
then people will think twice before stealing
then make the repo private
don't make it public if only your friend and you are gonna see it
friends aren't trustable don't share the token
make your repo private and use ENV for using token
Then how do i host it without github knowing it? Heroku btw
are you retarted or what
Also, if you're using git, if you commited your token file at any point and removed it afterwards, it's still in the history
I have no idea
are you retarted or what
@earnest phoenix don't attack others please
you seem like you know nothing about coding
But i should probably put it in another file

im done gl
in d.py how do i check if a channel is a community channel?
@lost herald a "community channel"?
clearly this is your first time round these parts 913
Mhm
And you're trying to delete either a rules or announcements ("community updates") channel
ik
this is a public bot with a command for mass deleting channels in a category, and i wanna check beforehand if there would be an issue
Just try it and catch it silently is one approach π
I don't think it's possible without actually trying to delete the channel
try {}
catch(e) {
if (e.contains('400')
log('Required channed cannot be removed')) }
syntax error grr
wHaT laNGuAgE iS pSuDoCoDe???
python
code that does not work
(pun intended)
(me does not work)
but conveys an idea/concept
im fixing a fuck ton of bugs in my bot lmao
Make small commits
the object i want to store:
{
lol: "lol"
}
storage JSON takes to store the object: 37 bytes
storage sqlite takes to save the object: 82 bytes
storage mongodb takes to save the object: MathError: Integer value cannot exceed 2^32
LET'S ALL MOVE TO JSON DATABASES BABYYYYYYYYY
was wondering based on what auger said
getting the actual error and handling it from there
specially when dealing with api's n shit the errors it may return vary a lot
re trying based on error sounds like a good idea, but i never thought of handling errors dynamically that way
typeof e
msg = await bot.wait_for('message', check=check(ctx), timeout=30)
if msg:
async with aiohttp.ClientSession() as ses:
async with ses.get(url) as response:
await ctx.send(response.status)```
this doesn't work?
What doesn't work about it?
god damn more python
i hate python
What's check
check is what i use to check if the msg is a integer
I hate Python less than I hate the Math class in js
which works
because you are passing ctx to it manually
k
which you're not supposed to do
????????????
if you do know smth works then why ask for help with it
'it just works'
def check(ctx):
author = ctx.message.author
def inner_check(message):
if ctx.message.author != author:
return False
else:
try:
int(message.content)
return True
except AttributeError:
return False
return inner_check```
this works
i'm asking
why doesn't the aiohttp
work
cuz
cuz
it is wrong
duh
where's it wrong
lol
code would you mind
how can i count bots
im using py
?????
Because d.py calls the function you are supposed to provide to the check kwarg
well, tries to.
how can i count bots
im using py
@drifting wedge dude stop repeating the same question if no one is answering
that's not the problem
the problem isn't with the check
ask in discord.py official server someone probably will help
are you sure
For good lord's name code can you stop with the attitude
Is there a way to have multiple websites on one server?
@earnest phoenix So the wait_for works then
oh dear God you return another function
Also through nginx
the object i want to store:
{ lol: "lol" }storage JSON takes to store the object:
37 bytes
storage sqlite takes to save the object:82 bytes
storage mongodb takes to save the object:MathError: Integer value cannot exceed 2^32
LET'S ALL MOVE TO JSON DATABASES BABYYYYYYYYY
thats seriously like comparing apples, oranges and bananas
Are you sure the session doesn't just timeout?
it's the aiohttp
why would my session timeout
i have a check 4 that
if it timeouts i send a msg
Because invalid URL or the webserver took too long to respond
nope
Also through nginx
not sure if nginx can do that but i use expressjs and it does support multiple ports serving multiple websites (not in the same node.js process tho)
@drifting wedge what do you mean by "count bots"?
like get amount of bots
like serverstats bot?
I have another domain set up on it (the conf is in the sites-enabled folder) but it goes to the other site for some reason
in a server or generally any bots the bot sees in all guilds?
<guild>.bots.cache.size
in a server or generally any bots the bot sees in all guilds?
@slender thistle in a server
im doing server info command
oh lol
I forgot who here wasn't familiar with list comprehensions. Was it you, 0Exe?
I have another domain set up on it (the conf is in the sites-enabled folder) but it goes to the other site for some reason
@pure lionhmmmm..... hits up docs
A more appropriate question would be "are you familiar with list comprehensions"- okay
i mean, technically me, but i doubt i was the one you referring to shiv
Yeah not you Erwin, I don't remember explaining list comps to you
@pure lion this might help:
i still wonder if i should give py a try, it seems fairly familiar with js at first glance
basically one-liner list iterations
service* not server
i still wonder if i should give py a try, it seems fairly familiar with js at first glance
at first glance
but you should give it a try
In any case,
@drifting wedge [m for m in guild.members if m.bot]
The code snippet above iterates over guild.members where each element is assigned to variable m. The if m.bot part will only append the element to a new list if the member is a bot
@opal plank py feels really weird if you're coming from C++/JS
@earnest phoenix wouldn't the int() call not being able to parse the string raise a ValueError
@fluid basin how come?
i might also try C# cuz Unity decided to fuck up and remove everything JavaScript related
well many reasons
also isn't this a bit redundant
lol
most of the snippets here use the same if not similar stuff to js. if, elses, functions, returns, the only major difference ive spotted thus far is syntax in general
everything is just... shorter... in general
most of the snippets here use the same if not similar stuff to js. if, elses, functions, returns, the only major difference ive spotted thus far is syntax in general
well the 2 popular discord libraries in the 2 popular languages are OOP
which are they π€
that up there from lite for example
most of the snippets here use the same if not similar stuff to js. if, elses, functions, returns, the only major difference ive spotted thus far is syntax in general
i'll put some flowers on()and{}code blocks graves cuz they're used VERY less in Python
def as function()
var =(comparator) var
if
return
() tuples, [] lists
clearly js and py, I doubt if you can find a language here that has more questions/queries compared to these 2 languages
@sudden geyser no
bd script :^)
py has less questions overall tho
there is no value Error
@sudden geyser yes
because i had to migrate the code to a newer versio
redundant, as in useless
i was able to just pass in author
a code that doesn't error but doesn't help
if thing_what_is_same != author
clearly js and py, I doubt if you can find a language here that has more questions/queries compared to these 2 languages
@fluid basin HTML, CSS
also @opal plank python is synchronous in design, async was only introduced a while ago
HTML is not a programming language
does asyncio exist?
99% if my mongodb connection problems come from process.env.MONGODBPASS returning undefined cuz i fucked up
HTML is not a programming language
@fluid basin you know to cross it out
no error
HTML is not a programming language
@fluid basin It's a markup language, like XML, or YAML
Yeah, asyncio exists
im pretty sure asyncio allows for await n async
but it doesn't execute any of the code
there is no value Error
@earnest phoenix what do you mean? A bit confused.int(something)would raise aValueErrorbut you're checking forAttributeError
@opal plank yeah it is allowed now
int(something)
it is just a new thing in py tho
casting
well not new new but still
how was it done before asyncio though?
who in their right mind will use XML instead of JSON
@earnest phoenix dotnet boys
multithreading/multiprocessing
hmmm i can see that working
import threading
import __future__
two things I'm unfamiliar with 
@earnest phoenix dotnet boys
@faint prism what the hell
.NET is a weird name tbh
well even if its async, theres still have the issue of cpu hogging the threads (for any cpu bound tasks)
if i do import __future__ it'll return undefined
, im a disappointment
similar to js
that's a file format or what
yes, if u mean xml, if .net it is a framework, the file format of .NET is .cs
asynchrnous functionality was added in C++ recently too, so almost everything on C++ runs with several threads
ok @sudden geyser
i replaced that check
with lambda message: message.author == ctx.author
still doesn't work
Show how you use it
newMsg = await bot.wait_for('message', check=lambda message: message.author == ctx.author, timeout=30)
newMsg.content.isdigit() to check if it can be converted into integer instead of having an exception raised
ok
still doesn't solve my problem
just does nothing
at all
no code gets executed
Show the full command
Use hastebin
client.on('ready', () => {
console.log('Discord bot up and running; no issues reported!')
function statusThingy() {
const PossibleStatuses = ['Probably broken', 'The hamsters in my brain are running wild again', 'Find bugs with me please', 'Stop breaking me!!!']
const currentStatus = Math.floor(Math.random()*PossibleStatuses.length)
client.user.setActivity(PossibleStatuses[currentStatus], {type: "CUSTOM_STATUS"} )
}
setInterval(statusThingy, 10000)
})
``` the status isn't working, any idea why?
oh they can't?
Yeah they can't
lol
oh okay
@tough imp
it had an option for that on autofill for that so I just picked it
lol my friend is here
so I just changed the CUSTOM_STATUS thing to PLAYING and it's still not working


hmmmm..... hits up docs
