#discord-bots
1 messages · Page 486 of 1
I will use it, This is just debugging
oh
@slate swan if you want to do a full debug. Print out all the variables as you make them.
Great way to find out what's being set properly and what's not.
@slate swan is the daily_poll.txt in same folder as your main file?
Sigh why this have to be so complex
Yes!
hmm
@slate swan /shrug Probably missing a semicolon or something somewhere. Just print out all the variables and see what the issue is.
there is no semi-colon needed in python
I know @grand anvil
He could be missing something small. like a semicolon
or a dot
try to find out what step it breaks at
onoins
yes.
or did self.bot instead of just bot coz it's not a cog
who knows? print everything out.
Delete the prints once debug is over
import discord
import asyncio
import pathlib
from pathlib import Path
from discord.ext import commands
from discord.ext import tasks
from datetime import datetime
this_file_directory = Path(__file__).parent.resolve()
other_file = this_file_directory / "daily_poll.txt"
with open(other_file, "r+") as file:
daily_poll = [daily_poll.strip().lower() for daily_poll in file.readlines()]
class dailypoll(commands.Cog):
def __init__(self, bot):
self.bot = bot
@tasks.loop(count=1)
async def once():
today = datetime.utcnow().strftime("%Y%m%d")
with open('daily_poll.txt', 'r') as file:
if today in daily_poll:
print(today)
else:
print("Cant find it wot?")
def setup(bot):
bot.add_cog(dailypoll(bot))
There you go 🙄
I didnt say give us the code
just try to find out what step it breaks at
add a print statement with step number after each step in the once()
He's editing the code
Thats what ill do now
many times your function isn't invoked in first place and u try to find error inside function
@grand anvil that's why I said to print out. The print won't run if the code is broken
happened with me couple of times
or the print will display wrong.
Print is god. never disrespect the print
Got an error and unsure which variable? print all the variables.
yea but we need to find where it breaks before we fix it if we can't spot it
Ur not starting your loop
Again. Print out the variables as he invokes them.
myvariable = thisthing
print(myvariable)
myvariable = thisthing is now this thing
print(myvariable)
....
damn I didn't notice such an obvious thing
Under self.bot =... add self.once.start()
rip
Happens
i never looked tbh. too busy telling @grand anvil that printing works.
i totes wouldnt have missed it tho 😎
like I said earlier, sometimes your function isn't invoked in first place
Then we'd know coz nothing prints.
bro I also use printing......
yea
and if nothing prints. it means the fucntion isnt being called. Then we figure out why. work backwards.
If there's one thing I've learnt about debugging is to work backwards.
coz my code is always broken until it's not
Or firstly try see if something is missing
¯_(ツ)_/¯
¯\_(ツ)_/¯
damn why is there no competitive programming channel?
Wanna know what's totes fun tho? making a discord logging system to log all the events in the server \o/
Sir, this is a wendys.
Lmao
Done that for mine
Must say I had a headache at the end
I mean ok Python isn't the first choice of people for CP but people do use Py for CP
TypeError: once() takes 0 positional arguments but 1 was given
if it's in a cog, it needs self
It does have self
if changing async def once(): to async def once(self): isnt the solution then i have no idea
and when you call it, are doing self.once.start()? and not once.start()?
Yep self.once.start()
Lemme try
That's basic OOP knowledge
.>?
is face. from before you could emojis
What
Okay so no error but no print either now to see where it breaks
U got a point
Did u restart
The bot
And with that being said. I totes have never done that and would never do that and nor would I copy and paste code from outside a cog into a cog and forgot to put self everywhere
🤣
Happens all the time. I go to test code in different areas and forget to change a bunch of variables. so i run the code. breaks. fix. run. break. fix. repeat for like 50 errors
Gotta go faster
Okay so I did this
@tasks.loop(count=1)
async def poll(self):
print("Okay 1")
today = datetime.utcnow().strftime("%Y%m%d")
print ("Okay 2")
with open('daily_poll.txt', 'r') as file:
print("okay 3")
if today in daily_poll:
print("Okay 4")
print(today)
else:
print("Okay 5")
print("Cant find it wot?")
and its just spamming Okay 1 and Okay 2
(Wondering why it doesnt stop after saying it once?)
try this:
@task.loop(seconds=5, count=1)
change 5 to whatever you want.
Okay so I removed
with open('daily_poll.txt', 'r') as file:
and now it prints
Okay 1
Okay 2
Okay 5
Cant find it wot?
which is perfect for now!! Do I still need to do that?
Oh it started spamming Okay 1 and Okay 2 again
oh and it's @tasks not @task see. mistakes people. mistakes. double check your spelling.
It makes me question how I even made it to my age..
Okay now even though I put today variable in the txt it still prints cant find it
20210921 Dog or Cat?
Thats line one
datetime.utcnow().strftime("%Y%m%d") should print that
So it should find that
Where did u start it?
We got that to work finally!! Now trying to figure out why it wont find the line with todays date
Okay I got it to work!!!
@slate swan are you converting your variable that holds the date you want to search for to a string?
how can i use except for throwing 2 errors?
okay he got it guys
if it has HTTPExcpetion and Forbidden
I dont think I did much helping. if anything did more quacking. But I'll take ALL the credit 😎
All me guys.
whats the difference between on_message_delete and on_raw_message_delete
on_message_delete checks cache. and on_raw_message_delete is just any delete event in general.
your bot caches stuff, but only while online (and then that cache is dumped when it goes offline)
So if you dont care about the original author of the message or the message contents, you can use on_raw_message_delete
otherwise use on_message_delete
May I know what's the reason for this error?
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: DownloadError: ERROR: unable to write data: [Errno 122] Disk quota exceeded
oooo thanks
disk quota reached I guess?
Gnomeslayer, help pls
I actually just finished messing around with both those things. since I wanted to have the message itself
ok
The disk is full
A deco that makes the command only usable in NSFW channels
A check() that checks if the channel is a NSFW channel.
If you want my code I can share.but others consider it spoonfeeding. so up to you.
Okay so I am back here for more help 🙄 Right now I am able to check if a line in a file has a certain word and print that word, How would I print the whole line which has that word?
I already have my own events thats why I asked the difference

