#development
1 messages · Page 1211 of 1
can i get someone to help me and is wanting to come in to testing 1 vc
can someone help me with this.
vc1 = client.channels.fetch("id here dont mind me :b");
for some reason this doesnt work. can someone tell me how to properly store a voice channel by id in a variable
@ripe wadi
client.channels.cache.get("ID")
@ripe wadi your method works if you add await
ohhh okay
An API should work with all programming languages that support HTTP requests
hm
const client = GphApiClient(process.env.GIPHYTOKEN)
const searchForGif = (gifName) => {
client.search('gifs', {"q": gifName, "limit": 1})
.then((response) => {
var gif = response.data[0].url;
return gif;
})
.catch((err) => {
return err;
})
}
module.exports.searchForGif = searchForGif;```
oh
Searh something, get number of objects and select the property you want
In your case you want the img url I guess
I think theres a guide at giphy

Arg, I got an OFM error again
Why does this happen? What's not being garbage collect? Is what I wonder
author_id = ctx.author.id
guild_id = ctx.guild.id
author = ctx.author
user_id = {"_id": author_id}
if ctx.author == client.user:
return
if ctx.author.bot:
return
if(collection.count_documents({}) == 0):
user_info = {"_id": author_id, "GuildID": guild_id, "Level": 1, "XP": 0}
collection.insert_one(user_info)
if(collection.count_documents(user_id) == 0):
user_info = {"_id": author_id, "GuildID": guild_id, "Level": 1, "XP": 0}
collection.insert_one(user_info)
exp = collection.find(user_id)
for xp in exp:
cur_xp = xp["XP"]
new_xp = cur_xp + 1
collection.update_one({"_id": author_id}, {"$set":{"XP":new_xp}}, upsert=True)
#await ctx.channel.send("1 xp up")
lvl = collection.find(user_id)
for levl in lvl:
lvl_start = levl["Level"]
new_level = lvl_start + 1
if cur_xp >= round(5 * (lvl_start ** 4 / 5)):
collection.update_one({"_id": author_id}, {"$set":{"Level":new_level}}, upsert=True)
await ctx.channel.send(f"{author.name} has leveled up to {new_level}!")``` but its not writing to the db
Uhhhhh
@drifting wedge Your indents are fucked I believe
Yeah they're really fucked
some1 help me pls
@blazing ravine
Send the updated code, 0Exe
with?
@slender thistle 1 sec
@commands.Cog.listener()
async def on_message(self, ctx):
mango_url = "url"
cluster = MongoClient("this is right")
db = cluster["db1"]
collection = db["db1"]
author_id = ctx.author.id
guild_id = ctx.guild.id
author = ctx.author
user_id = {"_id": author_id}
if ctx.author == client.user:
return
if ctx.author.bot:
return
if(collection.count_documents({}) == 0):
user_info = {"_id": author_id, "GuildID": guild_id, "Level": 1, "XP": 0}
collection.insert_one(user_info)
if(collection.count_documents(user_id) == 0):
user_info = {"_id": author_id, "GuildID": guild_id, "Level": 1, "XP": 0}
collection.insert_one(user_info)
exp = collection.find(user_id)
for xp in exp:
cur_xp = xp["XP"]
new_xp = cur_xp + 1
collection.update_one({"_id": author_id}, {"$set":{"XP":new_xp}}, upsert=True)
#await ctx.channel.send("1 xp up")
lvl = collection.find(user_id)
for levl in lvl:
lvl_start = levl["Level"]
new_level = lvl_start + 1
if cur_xp >= round(5 * (lvl_start ** 4 / 5)):
collection.update_one({"_id": author_id}, {"$set":{"Level":new_level}}, upsert=True)
await ctx.channel.send(f"{author.name} has leveled up to {new_level}!")```
its in a cog
btw
Are you...
creating a client on each sent message?
I'd suggest attacking one MongoClient, attach it to the bot object as a property and then use that property
And you are creating pointless clients instead of using just one
wdym?
cluster = MongoClient("this is right")
db = cluster["db1"]
collection = db["db1"]
This is in your on_message, so you are creating a new MongoClient each time a message is sent
I'd suggest attacking one MongoClient, attach it to the bot object as a property and then use that property
@slender thistle
so make it global?
ok
In your bot's main file,
bot = commands.Bot(...)
db = MongoClient()
bot.col = db["db1"]["db1"]```
Then, in the cog, use self.bot.col
You could use also find_one instead of iterating over returned value from .find
1 sec
@slender thistle
im using client
should i replace all the "bots" with client?
like im using client intad of bot
Then how are you using cogs if discord.Client doesn't support cogs
Don't you have that line already
1 sec
mango_url = "url"
cluster = MongoClient("u tried")
db = cluster["db1"]
collection = db["db1"]
so just make these global?
Define "global"
like just put that on the main file
I'm trying to make a mute command, And a friend of mine who is testing can still talk, His only role is muted, is it because of the @.everyone role?/permissions, The role has send messages permission denied
so i can pull from anywhere
@still merlin 1. make it so everyone and muted cant talk
Is the send messages permission ticked for the everyone role?
But this bot isnt being used for custom servers, This is a moderation bot im working on with 30+ guilds
Is the
send messagespermission ticked for the everyone role?
@slender thistle yes
the green tick
then that's the issue
Allowed permissions overwrite the denied ones
oooh
so i would put mango_url = "url"
cluster = MongoClient("sneaky boi 6000")
db = cluster["db1"]
collection = db["db1"] in the ()?
Any errors you are getting?
-notr
İngilizceden başka dillerde sohbet etmek için #memes-and-media kanalını, top.gg hakkında (Türkçe olarak da) destek almak için #support kanalını kullanın.
Bu kanalda Türkçe konuşmayın.
Şakaydı*
Any errors you are getting?
@slender thistle no
i was yesterday tho
same code i think
but i dont think its important
Are you blind
@slender thistle
so how would i attach it?
i saw
the message
but i dont understand it
I'd recommend going over OOP both in general and in Python
because my snippet does attach the collection to the bot object that you will later use
Try increase the timeout in client options
partials: ['MESSAGE', 'CHANNEL', 'REACTION'],
disableMentions: 'everyone'
});```
Did I do this right for disabling ateveryone? It still pings it 
db = MongoClient()
bot.col = db["db1"]["db1"]``` shivaco told me to do this
to sharding
it's allowedMentions
wut does it mean lol
@pale vessel disableMentions takes these arguments tho
lemme check
I mean I can do it the other way around, but I dont see anything wrong with what I did
@split hazel pls help my won't go on
allowedMentions actually pings them but at the same time not
bot*
i have to disable that
disabledMentions just escapes it with a zws
it'll look like this: @pale vessel
but it doesn't ping
Ok I'm confused
zws is a zero-width-space
^thanks
works
i didn't need to disable my allowedMentions, it won't ping anyway lmfao
i'm so retarded
partials: ['MESSAGE', 'CHANNEL', 'REACTION'],
allowedMentions: ['roles', 'users']
});```
This seems to "work" - It now returns an Invalid Form Body-error when everyone is mentioned
oh I think I'm understanding it wrong I guess?
I'll test around a bit
oh oops
if you want to disable for all, just add an empty array for users
it'll work for roles too
which isn't what you want...
I guess this works? const client = new discord.Client({ partials: ['MESSAGE', 'CHANNEL', 'REACTION'], disableMentions: 'all' });
does anyone know how to chsnge the default location of the bots automatically created role
I doubt that's supported
like for example this is how my bot "MEE69" comes on a server
@nimble kiln everyone didn't work?
but it lacks the permission to change "Members" nicknames
becuase they are above it
(node:28169) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions
most bots create a new role below their highest position and delete their old one
@nimble kiln
everyonedidn't work?
@pale vessel Yeah, everyone didnt work as I wanted it. And the user mention still worked
most bots create a new role and delete their old one
@pale vessel ok thank you
edited
let's say a bot named mee69 creates a new role to for example change their color. they would create a new role under their role
and use that instead
but that wouldn't allow it permissions over Member
if they have the permissions
MEE69 has admin
if not, then it can't do that
Member doesn't
so the command that i get ''DiscordAPIError: Missing Permissions" for is a command that changes all nicknames in a server to whatever you put after the command
all? 👀
but it only works if i manually move the MEE69 role above the Member role
not all but all except admins
Please guys
Error [SHARDING_READY_TIMEOUT]: Shard 0's Client took too long to become ready.
message.guild.members.cache.forEach(member => {
if(!member.hasPermission('ADMINISTRATOR')){
member.setNickname(nick);
}
});
@pale vessel this is pretty much what it does
and nick is ``` let nick = message.content.slice((settings.prefix + "nickmass").length)
what role does this?
but if i run it when the MEE69 role is at its default location it doesn't have permissions
i see
only when moved
that's because it can't modify any roles that are higher than it, even with admin
member is higher than mee69 in this case
yeah
it's the role hierarchy
you have to deal with it
make the bot's role highest
or at least after administrator
yeah
so i just have it create a role on joining a guild
is it able to create roles higher than itself?
So I dont know what I did differently, but after a few more restart this works now 
partials: ['MESSAGE', 'CHANNEL', 'REACTION'],
disableMentions: 'everyone'
});```
i'm not sure if that would work since i have no idea what position discord puts for new roles
but if it doesn't have the perms, just send a message telling the owner to move the position manually
i'm sure there's a better way to do this though
yeah
i guess i can but that in the message when it joins
a guild
i finally managed to make my database and start logging settings into it
because shards start with 0
yes but it says 0/1
:(
It says recommended shards: 1 for me too
Shard 0 is your "1" shard, so yeah. Flazepe is right
I can't explain why it shows 0/1 tho ¯_(ツ)_/¯
okie
gj
thank you so much for your help
Require stack:
- C:\Users\Pujya Kumar\Desktop\Thunder\commands\music\drop.js
- C:\Users\Pujya Kumar\Desktop\Thunder\handlers\command.js
- C:\Users\Pujya Kumar\Desktop\Thunder\server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\Users\Pujya Kumar\Desktop\Thunder\commands\music\drop.js:2:19)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Module.require (internal/modules/cjs/loader.js:1025:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\Pujya Kumar\\Desktop\\Thunder\\commands\\music\\drop.js',
'C:\\Users\\Pujya Kumar\\Desktop\\Thunder\\handlers\\command.js',
'C:\\Users\\Pujya Kumar\\Desktop\\Thunder\\server.js'
]
}
why npm is unable to find config.json

uhhh
idk
i use client.config = require('./config');
not ../config
oh
remove the extention
@weak rain
just type "../"
and you should get a thing to select the file but like
it shouldn't have an extention i think
Hey @quartz kindle thanks but one more thing
I have the 2 main files
index.js - Sharding one
bot.js - My bot one
So in package.json do I change main to bot.js or leave it index.js only ???
And second thing
I use pm2 for monitoring
So do i do pm2 start index.js or pm2 start bot.js
because a config.json doesnt exist in the directory u provided @weak rain
@delicate shore the sharding one
its open but @digital ibex
your sharding one starts the bot script
@delicate shore the sharding one
@pale vessel for which thing first ques or second
ok
both
but it gives me an error
Require stack:```
@weak rain type ../ and it will list the files available
yea
@pale vessel it says shard 0 exited before client became ready
bruh.
what
how long should it take for my bot to get checked
like 3-4 weeks
rip in peaces :((
const { ShardingManager } = require('discord.js');
const manager = new ShardingManager('bot.js', {
// for ShardingManager options see:
// https://discord.js.org/#/docs/main/v11/class/ShardingManager
// 'auto' handles shard count automatically
totalShards: 'auto',
// your bot token
token: ''
});
// Spawn your shards
manager.spawn();
// The shardCreate event is emitted when a shard is created.
// You can use it for something like logging shard launches.
manager.on('shardCreate', (shard) => console.log(`Shard ${shard.id} launched`));```
the process exited
@pale vessel how to solve the issue then
@quartz kindle can you Help :( 😢
hey
async def on_message(self, ctx):
mango_url = "url"
cluster = MongoClient("u tried noob")
db = cluster["db1"]
collection = db["db1"]
author_id = ctx.author.id
guild_id = ctx.guild.id
author = ctx.author
user_id = {"_id": author_id}
if ctx.author == client.user:
return
if ctx.author.bot:
return
if(collection.count_documents({}) == 0):
user_info = {"_id": author_id, "GuildID": guild_id, "Level": 1, "XP": 0}
collection.insert_one(user_info)
if(collection.count_documents(user_id) == 0):
user_info = {"_id": author_id, "GuildID": guild_id, "Level": 1, "XP": 0}
collection.insert_one(user_info)
exp = collection.find(user_id)
for xp in exp:
cur_xp = xp["XP"]
new_xp = cur_xp + 1
collection.update_one({"_id": author_id}, {"$set":{"XP":new_xp}}, upsert=True)
#await ctx.channel.send("1 xp up")
lvl = collection.find(user_id)
for levl in lvl:
lvl_start = levl["Level"]
new_level = lvl_start + 1
if cur_xp >= round(5 * (lvl_start ** 4 / 5)):
collection.update_one({"_id": author_id}, {"$set":{"Level":new_level}}, upsert=True)
await ctx.channel.send(f"{author.name} has leveled up to {new_level}!")```
this is my levels code
but its just not working
like no errors
just not working
py 
py
nothing i just haven't learnt it 😄
maybe you ran the bot twice?
oh
of servers
fetchClientValues returns a promise
Require stack:
- C:\Users\Pujya Kumar\Desktop\Thunder\commands\music\drop.js
- C:\Users\Pujya Kumar\Desktop\Thunder\handlers\command.js
- C:\Users\Pujya Kumar\Desktop\Thunder\server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\Users\Pujya Kumar\Desktop\Thunder\commands\music\drop.js:2:19)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Module.require (internal/modules/cjs/loader.js:1025:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\Pujya Kumar\\Desktop\\Thunder\\commands\\music\\drop.js',
'C:\\Users\\Pujya Kumar\\Desktop\\Thunder\\handlers\\command.js',
'C:\\Users\\Pujya Kumar\\Desktop\\Thunder\\server.js'
]
}```
why
in your eval command, you should check if the result of eval returns a promise or not
if it is, await it
he can't find the module
@weak rain as we said before ../ goes back and ./ is in the dir
@weak rain where is your config and where's the file with the ../config
are you sure it should be ../
Yea
And your file with the config require?

where are you requiring it
like wdym
i meant await the promises in the code for your bot's eval command
drop.js
Where is drop.js
if you are in: Thunder\commands\music\drop.js
then config.json is supposedly located at: Thunder\commands\config.json
^ that's what you're trying to find atm
no
where is it located?
hellooooo
i have a question
client.on("message", function(message){
console.log(`message is created -> ${message}`);
});```
like how this does something when one message is sent
is there a way to have a function that excutes after x messages
lol
oh
Can anyone help me with the question I asked above
multi
lol
i meant await the promises in the code for your bot's eval command
wat
add a counter
let counter = 0;
oh
@sonic lodge i even did in the code itself
jj
did not work
*kk
@vale garden try channel.awaitMessages()
then after every log do counter++;
if counter = whatever do this
ok thx
bot.shard.fetchClientValues('guilds.cache.size').then(console.log);
I use bot so do I need to change Client Values to BotValues
depends on what you're trying to achieve
no
it's a function name lol
but it resturns a p[romise
await it
returns* promise*
and flatten it if you need to
use .then()
do i need to use async in eval also
no
remove await and add the send method inside .then()
then(e => message.channel.send(JSON.stringify(e)))
don't put e in ``
that would be object Object
nm i read it wrong
ok
add one more )
what didn't work?
try
this.client.guilds.cache.size
@restive furnace but i am using ClientValues
doesn't eval() return the return value of the last expression
there is no last expression
So???
there's nothing to return at the end
it's correct
So what should I do now ? ;-;
what i mean is
it's not the same as eval
it's running it for each shard
and return it as array
well, it's kind of like eval
but not like let x = xxx
it just runs that code
it's not about fetchClientValues, it's about the actual eval function
:(
it's supposed to send a message
I am so done
did it send a message
no
check console
How can i add a picture to my bot's description? Someone told me I need to learn how to code with html or css
you can use markdown
Can I do something like const bot = new Discord.Client()
const client = bot
will they both work same
what
you can use markdown
What is markdown?
it's what you use on discord, `**hello**` etc
ok thx
what
@pale vessel can i use bot and client both as same
 can be used for images
const client = new Client({
disableMentions: "everyone"
});
const bot= client;```
so i can do bot.login and client.login also?
yes yes
this is why you would usually name your client as client
since having your client defined as bot and accessing something like guild.client would be confusing
but that's just how it works
Uhhhhh
the fetchClientValues() one or the shard process exit one?
the fetchClientValues() one or the shard process exit one?
@pale vessel Yo I resolved the promise and idk how it worked this time thanks
hi
can someone tell me how you can send messages to a specific channel on a specific server
lol
so, timers usually end when the bot restarts correct? how would I avoid this
Thats a good question
use a database
Or run the timers outside the bot 
can someone tell me how you can send messages to a specific channel on a specific server
plz help
lol
What library are you using
Select guild and channel
Look at discord.guide to get channels and guilds by id
Define the channel and the guild
Like
chn = get by id bla bla
chn.send(bla)
And the guild has to be before that
Test and fail, thats the best way to learn
docs*
but yeah it does have predictable abstractions
bot.on("message", function(message){
bot.channels.get(`718760245014298654`).send(`${message}`);
});
is there something wrong here
cache
that looks like some huge logger lmao
[object Object]
[object Object]
[object Object]
[object Object]
bot.channels.cache.get?
v12 is full of .cache 
cuz that isnt working
yes
<Client>.channel.cache.get(channelID)
no errorit just isnt working

bruh
do
const chn = (the thing)
chn.send("Hi")
that's the same
How do i make my bot send welcome messages?
which language/library?
discord.js
listen to guildMemberAdd event
it'll return a member object
you can just send the message onto the member guild with the message
Oh no, member objects, i give up
I'm new ;-;
who can help with mongo?
My bot exits vc playing music
start with objects intro then
thats like, the whole point of an OOP
its the super basics

@earnest phoenix https://www.w3schools.com/js/js_objects.asp
and goes offline
Aight, thanks Erwin, i'm trying to learn as much as i can 😄
@opal plank u know anything?

When the guildaddmember event is sended you can take the user info and send something to an specific channel using client.channel.cache.get(id)
@earnest phoenix
who needs linters anyway
Like an embed with the username/avatar/welcome message

Whatever the event name is
;-;

Hey
Why Ignore
cuz this isnt #memes-and-media
He mentioned by using sticker
of course i dont know everything, theres quite a few things i need to learn as well
What a god
hm
im going to start meta stuff soon hopefully
Yes
Do you have a queue?
queue limit or command
Music queue
No
The audio starts playing and then crashes?
Can I see code?
yea
Also, do you have an error handler?
Yes
And how is it crashing
no


after crashing logs -->>
Send hastebin
Yeah that crash log is a mess of ytdl
oh
arent you using opus?
First, hastebin the code 
hi
is there any difference between ytdl-core and ytdlDiscord?
im not using the "Discord" one
so this is used to log all messages from my bot guilds
bot.on("message", function(message){
bot.channels.cache.get(`751089331560775691`).send(`> **${message.author.username}** >> ${message} \n`);
});
how do i make it not log its own messages
me?
i sure hope your bot isnt public
yes

lol
an if statement
good cuz thats a good way to get ratelimited
bot.on("message", function(message){
if (!message.author.bot) {return}
else {
bot.channels.cache.get(`751089331560775691`).send(`> **${message.author.username}** >> ${message} \n`);
}
});
no need for {}
whats that tho
ok but still not working

if(!false(true)) return
@weak rain back with you, did you know if theres a difference between packages?
wdym
ill give a look at your code to see why crashes anyw
@vale garden also message is an object
if you want to send contents of the message, use message.content
otherwise you sending the whole object stringyfied
wdym
@weak rain ytdl-core is a package, and ytdl-core-Discord is another
hm

use a database
@digital ibex I don't wanna ping the database and check if its time every time a message is sent or every few minutes. Should I check the database every X minutes?
Or run the timers outside the bot :realstate:
@ionic dawn How would I do this?
@weak rain my head is like 

@commands.command()
async def cmd(self, ctx, etc):
@weak rain also, it does change the way to work with it, [https://www.npmjs.com/package/ytdl-core]
thats not working

running timers outside the bot is no different from running it inside the bot bc they’re both processes, also could cause some memory leaks if ur using it as database, also only complicating things since you’d have to do stuff with ipc and stuff. you use setTimeout so you dont need to check the database at all. what you’d do is something like:
<add db stuff here to save the time>
const time = <time in ms from db here>
setTimeout(() => {
console.log(“time to remind them. the time has ended”);
}, time);
im on mobile so there may be slight mistakes i’ve accidentally made
@thick gull
discord.ext.commands.errors.ExtensionFailed: Extension 'meme' raised an error: TypeError: cogs must derive from Cog
sys:1: RuntimeWarning: coroutine 'Command.call' was never awaited
wut is this/
await it
where?
before where its erroring, same line
well i dont know where
hi
case 'lol':
bot.on("message", function(message){
if (message.author.bot) {return}
else {
bot.channels.cache.get(`751089331560775691`).send(`> **${message.author.username}** >> ${message} \n`);
}
});
break;
so this is the command i mae
made
so it takes people's messages and sends them in another channel
oh lord
use awaitMessages() or createMessageCollector() please
me?
multi
you dont do that
it does tho
cuz u adding event listeners onto a switch dude
yea wdym
is that a message logger I see
@drifting wedge class Meme(commands.Cog)
well see switch case is being used cuz i use it for my command handler
wat
it'll just start listening
@drifting wedge class Meme(commands.Cog)
@slender thistle i haveclass meme(commands.Cog): def __init__(self, client): self.client = client
ik
why tho
why u even got that there?
And how are you loading that cog
switch is used for my cmd handler
but
eh idk why i didnt just make a file
well i will
i was just testing here
dude, other way around
listen to event, once event is fired, THEN you get a file to handle it
is music great for a bot?
so basically
the listeners need to be always declared on most cases
bot.on("message", function(message){
if (command === "lol") {
if (message.author.bot) {return}
else {
bot.channels.cache.get(`751089331560775691`).send(`> **${message.author.username}** >> ${message} \n`);
}
});
}
like this?
yes
@weak rain I have this so far
dont do an event listener on an if, do the logic INSIDE the listener
E
@ionic dawn Pro
add some logic, set a variable or something
the queue is fucked and Im workin on another thing so 
let stop = true;
if(stop) return;
there, it'll stop
can i like
make a timer
like
if there are no messages for x secs
it stops automatically
of course
just add the logic for it
do u have any src @ionic dawn
2 variables and one set interval
OwO
youtubeAPI prevent to force people to use links
user searchs are easier and more comfy
let stop:boolean = false;
let mCount:number = 0;
setInterval(() => {
if(mCount < threshHold) stop = true;
}, timer)
bot.on('event' () => {
if(stop) return;
//logic
})
@vale garden
alr let me see
something simple like this would be automatic
though it would stop and never restart
if you want a trigger, like a command, just adjust a variable


say I wanna play a 24/7 stream from a url — how would I do it using FFMPEG?
im legit about to go on github cause a second pandemic i shit you not, ive never seen such a shit library and api merged together to create this one monstrosity that we call Twitch
thats it
no trace
no log
no info
just hey, i error, have fun
and then just stops

And how are you loading that cog
@slender thistle ext load
the ffmpeg stream stops eventually
exts=['music', 'meme']
entire file?
@slender thistle
Mhm
import discord
import praw
from discord.ext import commands
class meme(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
async def meme(self,ctx, memetype='Memes', other='Memes'):
reddit = praw.Reddit(client_id='butt',
client_secret='pp',
user_agent='ur mom')
"""Posts a meme from a subreddit of your choice."""
memetype = memetype.lower()
if memetype == 'memes':
memes_submissions = reddit.subreddit('Memes').hot()
elif memetype == 'dank':
memes_submissions = reddit.subreddit('dankmemes').hot()
elif memetype == 'deepfried':
memes_submissions = reddit.subreddit('deepfriedmemes').hot()
elif memetype == 'medical':
memes_submissions = reddit.subreddit('medicalschool').hot()
elif memetype == 'anime':
memes_submissions = reddit.subreddit('animememes').hot()
elif memetype == 'history':
memes_submissions = reddit.subreddit('historymemes').hot()
elif memetype == 'nuked':
memes_submissions = reddit.subreddit('nukedmemes').hot()
elif memetype == 'surreal':
memes_submissions = reddit.subreddit('surrealmemes').hot()
elif memetype == 'other':
memes_submissions = reddit.subreddit(other).hot()
elif memetype == 'mean':
memes_submissions = reddit.subreddit('MeanJokes').hot()
post_to_pick = random.randint(1, 100)
for i in range(0, post_to_pick):
submission = next(x for x in memes_submissions if not x.stickied)
await ctx.send(submission.url)
def setup(client):
client.add_cog(meme(client))```
sending code
my VSC crashed
const fetch = require("node-fetch");
module.exports = {
name: "phub",
category: "image",
description: "PornHub Quote",
run: async (bot, message, args) => {
let user = await message.mentions.members.first()
let text = args.slice(1).join(" ")
if(user){
text = args.slice(1).join(" ");
} else {
user = message.author;
}
if(!text){
return message.channel.send("**Enter Text!**");
}
let m = await message.channel.send("**Please Wait...**");
try {
let res = await fetch(encodeURI(`https://nekobot.xyz/api/imagegen?type=phcomment&username=${user.username}&image=${user.displayAvatarURL({ format: "png", size: 512 })}&text=${text}`));
let json = await res.json();
let attachment = new Discord.MessageAttachment(json.message, "phcomment.png");
message.channel.send(attachment);
m.delete({ timeout: 5000 });
} catch(e){
m.edit("Error, Try Again! Mention Someone");
}
}
};
if i dont mention if works fine


jesus christ the lib cant handle this much traffic

oh shorry
@earnest phoenix
I'm making a bot to give information about covid 19, everything is fine but I don't know why when I search for a country with spaces I get "undefined" instead of the data ... My code: https://hastebin.com/atufipifax.http
$ space {}
lets start there
yeah yeah, im using ${country} for states, country, and continents
you have to replace the space in the stuff the user puts in
there SHOULDNT BE
yeah there shouldnt be a space eitehr
but
"united states" >> "united+states"
depending on how it handles those
^^
args[1] = united args[2] = states
yes, but u defidning country as args[1]
yeah
show updated code
ok
this will always return undefined
parse
remove space
JSON.parse () => Json.parse()
is that a seperate message listener for every single command 😩
memory usage must be painful there
that indentation giving me nightmares too
the json is undefined
await it
the server doesnt have it

so what can i do?¿
Why is he having a ????
replace spaces with %20 btw
help
2020-09-03T15:59:47.551884+00:00 app[worker.1]: mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on 'localhost:3306' (111 Connection refused)
the website is dying rn
heroku error
no
heroku doesnt let you save anything
vps*
Yes
you need a remote database
is there any free hosting?
matthew
with database
no
do the vps thing
State doesn't exist
@earnest phoenix then theres your error
@earnest phoenix is that a message listener every command?
¯_(ツ)_/¯

lmao
any """""""""""free""""""""""" hosting is either:
- not intended to be used as hosting for bots
- not actually suitable for hosting for bots
- not actually free
- will get your token stolen
- all of the above
got it
oh
any """""""""""free""""""""""" hosting is either:
- not intended to be used as hosting for bots
- not actually suitable for hosting for bots
- not actually free
- will get your token stolen
- all of the above
SHIT
ha ha
lol
okay hear me out: start a hosting service but add ads to their bot
wait, but i want my database
im typing t-state new york
is there a way?
if your gonna keep using heroku use a remote database, it MIGHT work
everytime someone adds the bot it sends a massive wall with an ad to your vps
im not sure
how can i replace spaces with %20
remote database?

@earnest phoenix does it do it automatically?
@earnest phoenix does it do it automatically?
@thick gull what
cause if its /blah blah it will just be /blah
how can i replace spaces with %20
@earnest phoenix join args with that
how can i replace spaces with %20
@earnest phoenix encodeURIComponent
same way you connecting to 'localhost' you can connect to, guess what, an 'ip'














