#discord-bots
1 messages ยท Page 571 of 1
I 've thought it all out
?
I made it shorter

async def removeserverstats(self, ctx):
guild = str(ctx.guild.id)
self.serverstats.pop(guild)
await ctx.send("Done")```
well no errors now but didnt remove it from json i think
so did it sent done?
its a json
yes
If you don't save it it doesn't matter

endomorph , you gotta dump it to the json too
after it should be
thats the point :p
Yeah as I said, you never saved it after edition
hm
so you would be assigning a variable for the pop , and
json.dump(variable , file)
Still editing a dictionary
JSON is just a way to represent arrays and dictionaries as a text file
i meant , they wont have to dump a dictionary to save it , but for a json they would need to
how do i start a task when the task is in a different cog and the cmd to start is in different cog?
import the task , and .run() it
its basically just a function
from file import meme
from filename.classname import functionname
^
you would be able to import it but i doubt you wont be able to do anything with self
๐
nope
so , why do you have self there?
coz i need it
y
like self.bot.get_channal() to get the channel where i want to send things
you can pass the bot object instead ๐
ik
well , since you want to use it inside a cog , and it would for sure have a self.bot so sure
but how do i make it a class?
make it
nice help
just cut it / copy it , and paste it inside the class with correct indentations :>
How do I kick members?
discord.Member.kick
!d discord.Member.kick
await kick(*, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Kicks this member. Equivalent to [`Guild.kick()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.kick "discord.Guild.kick").
you can give a reason too
^
async def kick(ctx , user : discord.Member):
await bot.kick(user)
nuuuu
you can either use py await ctx.guild.kick(user)
or py await user.kick()
^
btw naming the arg as member is better choice according to pep8 , just saying
You can't kick a user....?
yeah , a User , user above is a discord.Member tho
It displays Missing Permissions in the terminal
Yea, discord.Member is a subclass of discord.User
U don't have perms to kick the member
your bot cannot kick the user due to insuficcient perms
The bot has owner perms and also i have perms
the role heirachy
And u tryna kick yourself?