on_message ?
Also on_raw will trigger regardless whereas the other will only trigger if it's cached.
and I discovered through testing. Once a message is deleted, you cant gather any details about it unless it was cached \o/
Can see code?
how can i throw 2 raises in one except ?
ahhh any ways to fix it? I'm using replit
@tasks.loop(seconds=5,count=1)
async def poll(self):
print("Okay 1")
today = datetime.utcnow().strftime("%Y%m%d")
print ("Okay 2")
if today in daily_poll1:
print("Okay 4")
print(today)
else:
print("Okay 5")
print("Cant find it wot?")
dunno
try:
whatever()
except Exception as e:
#wherever you want e to go
# Logs the error appropriately.
not like that
this has 2 raises:
https://discordpy.readthedocs.io/en/latest/api.html#discord.Role.delete
how can i fit it in one except
BTW can anyone here help me make a paginator?
So my AI API sends some data in the form of a dict, and I want to paginate it in an embed and control it with buttons... I want to show only a maximum of 10-12 entries on one page... Any help?
You should not use Repl.it to host your bot.
?tag replit in the dpy server
if today in daily_poll1:
print("Okay 4")
print(today)
print(daily_poll1)
print dailypoll1? Wont that print the whole file
you dont want to use an error handler?
is there like a one liner?
probably. but you could also just split on \n or something which makes a list. and check each item individually? you're working with a txt file.
which pagination exactly? Something like this? https://github.com/Rapptz/discord-ext-menus
except Exception as e:
await ctx.send(e)
``` this is possible, but will it send what is given in the docs?
im not hosting it , im jus running my code there
async def on_command_error(ctx, error): pass
And in the main bot file, just do `bot.add_listener("on_command_error", on_command_error)
Ezz
With buttons.. Sorry my bad I didn't mention it
Wait, nvm... I said buttons
Well yea... Just like the Python bot has
yea i do have that one..
!d
I'm still yet to get to buttons in discord. ;-;
reactions?
Instead of reactions, buttons
Replit uses shared ip for the projects
Which means if one project gets banned, all the others get banned too
!d
which library are you using for the buttons?
what am I supposed to do then?
disnake
Use another host
ahh okayy
Use a VPS
dpy 2.0 has buttons
!d discord.ui.View
class discord.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
also menus
its the best one for buttons
Wait... I think I just gotta map the page number to the embed and just edit the message with the different embed, right?
all the other impls are trash
forks?
alright! Thanks a lott broo!
that too
ofc
forks and third party libs
Suppose I have a dict, which has, uhh, say 15 keys... So how to do so that on each page of the paginator, only 10 keys are shown...? Like, I will have to slice the dict or something, ig?
you can slice the dict items
Wym? Like separate them or something?
because you cant slice a dict like you normally do with a list iirc
Hmm, well I was thinking of using dict.items()
dict.items is a list of tuples
Yea, it returns a list of tuples, so it can be sliced then, right....?
yes but i believe it returns a dict_items object so to be sure you can cast it to a list
Hmm ok
user isn't defined
Define the user
alternative of discord.py?
discord.on_member_join(member)``````py
discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
Or follow this
@bot.group(invoke_without_command=True)
async def help(ctx):
member = discord.Member
embed = discord.Embed(title="", description=f"Welcome {Hello World}, to get help on a specific command type `??help <command>`", color=0x109319)
embed.set_author(name="MultiversalBOT", icon_url= "https://i.imgur.com/jszzFTz.png")
embed.add_field(name=":globe_with_meridians: General", value="`Ping`, `Uptime` & `RoomInfo`", inline=True)
embed.add_field(name=":reminder_ribbon: Nitro/Donor Rooms", value="`Invite`, `Remove`, `Ban`, `Unban`, `Hide` & `Unhide`", inline=True)
embed.add_field(name=":door: Private Room", value="`Pin`, `Unpin`, `Rename`, `Description` & `Slowmode`", inline=True)
embed.add_field(name=":tools: Admin", value="`Shh`,`Shh` & `Shh`", inline=True)
embed.add_field(name=":kite: Misc", value="`Vote` & `Donate`", inline=True)
embed.set_footer(text="Founder of Multiversal • 【C E O】#8841")
await ctx.send(embed=embed)
Oh nah. This is a command..
why not subclassing default help command, this way is pain
Pardon?
You want tag the author of command or other user?
..
ctx.author.mention
oki, thanks
best way to store data for a bot??
how can i get channel name if i have id ?
is it bot.get_channel("ID") ?
its not working for me.
database
how do i convert user id into member object? ik u can do member: MemberConverter in the function but i want to do it in the middle of the command
!d discord.Guild.get_channel
get_channel(channel_id, /)```
Returns a channel with the given ID.
Note
This does *not* search for threads.
!d discord.Client.get_channel
get_channel(id, /)```
Returns a channel or thread with the given ID.
dict.items() maybe
!d discord.Guild.get_member
get_member(user_id, /)```
Returns a member with the given ID.
do you want to show the keys or the values?
both
Eh I have found a way, ig
Right now I am able to check if a line in a file has a certain word and print that word, How would I print the whole line which has that word?
@tasks.loop(seconds=5,count=1)
async def poll(self):
print("Okay 1")
today = datetime.utcnow().strftime("%Y%m%d")
print ("Okay 2")
if today in daily_poll1:
print("Okay 4")
print(today)
else:
print("Okay 5")
print("Cant find it wot?")
Postgres
You don't need to know C for postgres

Postgres has an amazing lib for python
ohk
L
O
L
k ty
on_message is a special kinda function or its just conventional?
You can do something like this ```py
def format_pages(self, pages):
items_per_page = 10
for i in range(0, len(pages.items()), items_per_page):
next_pages = pages[i : i + items_per_page]
page_entry = ""
for page in next_pages:
# page is a tuple containing 2 items
page_entry += f"{page[0]} {page[1]}" # Do whatever you want here
return page_entry```
id = ctx.selected_options[0]
member = discord.Guild.get_member(self, user_id=id)
AttributeError: 'Test' object has no attribute '_members'
and yes id is valid i tested its an integer
it needs to be the guild instance
Maybe you meant ctx.guild.get_member(user_id=id)
Hello! How to localize discord bot?
For example, I have info about selected language in every guild in my database.
Define guild
yeah this fixed it
i was just being dummy
SyntaxError: EOL while scanning string literal
{what does, this error mean?}
thanks @hasty iron
embed.add_field(name="Description", description="Use this commmand to check the BOT's ping", inline=False)
Error = TypeError: add_field() got an unexpected keyword argument 'description
I don't see any type errors
use value instead of description
ahh
help please
@drifting arrow Could I disturb you for a sec
@tasks.loop(seconds=5, count=1)
async def poll(self, message):
print("Okay 1")
today = datetime.utcnow().strftime("%Y%m%d")
print("Okay 2")
for single_line in daily_poll1.splitlines():
if today in single_line:
print("Okay 4")
print (single_line)
channel = self.bot.get_channel(789809104738189342)
await channel.send(single_line)
daily_poll1.close()
else:
print("Okay 5")
print("Cant find it wot?")
TypeError: poll() missing 1 required positional argument: 'message'
Why does it say that even though I put in message?
I hv a def on_message which is doing more than 1 task how can i make many functions doing these tasks cuz it seems that on_message is a special function name(myb idk much yet)?
Can Someone give me music commands for bot
You aren't parsing the 'message' through. whatever that is
Yeah dw I got it- I am so close to finally doing this
any1 know
Can you show your code?
@client.event
async def on_message(message):
username_mention = message.author.mention
username = str(message.author).split('#')[0]
user_message = str(message.content).lower()
chanel = str(message.channel.name)
print(f'{username} : {user_message} ({chanel})')
for i in range(0,len(HELLO),1):
if username == str(client.user).split("#")[0]:
return "avoiding bot"
if HELLO[i] in user_message :
print(username_mention)
general_channel = client.get_channel(GENERAL)
print('executed')
await general_channel.send(f'Hello {username_mention}')
return
for i in range(0,len(BYE),1):
if username == str(client.user).split("#")[0]:
return "avoiding bot"
if BYE[i] in user_message :
print(username_mention)
general_channel = client.get_channel(GENERAL)
print('executed')
await general_channel.send(f'Hello {username_mention}')
return
if user_message == 'what is the version':
general_channel = client.get_channel(GENERAL)
await general_channel.send(f'The verion is 1.0 {username_mention}')
return
if user_message in LIST:
general_channel = client.get_channel(GENERAL)
await general_channel.send(f'Language!!')
return ```
this func does more than 1 task whihci dont want
.command function exists
also here on_message is a keyword or something
!d discord.ext.commands.Bot.command
@command(*args, **kwargs)```
A shortcut decorator that invokes [`command()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.command "discord.ext.commands.command") and adds it to the internal command list via [`add_command()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin.add_command "discord.ext.commands.GroupMixin.add_command").
this?
its just a function name
Hi, I'm re-creating (and not forking) discord.py (called Disthon) using the code form discord.py, discord.js and Sapphire framework.
I need programming experts to lend me a hand with the project. If anyone's interested in contributing, please reply to this message
~~How do I make @group.command() case insensitive ? ~~
Ye, I figured it out
Ok
Thank You!!
Whether the commands should be case insensitive. Defaults to False. This attribute does not carry over to groups. You must set it to every group if you require group commands to be case insensitive as well.
What should I do if I want to get an input for a particular command as a web page? Should I change it to a django project?
help please
can i get a user from his name and tag?
Are they in the discord server? or do you want generic? check if they exist at all?
generic
and are you tagging them in a command? like $find @drifting arrow ?
!d discord.Guild.get_member_named
get_member_named(name, /)```
Returns the first member found that matches the name provided.
The name can have an optional discriminator argument, e.g. “Jake#0001” or “Jake” will both do the lookup. However the former will give a more precise result. Note that the discriminator must have all 4 digits for this to work.
If a nickname is passed, then it is looked up via the nickname. Note however, that a nickname + discriminator combo will not lookup the nickname but rather the username + discriminator combo due to nickname + discriminator not being unique.
If no member is found, `None` is returned.
Oh that's a thing?
I was gonna suggest like 5 different other things but here's a thing that does it all in 1 line
neato i guess
what if its not server specific?
You can use normal get member I think
Well if you can tag them like ( @drifting arrow ) they're already in the server anyway. so you can run a command using the member function
Which database should I use for making levelling system and economy system of my discord bot if I am using replit?
MemberConverter can get the member from name#discriminator iirc
Try aiosqlite?
Also, discuss this in #databases.
stuff gets wild in other channels
works in replit?
I assume so since someone keeps bugging me about their sql code
they use pretty much the same thing
yeah
also the id yes
btw how can i know the total number of messages in the current channel?
ok
i'll change it
wut
!d discord.TextChannel.history
async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the destination’s message history.
You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.
Examples
Usage...
it is for creating custom invite link for a discord server
bruh
without boosts
ok
i'll change it
why do you need a custom invite link? what's wrong with the standard?
oh apparently it linked. who woulda thunk
random letters /shrug
just checking it and how it works
i don't need it
means how can i know the total number of messages?
Honestly just better off creating a non-expiring discord invite and if you post it on a website just change the url text or whatever
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
!d code
Source code: Lib/code.py
The code module provides facilities to implement read-eval-print loops in Python. Two classes and convenience functions are included which can be used to build applications which provide an interactive interpreter prompt.
there is no other way
got it
Whats the website to save alot of code??
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
how can i change the url text?
On a website? depends. if it's a website you own and edit, you can use the url anchor tag <a href="discordinvite">Join my discord!</a> or if you're on reddit, just change the text. etc.
Most websites these days have a way for you to format links so they look like a facebook.com link but it's actually facebock.com where you steal their data
what if i wanna send it in discord?
Discord will make that giant box appear
saying "Developers discord click this shiny button to join"
what does that limit=200 do?
how to count a mentioned reply as a parameter for discord.Member ?
what
Limits the number it checks to 200
i don't want to
i want to check the full channel
tbh i am making clearchannel command
like this is a reply but if a command is used it wont take your user as a parameter
You're making a clear channel command but want to grab all the messages?
yah
What do you want to do with the messages you grab? log them? or just delete?
check Message.reference ig
!d discord.Message.reference
The message that this message references. This is only applicable to messages of type MessageType.pins_add, crossposted messages created by a followed channel integration, or message replies.
New in version 1.5.
@Client.command(pass_context = True)
async def clear(ctx, number):
mgs = [] #Empty list to put all the messages in the log
number = int(number) #Converting the amount of messages to delete to an integer
async for x in Client.logs_from(ctx.message.channel, limit = number):
mgs.append(x)
await Client.delete_messages(mgs)
just got this from stackoverflow
lemme try
@ocean leaf why copy code
its old code
yeah that's not gonna work
and that clears messages not count them
It's purge thesedays
i honestly think that's what he has been trying to do this whole time
he's just confused on how to do it
there are even examples on the doc page
not ccopying
this indicates lack of knowledge
just reading
please learn python before trying discord.py
"just reading" "lemme try"
and made my own
"just got this from stackoverflow"
i didn't try
sure man
Calm down. relax. If you take that attitude. Why dont you stop using discordpy and connect to the api yourself?
what attitude
He has copied like 4 lines which we all know wont work
here we go again with people picking up my "attitude" from messages
next time pick up my tone
There's nothing wrong with what he did
i didn't copy
i read the docs
they have tagged it
hey buddy ur attitude don't match our community 😅
dude
😮
that's what i did
i just pointed to the fact that i made a wrapper myself
cuz the guy said to stop using dpy
im working on my own aswell
and what about the previous messages
hes not being aggressive 😐
ok lets drop this
👀
discordpy will eventually stop working. Some parts may break. some wont have all the new fancy stuff. But eventually it'll stop. But by then we'll move to whatever replaces it
atm i think it's disnake or whatever
atm its none
disnake is meh
they're all shit
disnake is the leading one from what I can pick up
Whenever someone asks for a fork, it's always disnake
no fork is going to be at the quality of the original for months
^
we have pycord with their game breaking discord.Bot
Lol
for some reason they decided that that was a good idea
why.
I use pycord but I don't use the slash commands because it interferes with my prefixed commands
I only use the buttons/select menus as of now
those are in the normal 2.0
Then use dpy v2.0
Aight. I know ya'll like me so much. Wanna give me a code review?
lol
ok
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
\o/ code review time https://paste.pythondiscord.com/izonuxegen.py
This is my adminlogs i made today
I'm looking for:
-This is nice.
-This could be shorter/better [explain how]
stick to PEP8 :)
also so many useless imports
alright. removed useless imports
and that picking up the deleter from logs might not always work
iirc if you delete your own message it wont show up there
It will work
you're pretty much ok just by using the message object itself
I tested that one the most Lol
It's how I found out that discord caches stuff
If your bot is online, your bot will cache all messages.
yeah thats what I meant
which defaults to 2000 i think
I assume it deletes the oldest one first? if so, that's also fine
Besides, you dont want to get notified about something sent a month ago. just recent.
Which is fine
@help.command()
async def ping(ctx):
``` So I used `ping` as a command and this is the help version. But its giving me error since i've used it. Do I need to import something?
Guys, how can I have my game activity exactly like this
Whats the name of the plugin
I tried this one but it doesnt looks cool
Extension. named Discord Presence
What does @help.command() do?
Could you send a link?
gives an embed where it explains what the command does
I got it
Omg. is there a documentation for that? or something so I can further read it? Been wanting something better than the giant list I get when I do $help
ye ty
Huh
Btw. my $help list is now 2 embs ;-;
Oh, i just saw off youtube
Does it work with py?
it did with VSC
Alr
But i'm transferring to replit (IK Leave me be)
Wot
Py what?
it's just a plugin and you wanna make it cool?
It doesnt look great
Or god
good*
that isn't the point tho
For me it is
How to localize bot using gettext or something else?
make ur own RPC then..
Funny
𝖲
i am working with json and in discord.py :/ i am trying to store guild id in json file but it is showing keyerror in int so i tried str() but it is also giving error
Code?
Any word on discord.py alternatives?
That's just UON
when you do $help for your bot to view all commands, it'll break it into separate embs if necessary
Universal Object Notation, not only in JSON, python dicts cannot have int as keys
str(int)
help please
tellllll
they can?
>>> dict = {1: 3}
>>> dict[1]
3
Huh, new thing to learn each day I guess
how i can specify to convet a int to str with double quotes >:/
I'm writing the code but it resets lol, gimme some time to write it
When you dump the data into a file, Python automatically converts all single quote string into double
To convert int to string, just str(int)
if guild.id not in data:
data[guild.id] = {"afk": []}
if ctx.author.id in data[guild.id]['afk']:
data[guild.id]['afk'].remove(ctx.author.id)
else:
data[guild.id]['afk'].append(ctx.author.id)
One method I get thought of @steep estuary
Hi, I'm re-creating (and not forking) discord.py (called Disthon) using the code form discord.py, discord.js and Sapphire framework.
I need programming experts to lend me a hand with the project. If anyone's interested in contributing, please reply to this message
Show full traceback please
dont ping random people
isn't andy already in? How many people do you have and need currently?
I'm just getting as much as contributors as possible
Since the dev team is full now
yup
andy is in?
yep
yeah
Key error means that key does not exist
you could probably get nova too (431677941722906625) since he always cries about making something
Ahuh! we've solved the issue.
how many buttons can i get in a row?
but i am making it here ?? is it correct way to make?
Try printing the dict
also you're never closing the file which is bad
Yups... Use a context manager
you're opening it inside the arguments but never close it
this is the json file
5
Rows in a message --> 5
Button in a Row --> 5
Selects in a row --> 1
Soo, a message can contain a maximum of 25 buttons or 5 dropdowns
😮
Imagine sarcasm
json will also convert int to str automatically??
You gotta do that manually
str(int)
should i use this
Nope, there's a simpler way
for key yes, for value no
Well JSON will raise an error if the key is int...
I have provided answer, it should be like
{
"server id": {
"afk": [
28263826836,
38362862826
]
}
}
it worked
oh-
To check if a user is afk, you just do user.id data[str(guild.id)]['afk']
sighs
this worked but than also it gave a error
Now I need something else to add to my bot
The structure is wrong
?
than what is correct?
.
It's still raw, missing the open and close of the JSON file, some str() but that should give you the rough sketch
And the json structure will be like this
And this is to check
Basically the command is a toggle, if you're in the list, bot will un-afk, and vice versa
Hello
hi
but i want the afk variable inside the user id :/
That would be too nested
its better if you used a database
hmm
ok
yes a database does that
U forgot to await something
\o/
uhhh
can someone help me?
@client.command()
async def stealthban(ctx, ping : discord.Member = None):
try:
ping_id = ping.id
except:
pass
author_id = ctx.author.id
reason = "stealthban jutsu"
if author_id in trusted_json:
if ping_id == varsfile.creator_id:
user = await client.get_user(author_id)
message = "how dare you try to ban Master Radium!"
await client.send_message(user, message)
else:
await ping.ban(reason=reason)
await ctx.message.delete()
else:
pass```
if author_id in await trusted_json
ehhhh
Yea
can someone help me?
u sure?
101%
no need to spam
ill send u my code if u can help me fix it
send it
Is that a threat?
Felt like a threat.
no
K send code
you dont need to send your code. The error means that you triggered the command but didn't pass a required argument
ok
hey
hi @slim gust
sm1 has free discord bot code?
i send u it in dms cause i dont want everyone to see my code
Someone help me. This is my code.
https://paste.pythondiscord.com/situtuvago.sql
@slate swan just send it here. they dont care that it's about roblox
send what?
Your code..
you just... Need to specific the argument when invoking the command
Remove any sensitive information and send. honest, the people who are gonna help you wont care what it's about. and those who do want roblox code will do it themselves.
Hey @slate swan!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
like !check @user you specified the first arg
also you should use aiohttp
no it gets the guild by id
depends on where you put it
whats that
guild = discord server
@client.event
async def on_message(message):
id = client.get_guild(ID)
channels = ["commands"]
if str(message.channel) in channels: # Check if in correct channel
if message.content.find("!hello") != -1:
await message.channel.send("Hi")
elif message.content == "!users":
await message.channel.send(f"""# of Members: {id.member_count}""")```
then yes it gets the guild id everytime a message appears
guild is server?
yes
While discords naming conventions make actual sense. since there's no introduction to discord, people don't use the proper terminology
and thus it can get confusing at times
oh
@client.event and @client.listen("on message") are the same??
not really
one overrides process_commands, one doesnt
.listen can be used multiple times within the same event, .event cant
no guild is discord squads coming in a new update later this year
ohk any example if u hv
Kylee God Coder
Hey, just wondering if you can have an if inside an elif? In my head I think it should work but when I am trying my code it doesn't really work.
I understand what I said can be a bit confusing so just tell me if you want to see the code to understand (it's a bit much code tho)
whatever 
@bot.listen()
async def on_message(message):
. . . .
This way, no need to process commands
process commands?
x = 5
if x == 4:
#code
elif x == 6:
#code
else:
#code
wrong syntax :)
@surreal sierra ^
....?
i meant usage, but you get the point
elif is short for else if
Wym wrong usage....?
@bot.listen('on_message')
both are correct
you just did @bot.listen()
and?
Yea... on_message kills all your commands until u don't add bot.process_commands(message), but no need to do that with listen
More like
z = 9
x = 5
if x == 4:
#code
elif x == 6:
if z == 9
#code
else:
#code
else:
#code
Bet
uh i was giving an example about what you asked
Yeah but that was not really what I meant
huh, is this even dpy question 
🤷
Oh okay, I just was wondering if it didn't work because my bot doesn't do what I want it to do
you saw nothing
lol
i saw that
!e
x = 5
y = 10
if x == 6:
print("x was 6")
elif x ==5:
if y == 10:
print("x was 5 and y was 10")
@spring flax :white_check_mark: Your eval job has completed with return code 0.
x was 5 and y was 10
@surreal sierra ^
Yeah, then I just don't understand why my script doesnt work like I want it
my bad
You should ask in #python-discussion or open up a help channel #❓|how-to-get-help @surreal sierra
Okay thanks! I will do that
the official ones
docs for?
i dont know but i dont understand a thing
i obv dont want to read the same things again but i dont know where to start in it
the official docs
!codeblock
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
!d discord
In order to work with the library and the Discord API in general, we must first create a Discord Bot account.
Creating a Bot account is a pretty straightforward process.
@bot.command()
@commands.cooldown(1, 30, commands.BucketType.user)
async def hub(ctx):
channel = bot.get_channel(885206406385524757)
embed = discord.Embed(title="Command Log", description="Hub commando")
embed.add_field(name="Author:", value=f"{ctx.author.mention}")
embed.add_field(name="Bericht:", value=f"{ctx.message.content}")
await channel.send(embed=embed)
embed = discord.Embed(title="Hub informatie:", description="Zie hieronder de info.")
results = requests.get('https://games.roblox.com/v1/games/2857480150/favorites/count').json()
content = results[0]['favoritesCount']
embed.add_field(name="Favorites:", value=content)
embed.add_field(name="Link:", value="https://www.roblox.com/games/7322780412/Colza-productions-HUB")
await ctx.send(embed=embed)```
I dont get an output or error
bruh
Please 😛
add a print statement and see if it gets printed
whats the diff b/w client = discord.Client(), bot = coommands.Bot(command_prefix='$')
It doesnt print
commands.Bot has command extension feature while discord.Client doesn't, commands.Bot inherit discord.Client. meaning commands.Bot has discord.Client's feature, but with more additional feature
ohk cool i was thing they were different
I tried bot.listen and process commands but still nothing
Oh wait File "/home/container/.local/lib/python3.9/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "/home/container/bot.py", line 64, in on_ready
await bot.process_commands(message)
NameError: name 'message' is not defined
why do you have process commands in on_ready
👀 uh
@bot.event
async def on_message(message):
if message.content in blacklist:
await message.delete()
await message.author.send("Dit woord is geblacklist")
print(f"{message.author} heeft een geblacklist woord gestuurd")
await bot.process_commands(message)
dm me if you can help me
looks fine to me
did you save the file?
!d discord.on_message
discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
Warning
Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
all of it?
Not my hole bot, but that never had issues
send all of the code
I cant sorry, Its teammade and I dont have perms to share all data
any errors?
Nope, the hole output and terminals are empty
Im trying It without the on message event to make sure
Without on message It doesnt do anything either
The first line : discord.py offers a lower level aspect on interacting with Discord what does this mean btw??
Is It maybe because of the api? Since I use the same for a other api command but an other api
Idk If that api works with that
dm me if you can help me
!codeblock
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
@bot.command()
@commands.cooldown(1, 30, commands.BucketType.user)
async def hub(ctx):
responseees = requests.get('https://games.roblox.com/v1/games/2857480150/favorites/count').json()
test = responseees[0]["favoritesCount"]
embed = discord.Embed(title="Hub informatie:", description="Zie hieronder de info.")
print(test)
embed.add_field(name="Favorites:", value=test, inline=True)
embed.add_field(name="Link:", value="https://www.roblox.com/games/7322780412/Colza-productions-HUB", inline=True)
await ctx.send(embed=embed)```
This Is what I have now
Why is everybody suddenly working with python?
idk
Oh, I dont play It.
Yeah that's it. roblox.
I just get paid for the bots for them
How? what? where? where can I go to get paid to make a bot for roblox
How are you advertising? 🤔
and how do they find you
Every bot Is another ad for me
If you have a bot developer rank In an server people will get interested
and remember you for If they get one
@ionic wadi just tell me how to get started doing roblox stuff so I can earn money xD
perhaps want me to work with you ?
No
Can please get back on topic here
Sorry @bitter depot lol
i remember i was asking for 2 dollars just to buy a vps and code the bot for osmeone lmao
oh alright
get back on topic
but yeh
You have a form for me about that xd
its not working ?
Yeah I know
nop
i agree 
is there a error ?
nope nothing
maybe in the decorator
do you have an error handler
let me see
https://stackoverflow.com/questions/55063189/aiohttp-meme-command-discord-py
Does this explain It right?
I only use post and get xd
like this
import aiohttp
bot = # bot definition
async def create_session():
bot.session = aiohttp.ClientSession()
bot.loop.run_until_complete(create_session())
bot.run()
and then use bot.session
^^^
And this does xD?
although its better to subclass cuz that way you can close the session
just do it in ur on_ready func
read the code and you'll understand
no
can someone help me?
What I read there It makes a session that I can use to get the api data?

exactly, we're creating the session that we're going to use to grab the data from the api
and inside a command it'll be
async with bot.session.request(*args, **kwargs) as response:
...
Have to put the create session above events or?
doesnt matter, just have this bot.loop.run_until_complete(create_session()) above bot.run
i used AioHttps to make some requests and i didnt use that.
class spin (commands.Cog):
def __init__(self,bot) -> None:
self.bot = bot
@commands.command()
async def spin(self,ctx,) -> str:
global r
lst = ['careful from hitting ur head while spining', 'spinned too fast that he traveled across the universe','spin spin spin']
async with aiohttp.ClientSession() as session:
async with session.get('https://kawaii.red/api/gif/spin/token=mycooltoken/') as r:
if r.status == 200:
js = await r.json()
embed = discord.Embed(title=f'{random.choice(lst)}',description=f'{ctx.author.mention} IS SPINNING')
embed.set_image(url=js['response'])
await ctx.send(embed=embed)
await asyncio.sleep(4)
await ctx.message.delete()
@spin.error
async def spin_error(self,ctx,error):
if r.status != 200:
await ctx.send('the api is dead')
def setup(bot):
bot.add_cog(spin(bot))
``` this was the code
that can work as well
its better cause making a global session conflicts with the bot's session
what would be the benefit of having
bot.loop.run_until_complete(create_session()) then ?
!codeblock
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
@bot.command()
@commands.cooldown(1, 30, commands.BucketType.user)
async def hub(ctx):
response = requests.get('https://games.roblox.com/v1/games/2857480150/favorites/count').json()
data = response[0]["favoritesCount"]
async with bot.session.request(*args, **kwargs) as response:
embed = discord.Embed(title="Hub informatie:", description="Zie hieronder de info.")
print(data)
embed.add_field(name="Favorites:", value=data, inline=True)
embed.add_field(name="Link:", value="https://www.roblox.com/games/7322780412/Colza-productions-HUB", inline=True)
await ctx.send(embed=embed)```
Would this do the job?
response = requests.get('https://games.roblox.com/v1/games/2857480150/favorites/count').json()
data = response[0]["favoritesCount"]
``` this is not needed anymore
and replace *args and **kwargs with the arguments that you need
ok
coroutine async-with get(url, *, allow_redirects=True, **kwargs)```
Perform a `GET` request.
In order to modify inner `request` parameters, provide kwargs.
thats what you need, no clue why request doesnt have a link
@bot.command()
@commands.cooldown(1, 30, commands.BucketType.user)
async def hub(ctx):
coroutine async-with get('https://games.roblox.com/v1/games/2857480150/favorites/count/', *, favoritesCount)
async with bot.session.request(favoritesCount) as response:
embed = discord.Embed(title="Hub informatie:", description="Zie hieronder de info.")
print(data)
embed.add_field(name="Favorites:", value=data, inline=True)
embed.add_field(name="Link:", value="https://www.roblox.com/games/7322780412/Colza-productions-HUB", inline=True)
await ctx.send(embed=embed)```
its not coroutine async-with
...
yeah, and intialize ClientSession
async def create_session():
bot.session = aiohttp.ClientSession()
I have this at the top
so im trying to code a discord bot
so i have this line of code that says 'print('We have logged in as (0.user)
'.format(client))'
but then it says
file 'main.py', line 11
print(We have logged in as (0.user)
^
SyntaxError: EOL while scanning string literal
does anybody know how to fix this
it in python btw
ping me if u can
also im using replit if that makes a difference and im new to coding
Note: Put a space at the beginning of the text so theres a space between username and text
thx
sum(1 for i in bot.walk_commands())
``` in this how can i check how many cmd can be used by the author?
await can_run(ctx)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Checks if the command can be executed by checking all the predicates inside the [`checks`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command.checks "discord.ext.commands.Command.checks") attribute. This also checks whether the command is disabled.
Changed in version 1.3: Checks whether the command is disabled or not
umm
sum(1 for i in bot.walk_commands(await ctx.author.can_run(ctx)))
like this?
did not work
print('!bot 1'" We have logged in as")(0.user)
'.format(client))
it would error
print('We have logged in as {0.user}'.format(client))
also it's recommended to use fstrings instead
Learn python first then try discord.py the error you got is a minor error lol
^
Obviously you forgot a parentheses
^
It's 1 not i
sum(i.can_run(ctx) for i in bot.walk_commands())
wait, walk_commands is a thing of bot?
I thought it was cog
but it just works fine lol
!d discord.ext.commands.Bot.walk_commands
for ... in walk_commands()```
An iterator that recursively walks through all commands and subcommands.
Changed in version 1.4: Duplicates due to aliases are no longer returned
oh
By the way, is there a less time-consuming way to restart the whole bot?
It's kind of a pain to restart Vscode everytime I want to restart my bot
bot.reload_extension
Hi, I'm re-creating (and not forking) discord.py (called Disthon) using the code form discord.py, discord.js and Sapphire framework.
I need programming experts to lend me a hand with the project. If anyone's interested in contributing, please reply to this message
how do i go on about passing my message from main.py here
@client.event async def on_message(message): print(message.content) usermessage = message.content return usermessage
to my learn.py here
`def mainlearn():
dictionaryFile, inputFile = readArguments()
dictionary = loadDictionary(dictionaryFile)
if inputFile == "":
#interactive mode
while True:
userInput = usermessage
if userInput == "":
break
dictionary = learn(dictionary, userInput)
updateFile(dictionaryFile, dictionary)
print("learnt")
else:
print("not implemented")`
how do i do view=view(ctx) in on_message_edit
?
What do you want to do?
Just do something like this
view = View(ctx)
await send(view=view)
i want to know how to add a view button to on_message_edit event
so u say u can use ctx in on_message_edit
use get_channel and then TextChannel.send
Sure... await bot.get_context(after)
# on_message_edit has ``before`` and ``after``
# which are Message objects, with that you can
# get the context
ctx = await bot.get_context(after)
view = view(ctx)
ok
!rule 1
1. Follow the Python Discord Code of Conduct.
!rule 2
2. Follow the Discord Community Guidelines and Terms Of Service.
!rule 3
can someone help me?
@stiff nexus 😂the redirect URI is damn good in the bot invite. GG
Sure
i did not get u
oh
lol
that works?
you're not supposed to do it like that
i feel like you're breaking some kind of thing
like?
someone help me. this is my code.
https://paste.pythondiscord.com/situtuvago.sql
this is the error it is giving me
are u talking to me?
yes?
You ain't passing the user argument to the command
can u dm the ss of it?
why
how to do that?
Like, !kick will raise that error but !kick @gritty needle won't
put in here?
what
how do i do that?
no, when invoking the command
coz thats my bot and i want to know why it sent a invite
<prefix>check <cookie here or whatever> <user>
im talking about the redirect uri
is there a way to check if a PartialEmoji is usable by the bot? Or try to convert PartialEmoji to full Emoji?
!d discord.Emoji.is_usable
is_usable()```
[`bool`](https://docs.python.org/3/library/functions.html#bool "(in Python v3.9)"): Whether the bot can use this emoji.
New in version 1.3.
yes, but what about a PartialEmoji.
isnt partial emoji given when the bot cant see the emoji?
I'm constructing my PartialEmojis myself
I kinda have a custom emoji hardcoded in my code, and when testing with my test bot it can't see that custom emoji
If the partial emoji is not a unicode emoji, access the name attribute and pass that into Bot.get_emoji
If it returns anything but None the bot should be able to use it
great solution, thank you
Yeah, that's not what I asked
I don't want to reload the extension, I want to reload the bot
Do it for all bot extensions
Will do the same
Unless you wanna clear the cache
I literally want to kill the bot
How do I make pagination out of this list with the emoji controlling feature? Like 20 elements of a list in 1 page of embed and 20 in other?
Code:
@bot.command()
async def page(ctx):
lis = [1,2,3,4,5,6,7,8,9,10,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40]
embed=discord.Embed(title="Pagination out of a list", description=f"{lis}", color=0xe7b913)
await ctx.send(embed=embed)```
And restart it
I don't want to reload the extensions, I want to literally restart the whole bot through killing it
While also clearing the cache, of course
hi does digitalocean good for hosting discord bot? i got the github student pack and i am thinking that should i use replit, digitalocean or microsoft azure. which one of the three is the best?
is 100$ enough
Digital Ocean expensive
Use galaxygate maybe
I've never used any of these tho
Can't compare
yes. i have only three of it
thanks
is there anything else on the github student pack good for hosting?
...
You will have to make the most of it, and expire as in the credits disappear
ok.
Hi, I'm re-creating (and not forking) discord.py (called Disthon) using the code form discord.py, discord.js and Sapphire framework.
I need programming experts to lend me a hand with the project. If anyone's interested in contributing, please reply to this message
hello
How many people do you currently have working on the project?
About 12
Including me
Does anyone here have any information about cogwatch?
Forgot that- Thanks! lemme try