no
a friend
you gave your friend a higher role than your bot mb
Alright thanks so much for the help
users
are discord users
not guild members
yes
how to make all words turn black, not just commas
embed.add_field(name='Aliases:', value=value=f'`` ,'.join(ctx.command.aliases), inline=False)
i tried this
value=f"`{' ,'.join(ctx.command.aliases)}`"
thank you very much!
how to make a deposit command, where you can specify your value, or you can enter "all" instead of the number, in short, like Dank Memer
check for the args ig
set the options as str, if its all then dep all, if its a number then first convert it to a int and then dep
or maybe you can set 2 options
a command function with an argument with int and str as Union would work
how to set then 2 options?
1 option as amount and 1 option as all which will be bool
show ur code
ik, but how set up 2 options
hold on a sec
async def deposit_bal(self, ctx, amount: int):
local_collection = collection['coins']
bank = local_collection.find_one({'_id': ctx.author.id})['bank']
bank_size = local_collection.find_one({'_id': ctx.author.id})['bank_size']
balance = local_collection.find_one({"_id": ctx.author.id})["balance"]
amount2 = bank + amount
if amount <= 0:
embed = discord.Embed(
description=f"{ctx.author.mention}, you cannot increase the bank balance by a ``negative value``",
color=0xff0000
)
await ctx.message.add_reaction("โ")
embed_delete = await ctx.reply(embed=embed, mention_author=True)
await asyncio.sleep(10)
await embed_delete.delete()
elif amount > bank_size:
await ctx.reply(
f"You can only hold ``{bank_size:,}``:money: in your bank right now. To hold more, check our shop!",
mention_author=True)
elif amount2 > bank_size:
await ctx.reply(
f"You can only hold ``{bank_size:,}``:money: in your bank right now. To hold more, check our shop!",
mention_author=True)
else:
local_collection.update_one({"_id": ctx.author.id},
{"$set": {"bank": bank + amount}})
local_collection.update_one({"_id": ctx.author.id},
{"$set": {"balance": balance - amount}})
new_bank = local_collection.find_one({"_id": ctx.author.id})['bank']
await ctx.reply(
f"``{amount:,}``:money: deposited, current bank balance is ``{new_bank:,}``:money:",
mention_author=True)
too big ig
2nd version
ok, can you show ur decorator for that command
does anyone have an example of using https://www.reddit.com/r/memes.json in a discord bot
@bot.command
use praw to get memes
!pypi asyncpraw
@kindred epoch
@commands.command(
name="deposit",
aliases=["Deposit", "dep", "Dep"],
brief="Deposit money into your bank account from your pocket! You can also use arguments like 'max' and 'all'. You cannot deposit past your bank space allows, which you can see in balance.",
usage="deposit <amount>"
)
async def deposit_bal(self, ctx, amount: int):
ah ok
so to get more options use the args, add all: bool next to amount
becos idk how to use that
async def deposit_bal(self, ctx, amount: int, all: bool):
??
How do you know member correctly?
ye
then how to make condition with all ?
?
i mean plz dep all
is it a slash command or a normal command?
bot will work with all
normal cmd, plz - my pref
for my bot
any example?
since the website u send is using asyncpraw for smth else
@kindred epoch
??
In this video, we will learn how to get data from Reddit using python for a Discord bot. We will make the meme command in this video.
If you have any suggestions for future videos, leave it in the comments below.
Some Useful Links -
Reddit Applications- https://reddit.com/prefs/apps
My Discord Server- https://discord.gg/TXF3hBj
My Twitter...
Please tell me how to find out a member?
What are you trying to do?
what is this library
I am creating a ticket system, and when another person clicks the button, information about me is still displayed, because it says ctx.author, and I need information to be displayed about who clicked the button
dislash
use py-cord or nextcord
Do you want me to rewrite the entire system?
Why?
no
it is easier like that
just use pycord they have built-in support slash command
i want bot to add reaction to it's message and store ids of members that react to it in a list
Huh?
i read the react section of documentation but can't figure out
I'm pretty sure dislash and disnake is better than it
bro they are forks of discord.py
Pycord only supports slash commands where as disnake and dislash supports slash commands, context menus and apps
Pycord is also a fork of d.py
Can someone help me with my question?
pycord supports all of them
Whoever clicks the button is called inter.author
Can you send the docs for it?
ok
okay, thanks
all of them is still beta for pycord
disnake released them long ago
pycord is now official
Still waiting
they have slash_commands built it
Only reason pycord is popular is because of the owner having a yt channel and an already existing large discord server
why dont i see that in their docs
( it exists in master branch , beta i.e.)
that's beta , right?
Honestly not sure
what else would master mean
thats the point , disnake already is stable and released with 2.1.5
And the fact that they haven't even changed the discord invite link is just....
I'm pretty sure it's because those docs are from the latest "release" of it, which is from when it was first forked from discord.py
the stable release docs are just forked from discord.py's
master branch docs has been curated
with the blue&white snake logo
Please tell me how to find the channel id?
How do I get voice input or the loudness of a user in a voice channel
@zenith zinc how to find the channel id in discord.py
ouaaaa
(ctx, channel: discord.Channel):
print(channel.id)
discord.TextChannel*
bro
guys, plz help solve this
i need help my bot join in my channel how change to send in message channel nam
your trying to add a string to an integer
bro, too diff for me, if u can change my code - i cand send
jajajajja
Hi I have a question. A friend of me programmed a discord bot, but when it gets large numbers, it responses with an e-form. Is there a way to disable this and get the full number displayed?
Why is this counter not working?
prawcore.exceptions.ResponseException: received 401 HTTP response```
what does this mean
Where is your variabele n
And you don't need to say global
while number < 5: Number +=1
This should work
What libraries do you use?
hello can anyone pls help me out?
i am using repl to make a bot
and the error which is showing up is
a type error
i've checked the video many times
and my code is similar with the one in the video
still...
pls help
if you are using .env w/ repl there is something special you have to do. You also shouldn't name your TOKEN variable with your actual token
also you shared your bot token so you should probably regenerate it
He should use @ client.command rather than events for commands, no?
nah his code is fine the way it is
code?
ok wait
although it is recommended for EXT, he doesnt have to
@commands.command()
async def join(self,ctx,*, channel: discord.VoiceChannel):
if not ctx.message.author.voice:
await ctx.send(f"You are not in voice channel {ctx.author.mention}")
else:
embed=discord.Embed(title=f"JOIN", color=0x36393e)
embed.add_field(name=f":succsess: I join {channel.id}", value="``Type .wp {music name} to play music ``", inline=False)
await ctx.send(embed=embed)
channel = ctx.author.voice.channel
await channel.connect()```
and his code works fine
and thats in a cog right?
yes i regenerated it:>
yea
meaning?
then probably user erro
but is it better to use @bot.command? yes
with .ext yes
like example can u pls give me an example? @vagrant topaz
client.run(os.environ('token'))```OR
```py
client.run("token")```
and using on_message as a command is just dumb
when theres already a a thing for command which makes your life easier
yea this is my code but still not working
its not
os.environ should literally say token, not your bot token
and specifiy that in the environment variables tab
how fix?
set py async def join(self, ctx, *, channel: discord.VoiceChannel=None):
Use the discord api
specify on oauth2 authorization
hepl plz
on photo
help me please
yeah ik but it annoys me every fucking time
Bank or amount is a string
make it int('1234')
I don't understand
what are you trying to do
thats work
no i dont think so with discord.py
check api docs before asking, its most likely there
what
i just want make cmd where i need specify amount (int) or i can type "all" or "max" instead of amount, one guy said me that code, but there is mistake - how to solve this ?
who said that?
where is his code
how does my bot tag a channel when it enters a particular channel
wait
wdym tag
like mention?
yes
<#channel_id>
async def deposit_bal(self, ctx, amount: typing.Union[int, str]) -> None:
local_collection = collection['coins']
bank = local_collection.find_one({'_id': ctx.author.id})['bank']
bank_size = local_collection.find_one({'_id': ctx.author.id})['bank_size']
balance = local_collection.find_one({"_id": ctx.author.id})["balance"]
amount2 = bank + amount
if isinstance(amount, str):
if amount in ("all", "max"):
await ctx.send("test")
else:
.....
works for voice & text
@commands.command()
async def join(self,ctx,*, channel: discord.VoiceChannel=None:)
if not ctx.message.author.voice:
await ctx.send(f"You are not in voice channel {ctx.author.mention}")
else:
embed=discord.Embed(title=f"JOIN", color=0x36393e)
embed.add_field(name=f":succsess: I join (have a code tag this channel)", value="``Type .wp {music name} to play music ``", inline=False)
await ctx.send(embed=embed)
channel = ctx.author.voice.channel
await channel.connect()```
read
^```
there's your problem
@zenith zinc
i think you forgot ctx (don't quote me on that)
.
how can my bot tag that channel it entered
async def deposit_bal(self, ctx, amount: typing.Union[int, str]) -> None: local_collection = collection['coins'] bank = local_collection.find_one({'_id': ctx.author.id})['bank'] bank_size = local_collection.find_one({'_id': ctx.author.id})['bank_size'] balance = local_collection.find_one({"_id": ctx.author.id})["balance"] amount2 = bank + amount if isinstance(amount, str): if amount in ("all", "max"): await ctx.send("test") else: .....โ
why would you do that when you can just do channel.mention
oh true my bad
Your complicating a join command, you dont have to have a channel arg or self
self because cog
Join in and channel mention @vagrant topaz
you cant do channel.mention in ``i think
why would you not
it breaks it
How to make your bot join a vc?
just do {channelname}
?
Unless he wants the user to have to put in channel every time he can just see what channel the user is in and join that
!d discord.VoiceChannel.mention
property mention: str```
The string that allows you to mention the channel.
it so easy
I was responding to you lol
if not "@everyone" in message.content.lower() and not "@here" in message.content.lower() and not "613752401878450176" in message.content.lower():
rayyanw786 = await self.client.fetch_user(613752401878450176)
if rayyanw786.mentioned_in(message):
await message.reply("test")
so i have this on_message
but it seems to reply after 20 seconds
i dont understand why it replied after 20 seconds as i have other if statments
and they reply instantly
No need to be rude. If they knew they wouldn't have asked.
probably ur fetch_user
what would be a replacement
Use ...get_user(id) or await ...fetch_user(id)
get_user
Then it tries to get the user from cache
And if it returned None, it automatically uses fetch_
@commands.command()
async def join(self,ctx,channel: discord.VoiceChannel=None):
channel = self.client.get_channel(channel)
if not ctx.message.author.voice:
await ctx.send(f"You are not in voice channel {ctx.author.mention}")
else:
embed=discord.Embed(title=f"JOIN", color=0x36393e)
embed.add_field(name=f":succsess: I join in {channel.id} ", value="``Type .wp {music name} to play music ``", inline=False)
await ctx.send(embed=embed)
channel = ctx.author.voice.channel
await channel.connect()```
@vagrant topaz
channel is none
you cant get a channel if its none
how to get
error:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Bot' object has no attribute 'get_server'
code:
@bot.command()
async def leav(ctx, member : discord.Member = None):
toleave = bot.get_server("903655554403139657")
await bot.leave_server(toleave)
why does my bot no out of the server?
bruh
where to put it
guild = bot.get_guild(69696969420)
await guild.leave()```
replacing the channel = line
id is not supposed to be a str
@commands.command()
async def join(self,ctx,channel: discord.VoiceChannel=None):
channel = if channel:
if not ctx.message.author.voice:
await ctx.send(f"You are not in voice channel {ctx.author.mention}")
else:
embed=discord.Embed(title=f"JOIN", color=0x36393e)
embed.add_field(name=f":succsess: I join in {channel.id} ", value="``Type .wp {music name} to play music ``", inline=False)
await ctx.send(embed=embed)
channel = ctx.author.voice.channel
await channel.connect()``` like this
I put my commands in a cog and now litrelly every command has a error saying Callback for ping command is missing "ctx" parameter.
you need to add self as an arg
What's self?
A Cogs Example for the rewrite version of - discord.py - bot_example.py
Wait now it says, Command raised an exception: AttributeError: 'ccog' object has no attribute 'send'
oops
ccog?
@commands.command()
async def join(self,ctx,channel: discord.VoiceChannel=None):
channel = if channel:
if not ctx.message.author.voice:
await ctx.send(f"You are not in voice channel {ctx.author.mention}")
else:
embed=discord.Embed(title=f"JOIN", color=0x36393e)
embed.add_field(name=f":succsess: I join in {channel.id} ", value="``Type .wp {music name} to play music ``", inline=False)
await ctx.send(embed=embed)
channel = ctx.author.voice.channel
await channel.connect()``` like this @vagrant topaz
please provide code
no..
thats my file name
i said replace
him?
```py
```
import discord
from discord import client
from discord.ext import commands
class ccog(commands.Cog):
def init(self,client):
self.client = client
# Event
@commands.Cog.listener()
async def on_ready(self):
print('Bot Is Running')
# Commands
@commands.command()
async def ping(self, ctx):
await ctx.send(f'Pong {round(client.latency * 1000)}ms')
@commands.command()
async def randomn(self, ctx):
await ctx.send(client.randint(1, 1000000000))
@commands.command()
@commands.has_role("Owner")
async def kick(self, ctx , user : discord.Member):
await ctx.guild.kick(user)
@commands.command()
@commands.has_role("Owner")
async def ban(self, ctx , user : discord.Member):
await ctx.guild.ban(user)
def setup(client):
client.add_cog(ccog(client))
i can switch
when you try to run it or on command
in my main script im using bot
you dont have to
which one
!ping command
You are not allowed to use that command here. Please use the #bot-commands channel instead.
it not work
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'leave'
one sec
your ID is wrong
@commands.command()
async def join(self,ctx,channel: discord.VoiceChannel=None):
if channel:
if not ctx.message.author.voice:
await ctx.send(f"You are not in voice channel {ctx.author.mention}")
else:
embed=discord.Embed(title=f"JOIN", color=0x36393e)
embed.add_field(name=f":succsess: I join in {channel.id} ", value="``Type .wp {music name} to play music ``", inline=False)
await ctx.send(embed=embed)
channel = ctx.author.voice.channel
await channel.connect()``` like this @vagrant topaz
omfg
if channel: channel = self.client.get_channel(channel)```
also
why are you getting the channel when its already defined as a VoiceChannel in your command args
is correct
because voicechannel is none?
.
bruh move channel.connnect() to before the embed is sent
foudn the problem
you need self.client.latency instead of client.latency
whenever you mention client, make sure to include self.client to instance the bot
yea
yes you can
i think thats also fucking with your setup() function
you have to remove it
sorry no work
yes but make sure to change EVERY instance
Ok.
if you cannot solve these basic problems you should really not be doing discord.py
because from discord import client is only for your main file to define and run the client
when you load a cog, discord calls setup() and passes in bot
bro can you say some?
so you pretty much have to remove it unless you change every instance of client to bot
i've given you so much already
and even then client is pretty much useless
nono i say you some
what
Sooo sad, now the fucking bot doesnt start and it gives no error in terminal
show me ur main file
redact token ofc
import random
import discord
import os
from discord.ext import commands
from discord.ext.commands.bot import Bot
bot = commands.Bot(command_prefix='!')
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
bot.load_extension(f'cogs.{filename[:-3]}')
bot.run('')
hi
how i start ??
b r uh
go to yt
im dump man bro i tryng fix but i wont to my bot send channel tag in text channel
NO DO NOT USE YOUTUBE
tyy
english plz
define channel and connect before you send that embed
lol
you are defining channel AFTER you send that embed and thats why its None
Yeah?? I know the whole import is messed up.
i just want my bot when it enters the voice channel to send in the text channel voice channel name it entered
honestly you should not be doing voice
voice is very difficult
calm down mate jesus
its true tho
channel = # define channel here
await channel.connect()
embed = # define embed here & use channel.id
await ctx.send(embed=embed)```\
help?
main.py:88: DeprecationWarning: The object should be created within an async function
self.session = aiohttp.ClientSession(loop=self.loop)
``` how do i not get this??
i know but why not try
noice
because you need to have knowledge on basic python/discord concepts
await aiohttp.ClientSession(โฆ)
look 1 message above
Thanks for the help @vagrant topaz
aiohttp is an asynchronous library
?
np lol
ya
its good u fixed the problem urself
you did = aiohttp.ClientSession, but I just told you it was async
therefore you await that function
im trying find my problem on google
LMAO
bruh are you okay i even gave you code
bruh how can u await in bot class? @manic wing
youโre subclassing bot? you can just put it in on_ready
I cut my veins because of the problem good night everyone ๐
msg = await ctx.channel.send(f"`Now playing: {var3}` \n{url}")
await msg.add_reaction(u"\u23F8")
await msg.add_reaction(u"\u25B6")
while True:
try:
reaction, user = await client.wait_for("reaction_add", check=lambda reaction, user: reaction.emoji in [u"\u23F8", u"\u25B6"], timeout=90.0)
except asyncio.TimeoutError:
return await msg.clear_reactions()
else:
if reaction.emoji == u"\u23F8":
await msg.remove_reaction(reaction.emoji, ctx.author)
await ctx.voice_client.pause()
elif reaction.emoji == u"\u25B6":
await msg.remove_reaction(reaction.emoji, ctx.author)
await ctx.voice_client.resume()
This code is supposed send a message showing what is playing, and bring up pause and play reactions which will pause and play the audio when reacted to by a user. Right now it only runs once during a run of the whole code, this means it will only respond the first time a user calls the command and does a reaction. For example, if a user plays something then pauses through the pause reaction it will pause, but if he then does the play reaction he will get no response. Likewise, if he plays another song after the first one and tries pausing or playing through the reaction he will get no response.
I'm kidding I'm not "crazy"
hii
hii
i see
srry but the prob is i wann start but i dont know how to start someone please help me
Start with what?
where is the if for that else?
!ot if you want to talk about anything other than discord bots, go elsewhere.
Off-topic channels
There are three off-topic channels:
โข #ot0-psvmโs-eternal-disapproval
โข #ot1-perplexing-regexing
โข #ot2-never-nesterโs-nightmare
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
some know how fix it?
Thats not the problem, it works and runs the code the first time but doesn't repeat again
"url"
you need icon_url="https://โฆ"
needs to be a str
thanks
im first say
still
wooooo ๐
python
text="โฆ"
o
!resources Alright! Check out #โ๏ฝhow-to-get-help or the embed below :)
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
working, can i add too hour and date?
hm
timestamp
in embed = discord.Embed(โฆ) pass in the timestamp kwarg and set it to ctx.message.created_at
Caeden you got any idea how to loop it?
wait, what how
@client.event
async def on_message(message):
if message.channel.name != "suggestions":
return
embed = discord.Embed(title="no c", description=f"cc", colour=discord.Colour.light_gray())
embed.set_author(name="sex", url="https://google.com/", icon_url=message.author.avatar_url)
embed.add_field(name=f"Sugestie daล {message.author.name}", value=message.content, inline=False)
embed.set_footer(icon_url="https://media.discordapp.net/attachments/877151912120696873/902977072408973363/LogoMcForever.png", text="Zareaguj emotkami poniลผej")
msg = await message.channel.send(embed=embed)
await msg.add_reaction('โ
')
await msg.add_reaction('โ')
await message.delete()
I am on mobile so I canโt really read and understand the code - If youโre still asking later I can help
@manic winghi the thing u mentioned me ealier i just dont understand what to click
just do embed = discord.Embed(*, timestamp=ctx.message.created_at where * represents what else your arguments might be
please go to #python-discussion to ask non-discord bot related questions.
alr
is it sending any errors?
No
We all want to learn python, but here isnโt the right place
is it indented correctly?
Yes
and whats wrong?
It only works once
Like you turn on the bot and use the reaction and then it never works again until you rerun the bot
i dont see why it wont work
Yeah ive got no idea
guys, throw off the command so that the bot exits from a certain server
?
!d discord.Guild.leave || probably what youโre looking for
await leave()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Leaves the guild.
Note
You cannot leave the guild that you own, you must delete it instead via [`delete()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.delete "discord.Guild.delete").
I'm on pc here, I don't get where that else is coming from.
Its from the try except
Is there a way to send the names of the permissions the bot is missing when an cmd is invoked?
ctx.error.name i think?
bruh i can't believe my other account got disabled for trying to sell a vanity i owned and worked for
!ot sounds pretty ot
Off-topic channels
There are three off-topic channels:
โข #ot0-psvmโs-eternal-disapproval
โข #ot1-perplexing-regexing
โข #ot2-never-nesterโs-nightmare
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
ehh nothing else was happening so i don't think it matters that much but do you
Still of topic this is a channel for discord bots
If I have a member object, how can I get the member object of the person who invited the member? (discord.py)
I'm pretty sure it is impossible, unless you already have a database setup which records all invites.
How to record invites?
Caching
Uh
Save members with the invite in your cache when ever they make an invite then you can just pull it off of your cache
Yeah, but when someone joins the server, how do I get the member who invited him?
Can someone tell me how can i detect if a option has been pressed from a option menu?
Wait i potentially have a solution just gotta know if dpy supports it
whats that gonna do
Can i put my bot on google cloud this work?
return an invite object from the invite url
As I mentioned, you need to setup a data base, log all members on join event with the invite they joined with, then you will have to make a command to read the data base logs with each user's value (value being the person who invited them)
and
It has an inviter attribute which is the user who created rhe invite afaik https://discordpy.readthedocs.io/en/latest/api.html?highlight=get invite#discord.Invite.inviter
As per the official api docs (not dpy docs)
the user who created the invite
Yes why
ok
ik i was asking this, but i still cant understand guys, help me please with this error
i just want make cmd where u need put amount (int) and also u can put instead of number "all" or "max"
you can't do bank + amount
bank is an str and amount is an int
you prolly mean int(bank) + amount?
oh wait I know what u mean
check if amount's a string even before you try to add it to bank
`Author identity unknown
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'Uzytkownik@DESKTOP-FR2F8IS.(none)')`
i have problem with heroku
well that's not with discord bots
mhm
! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/avexa-verify-bot.git'
file is good
again, not a discord problem
go ask somewhere else
look it up
Yeah ofc
is there a github discord for stuff like that?
?
If you mean a template, then I do have one. https://github.com/ScopesCodez/python-discord-bot
Well, not really. I'm just helping them out, and myself at the same time. It's a smart play, nothing more nothing less.
Yikes, changing presence in on_ready and in a while-true loop
Might be from the second contributor, I don't do this. ๐
Crap, I got caught.
where do we set it up then?
cuz i dont have a thing where it needs to update every some amount of seconds
await wait_until_ready()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits until the clientโs internal cache is all ready.
In a task
It's because on_ready can be called multiple times.
And if you mean not a loop, you can pass activity to the bots constructor
Though, I still won't bother to set the status outside the on_ready event. Why? Because.
hm, didnt know about that lemme check that out
how do i @ someone in code forgot
.mention
!d discord.User.mention
property mention: str```
Returns a string that allows you to mention the given user.
can someone help with this issue on Heroku?
is it possible to delete user message on dm?
you mean if the user dms the bot delete their message to the bot or the bot's message to them?
first
not possible due to being in dm so the bot doesn't have message perms on the other side
only can delete message of it's own
@dapper cobalt
!d discord.VoiceClient
class discord.VoiceClient```
Represents a Discord voice connection.
You do not create these, you typically get them from e.g. [`VoiceChannel.connect()`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceChannel.connect "discord.VoiceChannel.connect").
Warning
In order to use PCM based AudioSources, you must have the opus library installed on your system and loaded through [`opus.load_opus()`](https://discordpy.readthedocs.io/en/master/api.html#discord.opus.load_opus "discord.opus.load_opus"). Otherwise, your AudioSources must be opus encoded (e.g. using [`FFmpegOpusAudio`](https://discordpy.readthedocs.io/en/master/api.html#discord.FFmpegOpusAudio "discord.FFmpegOpusAudio")) or the library will not be able to transmit audio.
!d discord.VoiceProtocol.cleanup
cleanup()```
This method *must* be called to ensure proper clean-up during a disconnect.
It is advisable to call this from within [`disconnect()`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceProtocol.disconnect "discord.VoiceProtocol.disconnect") when you are completely done with the voice protocol instance.
This method removes it from the internal state cache that keeps track of currently alive voice clients. Failure to clean-up will cause subsequent connections to report that itโs still connected.
do i call disconnect inside this?
Shut it.
what happend?
Wtf
i just made a bot with some super basic stuff, and nothing happens, i need your brains here
import json
import os
import discord
import requests
client = discord.Client()
async def on_message(message):
if message.content.find('robban'):
for x in client.get_all_emojis():
if x.id == ':wine_glass:':
return await client.add_reaction(message, x)
my_secret = os.environ['TOKEN']
client.run(os.getenv('TOKEN'))```
what am i missing, it should react with an emoji when someone types robban, right?
bank + int(amount) or bank += int(amount)
You forgot the @client.event over the async def
import json
import os
import discord
import requests
client = discord.Client()
@client.event
async def on_message(message):
if message.content.find('robban'):
for x in client.get_all_emojis():
if x.id == ':wine_glass:':
return await client.add_reaction(message, x)
my_secret = os.environ['TOKEN']
client.run(os.getenv('TOKEN'))
how can i fix if total_request > 5 and str(ctx.author.name) is not in user_on: ?
the broken part is str(ctx.author.name) is not in user_on, i dunno how to write it
(user_on is a list)
please revise that and show the code
all together
i need only to do right sentence, i don't know how to do that control
i have to check if name isn't on that list
thanks but still nothing tho =/
@midnight juniper theres nothing called message.content.find and get_all_emoji
and id is supposed to be an int not a emoji
no saw that now, im just grabbing stuff from stack overflow to see if i can get anything to happen at all
oh..
I haven't coded a discord bot in python so looong!
I've gotten used to js discord bots
same
async def on_message(message):
if message.content == "ping":
return await client.add_comment("pong")
but this should work right?
so you're saying you dont have any experience with python?
no?
yes
then why are you copying code from stackoverflow?
wait no
its outdated
add_comment is not a function anymore I think
1900s
@midnight juniper
Do you want the user to actually ping the bot or just say ping
isnt that exactly what being a pro coder is all about
just do
@client.event
async def on_message(message):
if message.content == 'Give me Drugs':
await message.reply('Alright here')
Epic example @hazy fulcrum
i know 
how darn awesome
thanks alot, now i just need to brush up that syntax, but at least i know it works
if you dont want it like that, just do await message.send("Something")
no problem ๐
๐
no
You can also do
if message.content.startswith('give me drugs')
await message.channel.send('alright here')
Obviously with indents and shit
well it is at my university ๐
Thanks man!
ok?
you cant, its the official channel
Also it seems like you don't know the basics of a discord bot, so u sure u don't wanna learn a bit of python be4 or are you just new to bots
ive never touched bots
I recommend just going through some tutorials on yt
but im 3 months away from graduating as an IoT -dev
but ill check the youtube stuff
Ooh really?
no
yt tutorials are garbage
Not for beginners like they seem to be
bruh
They will learn the fundamentals and basic knowledge of the bots
all of them are outdated/will learn dumb stuff
Not really
best tutorial is this: https://vcokltfre.dev/
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
made by one of the helpers
and former project leads
it seems like most of the examples are depricated stuff, or at least the ones i've found
yea all of them are outdated/ do unefficient stuff
haha
Do u all have 24/7 bots?
is it juicy?
Hmm?
All = y'all referring to you guys
24/7 means always online
ew
Can I get an example on how to put links with custom display text in a discord.py embed?
Aren't those only valid for 1 year
you mean free trial?
thanks @slate swan
btw is it possible to implement bots on facebook messenger ?
^^^
also tbh finding a hosting service for a discord bot is one of the hardest things in developing a bot due to the free trials and all
no free hosts are good, only good free host is the free trial from aws
yeah
unless if you are willing to pay for a vps
or something
Heroku is a good for being a free vps but paid ones are way better
heroku isnt even supposed to be a host
What is it then?
Its for websites
Yeah i know that but you could use it to but it isnt great
Things that don't need to be up 24/7, but rather spin up on requests generally from what I've seen (heroku wise)
Yeah i know what you mean
You can still run a bot on heroku right but its not gonna be good?
im using heroku but really want to move out of it :(
Idk, I've never used it
yeah of course but it is not intended for discord py bots
its not gonna be good and you're just destroying their platform
I pay my few bucks a month for a vps lol
or oceanblack or something like that
Nah linode
i use it myself like i said but thinking to move to a vps
anyways, what is a cheap and good vps?
digitalocean*
Linode

Replit is good, you can just buy hacker plan for 24/7 host. @midnight juniper
heard about that before
Buy a vps at that point lol

true
Theres no point to waste money on repl.it as a hosting service
That's just a waste of money
agreeed
true, unless your on a chromebook
$7 a month, could spend half for more on a vps
30$ monthly
Whats a good vps that has a year plan?
Go for digital ocean then
or just selfhost
Idk, I feel vultr is good as an entry point but imma be jumping from my current provider to contabo soon since I want scale
repl is not good
Vultr was good as well, I used it before, but I do remember having it go offline for a few hours
doesnt happen to me
you can use free hacker codes like
techwithtim or
MH
iirc its something about not having ddos protecting or whatever
its the same as vultr
But it was a odd situation
VULTR THATS THE ONE
they start with $5 but vultr starts with 2.50
i was trying to find the name for a while lol
Well, 1gb is a lot for a small discord bot
yeah
yea
vultr good for the cheapness, and just getting in but when you grow I'd change to paying a bit more for way more
personally
Rather just get a dedicated server and host more than just a discord bot
how do you deploy code into vultr? github or??
I host way too much on my vps lol
Seems kinda pointless to me to dedicate one server to hosting a bot after the market is so saturated
Whats the minimal specs for a discord bot like 2gb? Of ram
One of the reason I stopped bot dev and moved to making packages for developers and stuff. Better auidence as well, don't have to deal with people as much
i host my db and bot on the same server ๐ฌ
Not even, for small bots you get aware with little. What size is your bot?
Guild wise
Just 1 maybe 3 for future
Dealing with developers vs dealing with people tryna use your bot tho
Competent developers are fine
So small. not somethiing you planning on scaling?
Its the others that drive me insane
And I cba to write a code of conduct or contributing
Not really its like a personal bot
Heres my 1 guild bot with like ~30 members
https://gyazo.com/66471968967065d30f0b59631c2aa6df
how would do you deploy code into vultr?
ftp it onto your server, or use docker via portainer
you need to use filezilla
ah ok
ok ty
Does members matter and i think 1gb is fine
Memory scales with the amount of members
Personally I just use docker via portainer, didn't ssh into my server for months outside of updates
As it gets cached
I see
can you like connect ur github to vultr and automatically deploy from there?
You probably can
Heres stats on a 3.5k member bot
https://gyazo.com/7312f368575af0294a1c2c127c808d60
Doesn't get used a lot tho, but members should be cached
cuz i can update files in github from atom
like if your bot stores in like mutes, warns, etc., the amount of members can determine how much memory you should get
So you get aware with the smallest vps your provider offers is all im saying
Theres multiple ways to deploy code, you just find a way that works for you and use it
im sure vultr with 3.50 or 2.50 plan can be good for like 200-250 server bot
the reason i got 3.50 was cuz of the ipv4 adress
You can drop that number even lower with custom caching prob. On the top of my head chunk_on_startup=False then have a database store last active guilds and cache those, then pop them after a certain time
That's what I did for one of my production bots
Yea, could optimize it but why bother personally. If it were bigger then yea but not fussed over ~40mb
That is true
But then again discord.py isn't very performance efficient imo
The sharding isn't really sharding as well imo
Not what it could be at least
Following the flow chart, only need converters, attach more methods and finish interactions and its off to v1.0.0
I started components this morning
Sharding is done as well, but I have plans for a cluster manager
"True sharding" ig
Might add it to my list of if I get bored I'll add support for python discord packages ๐
If its at the point where people could make proper bots in
clustering with ipc, shared state or?
*Shared cache
IPC seems more preforment
And it should be ready for regular use, at least the commands extension is basically done
It just needs permissions checking and its ready
I already have Cogs, and the core of it finished
Soundds good to me then
Do you provide an external api method to build embeds from dict's
But can't really say anything about stability for now, still in alpha and I haven't gotten heavy testing on a production bot running it
Yes theres an embed builder
Oh wait you mean from dictionaries
That could be added pretty easily
Just because internally I need one, saves me writing one if it already exists
The embed class has a to dict method, but I'll take that suggestion
I can add from_dict right now
Alright
If it ain't there when I make an impl I'll pr one in
I mean, you likely need one internally anyway..?
To parse discord's api data into your Embed
@pliant gulch
I was not the one who PR'd the embed builder so I don't have it currently
Ah
Actually, I think I'll revamp the Embed builder
This ones way to class based
Makes it cumbersome to do stuff
Stuff like Message and channels but dw
In a limbo state
They are semi-implemented
We have all HTTP methods done, just haven't attached them to the models
Still looking for someone to do them but seems like me and my collaborator will have to do them
Aight
Okay thanks,
So I have
warns = sorted(warns, key=lambda x: x["number"])
pages = []
for warn in warns:
description = f"""
Warn Number: `{warn['number']}`
Warn Reason: `{warn['reason']}`
Warned By: <@{warn['warned_by']}>
Warn Date: {warn['timestamp'].strftime("%I:%M %p %B %d, %Y")}
"""
pages.append(description)
await Pag(
title=f"Warns for `{member.display_name}`",
colour=0xCE2029,
entries=pages,
length=1
).start(ctx)
where it says await pag, how could I replace that to make pages with nextcord? (Since nextcord already has pagination built it)
Using menus?
Can you link me the built-in things docs
Is nextcord better or hikari?
define better
Easier to implement imo
I'd probably say nextcord
Nextcord is discord.py, so if you currently use dpy it'll be 10x easier since its the same
You talking about this? https://github.com/nextcord-ext/menus
Otherwise your learning something new either way
Ohh well I never used discord.py and I have been learning hikari/lightbulb for a few weeks so ig I will stick to it?
Yes, but its not built in so I'm curious if you could link me the docs for what your discussing
Because there are so many libraries that I get confused lol
Yea probably, although lightbulb is very discord.py esque syntax wise so dpy would feel similar
Ohh
Ctrl + f failed to find pagination the given page. Guess I'm finding it myself if I want to help
Btw I had a doubt.. I am currently using postgres to store data like prefixes etc.. should I also use it to store experience or ranks of people through user IDs?
Or I should migrate to a better rdbms
Not sure how true this is anymore, but I think the only thing hikari lacks compared to dpy is voice stuff. Although there are no doubt extensions for it like yaru (I think its called that)
I believe this is it
postgres is nice yes, just make a user table for people by id as well
Not sure what would be better then postgres
Oh well I recently learned sql
So I am not sure which is the best free rdbms
and I started with postgres
Good choice tbh, I'd stick with it
Okay ๐
syntax for it is funky, but looks like you need to create the actual pagintation yourself. That class will give you pages using the methods from the docs but if you want to paginate the output thats up to you
You can look at nextcord.ext.commands.help.py for examples on how to use it since its what the help command uses
yeah i know what you mean, i still make bots here and there. but it isnt often anymore, ive gained more interest in building games and mobile applications. i plan to eventually come back to coding discord related things.
Ohh you are learning unity ?
Fair enough, I wanna make a mobile app over summer actually lol
Nice
nothing.
Unless your not using bot
full code?
maybe can raise a error of the bot not being defined or a eol scanning string error but thats just discord i think
he probably wanted to test us or sm
or waste our time
kinda useless when people have years of experience
^^
ive been coding w/ discord for almost 2 yrs now ||flexing ๐||
congrats
thats pog
how is dat a flex
idk
feels like i know more than ppl (not true)
just a cool fact about him you know
is it possible to make tests for a discord bot? since it uses the discord api, not the code to create responses
well ofcourse since you are helping people here , you know some things better than them
wtf do u mean
can you elaborate what you mean by 'tests for a discord bot'
not really everybody learns differently
mhm
i fucking hate when ppl say "HELLLO @near ospreyNNNN SOLVE MY PROBLEMS::: await fuckyou()"
different paste and other things
chill
stackoverflow :p
^^^^
not the best way to learn
but if it helps you out go for it
there are really many such names here lol
if i'd do @client or @bot its sure some person gets pinged
yea most of the code on stack and yt tutorials are outdated
@quaint axle
they dont even check what versions the code is for
@bot
no ofc not but just solving quick small scale problems
for better experience state any error and what you want and pls give a good explanation of it
yes ik
i mean, can you make unit tests for commands, since it uses the discord api
thats why im here lmfao
ok i gtg, sorry
im in class now
alr
you mean test out a command?cuz if thats so idk just test it out by yourself lmao
i chat in many yt tutorial servers , specifically lucas'
people bring 4 years oldcode to fix
yeah, good idea
i go now
lmaooo

if you want to test something without really adding it to your bot , use jishaku
@vagrant topaz they probably dont state their errors right for the fear of getting humiliated here but i dont blame them theres lots of people here who know their stuff
finished 
link?
interesting
Have you thought about slotting it
also maybe hiding the data variable
Hmm having slotted any of my models yet
Does slotting really matter here
And yea Ill make data a "private" variable
What do you stand to lose by slotting?
Given its not a dynamic class end users need to modify theres not a point to not doing it imo. Besides, they can just add to your data if they really want
Wait but if I use slots wont I be unable to use @property
Should be fine
