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.
1 messages · Page 990 of 1
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.
delete that msg
How could I make a discord bot with python from scratch?
you could use a wait_for
:,v
english only
watch tutorials
noooooooo
What does this mean https://paste.pythondiscord.com/ezacomuvur
@slate swan that is , the same way to process as the buttons ?
happens some
sori sent the wrong one
ok np
sheesh, which library?
I just wanted to send. How many Russians I started meeting but accidentally sent this
@brave forge you're using discord.py or what library?
yes yes
yes what?
lol
https://paste.pythondiscord.com/ifujucebeb 😔 why is this happening
@slate swan Yes, I use discord.py
If you wish to use Buttons (and Selects/Dropdowns), please view the documentation for discord.ui here: https://discordpy.readthedocs.io/en/master/api.html#bot-ui-kit
You can also view examples in the repo: https://github.com/Rapptz/discord.py/tree/master/examples/views
@slate swanfor buttons I remember using "from discord_components import Discord Components, Button, ButtonStyle" but it didn't work
are you using discord.py 2 or 1.7.3?
you cant name a function like you did
пред can't be used in python for naming a class/variable/function
how to view the version discord.py
I just copied it from someone
use @bot.command(name="пред")
Can you DM me the code pls
print(discord.__version__)
guess what i find
@slate swan any idea?
no sorry i can't spoonfeed, read this
#discord-bots message
so hi i have tried to create a discord music bot but every time i try to run it i get a Self.client=client
IndentationError: unexpected indent Error
here is my code:
https://paste.pythondiscord.com/egobicajab
just a moment
sure
and this is my cog itself
''' how I load it '''
[bot.load_extension(f"./cogs/{file[:-3]}") for file in os.listdir("./cogs") if file.endswith(".py")]
disnake cool
version 1.7.3
better upgrade to dpy 2
what's your file structure
does my entire software code break then ?
well, it shall
got a new idea for cmd
!!
did you try using cogs/{file[:-3]} as the path
how to do that when you click the reaction. In the first case, the command continued, and in the second it stopped or displayed a message like no !?
oh wait, thats not how you load an extension
load_extension(f"cogs.{file[:-3]}")
not in this bot*
I recently reset my Token, and now the data in MySQL won’t update? does the token have anything to do with it?
@slate swan how to do that when you click the reaction. In the first case, the command continued, and in the second it stopped or displayed a message like no !?
if you mean your discord bot token
no, your bot token has nothing to do with the mysql server
hmm alrighty
this type is used entirely instead of discord.py ?
another problem 😔 How do I make a check for a cog?
Like I'm doing this as of now, which obviously wont work
def check_limit(self):
async def predicate(ctx):
user = await self.bot.db.read(query={"key": ctx.author.id})
if len(user['notes']) >= 5:
raise MaximumValuesReached()
return True
return commands.check(predicate)
oh no its easier
class MyCog(commands.Cog):
async def cog_check(self, context: commands.Context):
# this is an in-built cog check
...```
ah
!d discord.ext.commands.Cog.cog_check
cog_check(ctx)```
A special method that registers as a [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") for every command and subcommand in this cog.
This function **can** be a coroutine and must take a sole parameter, `ctx`, to represent the [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context").
uh so is it applied for every command in the cog?
yep
thanks a lot uwu sarthak
Seeing as it has nothing to do with my token it must be my code. So, Ive made it so when a user renames a ticket to {user}-done my database updates their count by 1, however, i recently reset my bots token and now that doesnt work. But, other parts of the database works, like adding users to the database and so forth. Here's my code:
users = sorted(users.items(), key=lambda x: x[1], reverse=True)
for i in users:
mycursor.execute(f"SELECT * FROM logs_info")
for i2 in mycursor:
if str(i2[1]) == str(i[0]):
NewCount = int(i2[2])+int(i[1])
mycursor.execute(f"UPDATE logs_info set count = '{NewCount}' WHERE username = '{i[0]}'")
db.commit()
mycursor.close()
db.close()
I get no errors..
Which database are you using?
@boreal ravine how to do that when you click the reaction. In the first case, the command continued, and in the second it stopped or displayed a message like no !?
how to make cooldown message without using global error handlers, bcs im kinda not liking it eating my errors
json files deta's Base
Add ```py
else:
print(error)
this would be better (needs the traceback and sys module)```py
else:
print('Ignoring exception in command {}:'.format(ctx.command), file=sys.stderr)
traceback.print_exception(type(error), error, error.traceback, file=sys.stderr)
i guess you could do ```py
r, _ = await bot.wait_for(...)
re, __ = await bot.wait_for(...)
❤️
how do i make a coinflip command?
undefinted name "traceback"
anyone?
like i said, needs the traceback and sys module
you have to import
yes..
cog_command_check
How tf are you supposed to test the patreon API if you can't pledge to your own campaign
import random
if random.choice(["heads, "tails"]) == "heads": #picks a random value
...
in discord.py
. . .?
just integrate it into a command
with the . . . ?
What's your best suggestion for keeping a discord bot online? I work on a Chromebook.
Use something that can host your bot
Really, I thought I should use something that doesn't do that
i think https://www.pythonanywhere.com/
Host, run, and code Python in the cloud: PythonAnywhere
maybe.. but ... is the part where you write your own code
ok
@delicate trench over here
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord.ext.commands' has no attribute 'wait_for'
!pypi disnake
Ok, I'll see if I can get that to work once I get to my computer
this is an api wrapper, makes life a million times easier
you need a bot user to use it tho
you need a Client/Bot instance
so just make one at https://discord.com/developers/applications
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
why did you think that?
sarcasm alert
but I have commands now because of cogs
hi can i put events in one class?
thanks
wait before i use cog, i need to how knowledge about cog
to have*
it doesn't look easy but it actually is
make a class where you subclass commands.Cog
ye. but i want to learn what is exaicly cog
your init should look like this:
def __init__(self, bot):
self.bot = bot
k
so like
you make a subclass of Cog
then you make a setup function for it
so when you use load_extension, discord.py calls that setup function for you
or you can call it yourself
i use Grepper
i found this code
from discord.ext import commands
class Test_Cog(commands.Cog):
def __init__(self, bot):
self.bot = bot # defining bot as global var in class
@commands.Cog.listener() # this is a decorator for events/listeners
async def on_ready(self):
print('Bot is ready!.')
@commands.command() # this is for making a command
async def ping(self, ctx):
await ctx.send(f'Pong! {round(self.bot.latency * 1000)}')
def setup(bot): # a extension must have a setup function
do you use 2.0?
This looks fine except setup is empty
what do you mean?
dpy2.0
Well not perfect but conceptually it is valid
i didn't copy it all
do you use discord.py 2.0
how to see my d.py v?
print(discord.version)
my discord.py v 1.6.0
I have a dumb question, I saw they had discord.js would it be better in the long run to start and stay in python or is discord.js a good start, I plan on working on creating my own version of Carl bot and have never tried to make a project this big before.
its depend
I have made some basic bots before just using py but I just learned they had js so wasn’t sure if it was a good idea
are you great at discord.py/python or you great at js?
I mean, Carl bot is coded in python
I have done only py so far so wasn’t sure if js would be anything interesting
idk i want to help but i am not good advicer
what i know you will work with difference stynx
oh shit i forget its ifter
bye
I’m just not sure what discord’s plan was for py and js, I was wondering which would be better in the long run
iftar?
both..
they are practically the same
both have all the new features
you just make requests/ws connection to the api, doesnt matter what language you use
Ok so just personal preference basically
client.crypto_pages = [cryptoEmbed, cryptoEmbed2, cryptoEmbed3, cryptoEmbed4, cryptoEmbed5, cryptoEmbed6, cryptoEmbed7, cryptoEmbed8]
current = 0
async def button_callback(interaction):
await interaction.response.edit_message(content=client.crypto_pages[current+1])
msg = await ctx.send(embed=client.crypto_pages[current], view=view)```
ite easier because of its syntax and keywords
obviously..
i was trying to scroll through embed pages using buttons but for some reason the interaction.response.edit_message part doesn't seem to do anything rn. did i mess up smt?
yes
Yeah I don’t know much on js so that’s why I was asking
lol
and most libs provide an inbuilt/external command handler(s)
lol
if you want to code faster use python

Yeah I have always used py just wasn’t sure if it was anything different for js
But if it’s personal preference definitely sticking with py
.bm
the last question is it retoric
I made a slash command to test but it don't show when I use the slash?
@bot.slash_command() async def hello(ctx, name: str = None): name = name or ctx.author.name await ctx.respond(f"Hello {name}!")
try using a simple send instead of a response
like await ctx.send?
"You need to verify your e-mail in order to perform this action."
how do i verify my email?
one thing's for sure
your label is a tuple
and you're checking if it's a string in the if statement
say i have to store one or two variables (externally) how should i store them?
!bot-var
Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:
bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"
@bot.command()
async def get(ctx: commands.Context):
"""A command to get the current value of `test`."""
# Send what the test attribute is currently set to
await ctx.send(ctx.bot.test)
@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
"""A command to set a new value of `test`."""
# Here we change the attribute to what was specified in new_text
bot.test = new_text
This all applies to cogs as well! You can set attributes to self as you wish.
Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!
and how can I create a team without a tuple ?
if you're updating these variables frequently you probably want a database, and for stuff like configurations a file is fine
one or two
...
the Russians in this case say and fuck you're sticking your nose out of your business
ok
no matter what, a slash command will say interaction failed if no response comes
or an interaction
yes
make sure to put something at the end to see if your buttons even worked
out of all if statements so it surely returns something
also, language
!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.
@slate swan
and where did you find all the access rights of discord ??
the what
what is this guy talking about
async def question(message):
redditsub = reddit.subreddit('AskReddit')
num = random.randrange(1, 100)
for post in redditsub.hot(limit=num):
await message.channel.send(post.title)
return```
this command is supposed to choose any random reddit post but it always chooses the same one. what's wrong?
I and fuck am sticking my nose out of my business
😔
just have get all the subs and put them in a list and pick a random element
that gave me a stroke
ikr
Hi
yeah it would go through a list of elements, but you return after sending the first one
when i didnt put the return it just spammed
I think all you wanna do is just
await message.send(random.choice(redditsub.hot(limit=100)))
which looks complicated but really isn't
and don't name a Context instance message next time
uh is it a list
redditsub.host()
i just want to choose a single post
i should mention i only want posts from that subreddit.
so hi i have tried to create a discord music bot but every time i try to run it i get a Self.client=client
IndentationError: unexpected indent Error
here is my code:
https://paste.pythondiscord.com/egobicajab
no colon after def
!yt-dl
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
@main sonnet ^
completely forgot about that lmao
is channel : discord.Channel a thing
like, i want the user to input a channel
is the discord bot written in python?
Our community bots are
!contribute - if you are interested in knowing more about them
Contribute to Python Discord's Open Source Projects
Looking to contribute to Open Source Projects for the first time? Want to add a feature or fix a bug on the bots on this server? We have on-going projects that people can contribute to, even if you've never contributed to open source before!
Projects to Contribute to
• Sir Lancebot - our fun, beginner-friendly bot
• Python - our utility & moderation bot
• Site - resources, guides, and more
Where to start
thanks
how to setup a on_message event in a cog
@commands.Cog.listener()
async def on_message(self,message):
a=message.content
b=message.author
if message.author==self.client:
return
else:
print(a)
await message.channel.send("AALTU FAAltu")
error:'result' object has no attribute 'client'
self has no attribute client
interesting
self is a result, not a cog
you defined the class wrong
no no
show
it's correct
maybe you overwrote it then
Probably just the name of the class
from discord.ext import commands
class result(commands.Cog):
def init(self,client):
self.client = client
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
if isinstance(error, commands.MissingPermissions):
await ctx.send('Sorry you are not allowed to use this command.')
@commands.command(description = 'Kick memebers from the server. NOTE: this command is for those who have kick_members permission')
async def kick(self,ctx, member:discord.Member, *, reason = None):
if (ctx.message.author.permissions_in(ctx.message.channel).kick_members):
await member.kick(reason = reason)
await ctx.send(f'{member} was kicked.')
@commands.command(description = 'Ban memebers from the server. NOTE: this command is for those who have ban_members permission')
async def ban(self,ctx, member:discord.Member, *, reason = None):
if (ctx.message.author.permissions_in(ctx.message.channel).ban_members):
await member.ban(reason = reason)
await ctx.send(f'{member} was banned.')
@commands.Cog.listener()
async def on_message(self,message):
a=message.content
b=message.author
if a==b:
return
else:
print(a)
await message.channel.send("AALTU FAAltu")
return
def setup(client):
client.add_cog(result(client))```
oh well
__init__ not init
done
👋
infinite loop
im still not able to fix this
self.client.user
THANKS!
within a command, how do i test if the ctx.author.id is in a json file
Hello is anyone here
Yes
maybe
!ytdl we won't help with projects using that btw
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
uh okay
It’s against yt TOS
know it now
Open the file and see if the author Id is in there
but like how? ive never used json files before
It's just like a dict
async def question(message):
redditsub = reddit.subreddit('AskReddit')
for post in redditsub.random():
await message.channel.send(post.title + "\n" + post.url)
i changed it and it still does the same
with open(file) as file:
file = json.load(file)
if ctx.author.id in file: # this will check all the keys
...
thx
just figured it out
ok so in my json file, i have this:
{
"965624886657695804"
}
and it says its expecting a colon, but what goes after it?
"965624886657695804" : what here?
there's any way to disable the "banned from api temporaly"?
Probably not. Sounds like a rate limit or straight up ban from accessing an API. What were you doing prior to that?
@paper sluice
Hi I am making a Discord bot and I am trying to make a Dead Chat Ping function that pings @ here if there is no activity in the server for 1 hour.
if message.content.startswith("$EnableDeadChatPing"):
if datetime.datetime.now() - message.created_at == 5:
await message.channel.send("@here")
await message.channel.send("Enabled Dead Chat Ping")
Here there are no compiler errors and the Enabled Dead Chat Ping message comes out too but the @ here ping doesn't which it is supposed to if 5 seconds pass, which I have done as a test
hey so um i tried asking someone about this and he hasnt replied so i still ned help. i have this command:
@bot.command()
async def test(ctx):
with open("premium.json") as file:
file = json.load(file)
if ctx.author.id in file:
await ctx.send("Testing")
and this in my json file:
{
"965624886657695804" :
}
what goes after the colon?
Use a list to store singular data
str(ctx.author.id), since you save the json keys as string
pls explain, bcs as i said, ive never used json file before
What doesnt work?
it wont send the message after testing if my id is in the file
Remove the " from json
ok so i wanna delete the users command after its used but it says that ctx has no attribute "delete"
!d discord.Message.delete
await delete(*, delay=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Deletes the message.
Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you need the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission.
Changed in version 1.1: Added the new `delay` keyword-only parameter.
!d discord.ext.commands.Context.message
The message that triggered the command being executed.
Note
In the case of an interaction based context, this message is “synthetic” and does not actually exist. Therefore, the ID on it is invalid similar to ephemeral messages.
it would be
await ctx.message.delete()
thx
Trying to make a bot clear command.
put it blank im trying to make it where my bot checks if the author of the message is another bot. if it is a bot they'll delete their message. i'm not completely sure what CHECK to do for it though
!s discord.help
Can you host a discord bot on this
oh really?
I think
Hello m a new memebr on this server
so there's not a if message.author.bot = True ?
for a leveling system in dpy they just give the bot xp as well?
no no
what im trying to get at is like a purge command, but instead of it purging USER messages it purges bot messages. i've seen it done wit multiple bots that use dpy
!d discord.TextChannel.purge you can pass a check to the purge call
await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.
You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own. The [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.
Changed in version 2.0: The `reason` keyword-only parameter was added.
Examples
Deleting bot’s messages...
can you explain how hosting bots works
E.g lambda message: message.author.bot
The purge method will call the check, and only purge if the message passes the check
Has anyone here made a backend for their bot? Im trying to make a SQl DB on a server, build an API on it. Since im using python for my bot would flask/django be solid for backend?
Have a file being ran on that?
I run my bots on a 30gb VPS
can i host it on a normal hosting provider like profreehost or somethhing?
I don't know, probably
do i need a hosting service that has python on it
thats cool man
I host like 15 on there with databases and such and the VPS handles it all
thts really cool where can test ur bots
I am not allowed to promote such things here
But I have a few test servers
ok ok send me bro
DM me then
i sent u a friend req
so I have a command with buttons here,
after I restart the bot it works and responds normally, reacts to the buttons etc.
but if I try to run the command again, it doesn't respond. not on any guild or channel
how can I stop it from listening to button callbacks, how do I stop them with the view.stop
async def reddit(ctx, saymsg):
subredd = reddit.subreddit(f"{saymsg}")
for post in subredd.random_rising(limit=1):
await ctx.send(post.title + "\n" + post.url)```
trying to make a bot that can browse a subreddit, but i dont seem to find a way to do it
why?
i dont think you can, but even if you find a way to it would be too slow for practical purposes
@slate swan how do I subclass View
u can help me with the issue?
can you show your code including the line numbers?
bro why can't it respond to the command again even after stopping the view from every button
i think you meant list(count_members.items()) here at line 59
why can't my bot reply even after stopping every view
it works after restarting bot but then doesn't reply anymore
doesn't work in any guild or channel anymore
I'm trying to make a command that edits the description of an embed in a specific channel, and I'm not really sure what I'm doing wrong, but it says
@client.command()
@commands.has_role('Manager')
async def reason(ctx, msgID: int, *, arg):
channel = client.get_channel(824390745775276092)
message = channel.get_message(msgID)
old = message.to_dict()
edit = re.sub("(\'description\': \'.*\')", str("\'description\': \'" + arg + "\'"), old)
new = discord.Embed.from_dict(edit)
await ctx.message.edit(embed=new)
``` Error is that TextChannel has no attribute get_message. I got the channel.get_message part from this channel
hi, im making a discord bot to send a dm to a user. but i got this error: RuntimeWarning: coroutine 'Discord_Send.dm_codes' was never awaited Discord_Send().dm_codes() RuntimeWarning: Enable tracemalloc to get the object allocation traceback
this is my code: ```class Discord_Send:
async def dm_codes(self):
print("Dm'ing codes")
user = Data.author
embed = Embed(
description = f"**[10% OFF]**",
color = Color.blue()
)
_str = ```"```yaml\n"
for code in Email.codes:
_str += f"{code}\t10% OFF\n"
_str += "```"```
embed.add_field(name = 'Codes:\t', value = _str, inline = False)
await user.send(embed=embed)
you call the command yourself?
first i have a function that sends a message on a command and than calls another function that will open a txt file which thn calls this function
it's fetch_message
you have to await this function
guys I found out what my issue was
replace get_message with fetch_message, discord.Embed with an instance of it and you cannot edit ctx.message
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
How to set volume of the bot in vc channel
are the delays from /slash command down to the code or discord alone staling them kinda thing?
in the new update can i take the user input? (not wait msg to take input)
if you throw a bunch of links into a json file, the program itself will be able to randomly get them from there and use them in embed ?
yes you can
1.load the links list from the json file
wait i didn't use discord from a long time
2.use the random library
3. use the fun random.choice(linksList)
or just use a list
like the input function?
!d input
input([prompt])```
If the *prompt* argument is present, it is written to standard output without a trailing newline. The function then reads a line from input, converts it to a string (stripping a trailing newline), and returns that. When EOF is read, [`EOFError`](https://docs.python.org/3/library/exceptions.html#EOFError "EOFError") is raised. Example:
```py
>>> s = input('--> ')
--> Monty Python's Flying Circus
>>> s
"Monty Python's Flying Circus"
``` If the [`readline`](https://docs.python.org/3/library/readline.html#module-readline "readline: GNU readline support for Python. (Unix)") module was loaded, then [`input()`](https://docs.python.org/3/library/functions.html#input "input") will use it to provide elaborate line editing and history features.
Raises an [auditing event](https://docs.python.org/3/library/sys.html#auditing) `builtins.input` with argument `prompt` before reading input...
he/she said "links into a json file..."
this?
I have a team working on 3 points right now
yeah
i see no reason to why use a json file tbh
idk ask him/her
no you cant it will block your bot you would need to use ainput iirc
how to write links correctly in a json file ??
if youre gonna write links just use a list
no i want to use it in discord something like embed if there nothing like that then i just use wait_for
ah
!d json
Source code: Lib/json/__init__.py
---...
sorry wdym?
like the coro Bot.wait_for? im kinda confused sorry
!d json.dump
json.dump(obj, fp, *, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, default=None, sort_keys=False, **kw)```
Serialize *obj* as a JSON formatted stream to *fp* (a `.write()`-supporting
[file-like object](https://docs.python.org/3/glossary.html#term-file-like-object)) using this [conversion table](https://docs.python.org/3/library/json.html#py-to-json-table).
If *skipkeys* is true (default: `False`), then dict keys that are not
of a basic type ([`str`](https://docs.python.org/3/library/stdtypes.html#str "str"), [`int`](https://docs.python.org/3/library/functions.html#int "int"), [`float`](https://docs.python.org/3/library/functions.html#float "float"), [`bool`](https://docs.python.org/3/library/functions.html#bool "bool"),
`None`) will be skipped instead of raising a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError")...
ops
or just use a regular list.
!d json.load
json.load(fp, *, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)```
Deserialize *fp* (a `.read()`-supporting [text file](https://docs.python.org/3/glossary.html#term-text-file) or
[binary file](https://docs.python.org/3/glossary.html#term-binary-file) containing a JSON document) to a Python object using
this [conversion table](https://docs.python.org/3/library/json.html#json-to-py-table).
*object\_hook* is an optional function that will be called with the result of
any object literal decoded (a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "dict")). The return value of
*object\_hook* will be used instead of the [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "dict"). This feature can be used
to implement custom decoders (e.g. [JSON-RPC](http://www.jsonrpc.org)
class hinting)...
you don't know maybe he want to make cmd to dump and load json
In the new "update" which I assume you mean discord.py v2.0, there is Modals, which allow a user to enter text and hit "submit"
They are only avaliable through interaction responses although
idk the situation but he said about writing lists and getting a random element so
wait brian do you want to do <prefix><context> message here?
@brave forge here how to load json and search about json tut
because you said you want to take a users input without waiting for a message so is that so?
something like that i want to make input box in the embed inself
but thx i don't think there is a way
What do you want to do? 
thx but what i was try to found way to get user input from embed, entering input (input box)
modals!
why is this wrong?
def check(m):
return m.content == 'Join' and m.channel == ctx.channel and m.author == not ctx.author
error says that == not ctx.author is wrong
but idk what would be right
But it doesn't do what you want it to do
then how do i make it do what i want it to do
m.author != ctx.author
ok
I have a verification command (slash command)
How do I know If there is an ongoing captcha which is not complete and won't send another one if there is so (until timer run out).
What is the best way ?
Use slash command and discord modals
Or, not m.author == ctx.author
please ping
You'd need some sort of bot variable:
bot = commands.Bot(...)
bot.ongoingCaptcha: bool = False
@bot.command()
async def start_captcha(...):
if not bot.ongoingCaptch:
# do stuff
will this work if there is multiple people using ?
or should I just do the ez but not bad way to do it like storing user id in json file inside array ?
ok so i have this annoyingly complex battle command and it wont send the winning message at the end unless i say FIRE
@commands.command(name="battle")
async def battle(self, ctx: commands.Context):
await ctx.send(f'The next person to say "Join" will fight {ctx.author.mention}')
def check(m):
return m.content == 'Join' and m.channel == ctx.channel and m.author != ctx.author
msg = await self.bot.wait_for('message', check=check)
fight = await ctx.send("To win, be the first person to say...")
await asyncio.sleep(3)
await ctx.send("FIRE")
def check2(m2):
return m2.content == 'FIRE' and m2.channel == ctx.channel and m2.author == ctx.author
msg2 = await self.bot.wait_for('message', check=check2)
await ctx.send(f"{msg2.author} won the fight!")
nvm
how would i check if a message is in a server rather than a dm in on_message
if message.guild
ty
look how pretty this code is now to update my patreons for discord and get some names 
Why are you using repl?
who's using repl
That looks like repl 👀
it's atom with dark forest theme
Ah, sorry, looks like repl 😅
replit is slightly uglier
how can i make it where if you put a certain word in your status it sends a message and adds a role and if you remove that word it removes role and sends a message
whats wrong with the test code?
class Test_Cog(commands.Cog):
def __init__(self, bot):
self.bot = bot # defining bot as global var in class
@commands.Cog.listener() # this is a decorator for events/listeners
async def on_ready(self):
print('Bot is ready!.')
@commands.command() # this is for making a command
async def ping(self, ctx):
await ctx.send(f'Pong! {round(self.bot.latency * 1000)}')
def setup(bot): # a extension must have a setup function
bot.add_cog(Test_Cog(bot)) # adding a cog
setup(bot)
bot.run(DataV.TOKEN)
Error
exmple.py:26: RuntimeWarning: coroutine 'BotBase.add_cog' was never awaited
bot.add_cog(Test_Cog(bot)) # adding a cog
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
You have to await add_cog() I'm guessing
Though I don't remember it being a coro but load_extension() was made a coro so I suppose it does make sense
huh
Well the error is clear enough, isn't it?
"coroutine 'BotBase.add_cog' was never awaited"
yeah but i try to await it
yeah
And setup() is supposed to be async
i can't await outside or inside not-async fun
There are some different ways to do that, but you should check the activity of someone first of all
str(user.activity) # Not sure, but i think its needed as a string as it will return some other stuff else
I think this simply is enough, just check then what the status contains:
if str(user.activity) == "test":
await user.send("Test")
else:
pass
Not sure, but i think there's such an event like "on_user_update" or something
i can't await it outside
^
You're not supposed to it await
Code?
i must use load right?
Are you calling setup()
yes
Don't
ik
what
atleast you found the issue^^
C:\Users\raimy\Desktop\fuck-bot>python bot.py
Failed to load extension cogs.economy
C:\Users\raimy\Desktop\fuck-bot\bot.py:28: RuntimeWarning: coroutine 'Client.run.<locals>.runner' was never awaited
print(f'Failed to load extension {cog}')
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Failed to load extension cogs.__pycach
Logged in as FarmBot#0000
nope still have it
rip
i did some test and i failud
class Test_Cog(commands.Cog):
def __init__(self, bot):
self.bot = bot # defining bot as global var in class
@commands.Cog.listener() # this is a decorator for events/listeners
async def on_ready(self):
print('Bot is ready!.')
@commands.command() # this is for making a command
async def ping(self, ctx):
await ctx.send(f'Pong! {round(self.bot.latency * 1000)}')
async def setup(bot): # a extension must have a setup function
await bot.add_cog(Test_Cog(bot)) # adding a cog
setup(bot)
bot.run(DataV.TOKEN)
@bot.event
async def on_member_update(member):
if str(member.activity) == "test":
#await member.send("Test")
else:
pass```
is this good?
you're not supposed to call setup
discord.py already does that for you internally
oo right
That could work, try it out
where did i mes up in indent
becuase i got indent errors
you use tab/spac
duh
Do you use tabs & space mixed up? You should consider only using one of those both
no
I recommend using tab, try to indent the code again
Hm, I don't see any indent problem. What does the error say where you messed it up?
me either
ah
i see
I see the problem, remove the #
you coment the line
It does count the else as a part of the if statement
where
excicly
on await?
Yes, you have it marked as comment. Remove the # from it and it should work
It's what I said, it looks like you used spaces and tabs mixed up, indent your code again only using tab or space
yea i do dat
how to make him do that?
what
call the setup fuc?
discord.py already does that for you internally
It's not for you to call
Discord.py calls it automatically
but it didn't call it automatically idk why
How do you know it didn't call?
it must print to em 'bot is ready!.'
Right. Did you await load_extension(...)?
i think cog is not for me lmao
What do you mean?
nope i didn't
Mm. Yeah you need to do that for discord.py to call your setup function
how to use that?
what is the filename for?
The name of the file with the cog
uham
lmao
i feel like its unnecessary to subclass the bot class just for loading cogs
You should be subclassing anyway
never heard about it
if youre starting no need.
Right, and if you're getting to the point where you're loading cogs and extensions you're not necessarily starting and should consider subclassing
so youre assuming that everybody who uses cogs know inheritance ?
No, I'm only saying at that point it's time to start thinking about subclassing
(And learning if you don't know)
Since inheritance is one of the biggest concepts when it comes to object-oriented programming, it's quite important to know if you plan on expanding outside of just discord bots
Can't seem to find it, that's really crazy, I never saw it listed up anywhere nor did I saw any bot having it
Damn, I will test that out tomorrow, I'm still on d.py 1.73 though, hopefully it works
Is it possible to add a user, bot, and banned members counter if so where do I start
Discord provides all of those for you
await guild.bans() - for all banned users, find length to get banned members count
guild.members - for all members (including bots), find length to get all member count
And you can apply filters on guild.members to only get what you want
e.g filter(lambda x: x.bot, guild.members) for a list of all bots
Likewise, filter(lambda x: not x.bot, guild.members) for a list of all non-bot users
How about just numbers?
len()
Example?
!d len
len(s)```
Return the length (the number of items) of an object. The argument may be a sequence (such as a string, bytes, tuple, list, or range) or a collection (such as a dictionary, set, or frozen set).
**CPython implementation detail:** `len` raises [`OverflowError`](https://docs.python.org/3/library/exceptions.html#OverflowError "OverflowError") on lengths larger than [`sys.maxsize`](https://docs.python.org/3/library/sys.html#sys.maxsize "sys.maxsize"), such as [`range(2 ** 100)`](https://docs.python.org/3/library/stdtypes.html#range "range").
whats the code for discord bot
Huh you make code for the discord bot
Learning Guide for Discord.py
https://pythondiscord.com/pages/resources/guides/discordpy/
A learning guide for the discord.py bot framework written by members of our community.
^^^
oh im new idk my bad
You're new to python or the discord lib?
i find it hard to learn python idk from where to learn
python
If you’re new to Python, I suggest to start learning the basics first
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
^
how many days it takes me
not about how much it will take you.
its were it would take you and how much passion you put into it and how fast you learn.
^
You're straight up stealing my words lmao

oh ok thanks btw
thanks down bad!
Np^^ have fun learning Python!
Is it possible to get the cog of an app_command.Command?
im a fast learner and it took me a bit of time about 6-7 months and it was short because ive always liked programming and ive mastered python pretty well after about a year
thats great
yep
Damn, I'm after around 4-5 months just starting to learn the "advanced" stuff, but for my defense I did take breaks sadly pretty often
in dpy 2.0 how can I check if a guild is a community server? can I do something like```py
guild = self.bot.get_guild(ID)
if guild.features.community is true:
big tip is to hang around people more experienced that you
most people i talk to/friends of mine have 2+ years of experience while i have more than a year of experience
Damn, that's actually something that could help me
Looks like I will be much more active on here lol
ive learned quickly because ive been here probably 250+days so almost daily for over a year
mostly helping others
and no helper role, mina notice me or robin😔 🙏
Crazy, what channels are you the most active in? I just sometimes look in here, or try to find a help channel where someone just has problems with the d.py basics lmao, I mostly do that when I'm bored
Who knows what the future brings 👀
i mostly hang in #discord-bots and for more advanced talks #965291516031549500
yep!
i need time to finish my event system impl😔
but ive seen you and you remind me of me ngl
you have the same knowledge as me when i had 4-5 months of experience
I see, I see, looks like we will see each other more often from now on
Good luck with your event system
💜
You did? Where lol
im always lurking😏
good to know
even when im in school😳
Damn
you remind me allot of me because of your experience and your zt pfp😳
lmao, yeah zero two is never gonna die as waifu
amen 💜 🙏
Anyways, we're kinda going off-topic, I will head to sleep now anyways, good night, we will probably see each other again within the next days!
Good night, i look forward to it!
How would I rename a channel the member amount
this is the code import discord
token = 'my tok'
client = discord.Client()
@client.event
async def on_ready():
print("hey we have logged in as {0.user}")
client.run(token)
please help me guys
Thank you
probably yea
yes
get the channel object, use the edit method on it.. ```py
channel = ...
await channel.edit(name=...)
to get the members use `guild.members`, this returns a list of `Member` objects so just use the `len` function on it
from where
When u hack account and see there's 2fa lol jk
wdym
where you enabled your 2fa (google, authy)
Hi sift
Thank you
hi
How would I use len?
I suck at choosing color can anyone suggest any color combination ?
idk I think that looks pretty nice
use the emoji kwarg in the button if you're using d.py for emojis
why ?
✅ < - Wouldn't that make my button look like this ?
It would remove the black outline on the emoji
yes
Master's name becomes more weirder the more i see him
blurple for the first one gray for the 2nd
So py await channel.edit(name=f"{Len(guild.members)}")
Green on green, red on red makes it hard to tell
yes..
Docs not much of example
is it just me or it look a bit weird 🤔
Ummm error int has no attribute edit
can I use animated emoji in button ?
yes, i think
get the channel object
I did I provided the ID do I need to do get_channel(id)?
!d discord.Client.get_channel
get_channel(id, /)```
Returns a channel or thread with the given ID.
Changed in version 2.0: `id` parameter is now positional-only.
await get_channel(id)
yes..
Hey @fervent shoal!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
dam
Just get_channel(id)
Yes
https://paste.pythondiscord.com/saranuqidi
i understand i need to change the bots status to idle, idk how. got this code from the internet for some shits and giggles
c = bot.get_channel(id) # from cache
c = await bot.fetch_channel(id) # api request
Get and fetch are different things, you dont need to await get_x methods
Yellow and black
good idea thank you
Anyone know why this command isn't registering in discord?
@app_commands.command()
async def helpmessage(self, inter: Interaction, cog: str = None, group: str = None, command: str = None, ephemeral: bool = True):
#...
The cog is loaded and commands are synced
are you overriding a on_connect() ?
No
how do i set a listen thingy
try
@app_commands.command(
name="helpmessage", description="fdsadsadsa"
)
I think you might need to have command name
so that the bot listens and responds instead of me doing a command
!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.
Yeah still nothin
bruh
where did dave come from
!d discord.ext.commands.Bot.listen
@listen(name=None)```
A decorator that registers another function as an external event listener. Basically this allows you to listen to multiple events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready")
The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.10)").
Example...
@commands.Cog.listener()
async def on_message(message):
print('logger module online')
@commands.Cog.listener()
async def on_message(self, ctx):
now_utc = str(datetime.now(timezone.utc))
now_unix = str(time.time())
serverNAME = ctx.guild.name
serverID = ctx.guild.id
userNAME = ctx.author.name
userID = ctx.author.id
channelNAME = ctx.channel.name
channelID = ctx.channel.id
message = ctx.content
now if i substitued the id stuff, it should work
did u turn on application command ? in the dev panel ?
on_message doesn't take ctx
so remove ctx
wdym?
replace it with message
btw all of my other commands do register as slash, just not this one
replace the self too?
Oh, yes I did @oblique adder
no it's in a class you need that
@commands.Cog.listener()
async def on_message(self, message):
now_utc = str(datetime.now(timezone.utc))
u didn't have guilds_id ?
i gotta now fix all the ctx after that, any idea on wht to change it too?
so wouldnt that make it a global ?
Yes
so It would take an hour have u waited that long ?
Is there a way where I can create commands that will only work if you dm the bot
The bot is in 3 servers, the effect it has on the bot is minimal
In the command, you can just add
if ctx.guild:
return
``` Which just stops doing the command if the command was called in a guild
There's probably a commands. decorator for that too
Thx
@commands.Cog.listener()
async def on_message(message, ctx):
now_utc = str(datetime.now(timezone.utc))
now_unix = str(time.time())
serverNAME = ctx.guild.name
serverID = ctx.guild.id
userNAME = ctx.author.name
userID = ctx.author.id
channelNAME = ctx.channel.name
channelID = ctx.channel.id
message = ctx.content
?
you only need self and message as its args
!d discord.ext.commands.dm_only
@discord.ext.commands.dm_only()```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that indicates this command must only be used in a DM context. Only private messages are allowed when using the command.
This check raises a special exception, [`PrivateMessageOnly`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.PrivateMessageOnly "discord.ext.commands.PrivateMessageOnly") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
New in version 1.1.
on_message doesnt take ctx
?
what do i do with all the ctx under this then
self is the first arg, message would be the second one
change it to message. and arrange the arg self to be the first one
create_dm ?
Can u show
There’s not point in create_dm honestly
Oh..
Member.dm_channel.permissions_for(bot.user).send_messages
would be true, if the member is DM-able
!d discord.DMChannel.permissions_for
permissions_for(obj=None, /)```
Handles permission resolution for a [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User").
This function is there for compatibility with other channel types.
Actual direct messages do not really have the concept of permissions.
This returns all the Text related permissions set to `True` except...
any error /
actually no, this may be useless from how its documented
Not sure if it works. It says “sets all perms to True except send tts messages and manage messages”
no error, just doesnt work either
indeed, just figured that out
im not getting anything back
Thanks :D
@slate swan
You would just have to send the message and catch an error
you can un use try except blocks
..
Plus there's no reason for you to check if they're DMable using an if condition
Im already using
try:
await send("msg")
except discord.Forbidden:
# dms closed
I was finding a simpler way
In my ban cmd mainly
First send msg that ur banned then ban
why cant i get the stupid bot to respond back, am i missing something?
have you enable intents ?
so not a api one
nope you didnt ic why now
Nvmd
@commands.Cog.listener()
async def on_message(message):
print('logger module online')```
and why on_message instead of on_ready ?
also
why do you even import cProfile ?
Ok
i think its an api limitation since i havent seen any library implementing a method/property to check if a Member/User is dm-able
Hmm
even from a normal user side you wont know if a user has their dms closed without actually dming them
I meant API. my bad
huh
Pretty sure bots can't have friends
discord.Member.is_friend there are methods of checking if someone is in your friendlist or not tho, "tho it works only for user accounts" so doesnt make sense here
it was in 1.7.3 im sure
i've never seen that before
what is an intent
click on the link, and now you do
removed in 2.x
basically you tell your Client class what events you want to get using intents
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
so do i just add that ?
what dpy version are you using
tbh i dont think i am using it
i got this code of the internet
wait no i am
you ain't using discord.py?
its not in the imports 💀
Are you doing import discord?
wait
yes, its just far down there
must fix the formating
ok so ive added the intent, still nothing
Can we see the code?
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
I wonder if most ppl are gonna be switching back to discord.py 2.0 or if they’re gonna stick with their fork library 🤔
if i were to choose, id just stick with a fork
but I don't use any of them, hikari pog 
I'm sticking with pycord. The difference is minimal
minimal? 2.x versions of both are too different
why did you choose pycord? Slash commands?
well, dpy slash commands and pycord/any fork's slash command are too different
anyone know why? my discord.py is up to date
Ummm I keep getting errors and I don't know how to define guild
why do you want to define guild?
do you have some file named discord.py?
Ignoring exception in command update:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/vscode/Everything bot's/main_cogs/utility.py", line 60, in update
await channel.edit(name=f"{len(guild.members)}")
NameError: name 'guild' is not defined
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'guild' is not defined```
!d discord.Client.get_guild
get_guild(id, /)```
Returns a guild with the given ID.
Changed in version 2.0: `id` parameter is now positional-only.
nope
@commands.command(name="update", description="Updates the member count!")
async def update(self, ctx):
guild = self.client.fetch_guild(8048908012184977438)
channel = self.client.get_channel(9668469890273380556900)
await channel.edit(name=f"{len(guild.members)}")
await ctx.send("Member count has been updated!")```
all i want is the member count on the vc channel
any folder?
where? sorry if im being stupid
just look up for a def load
i dont think i created any of those
mhm did you try reinstalling the Library?
@slate swan
with pip? yea
where do i add bot.add_cog(CogClass(bot))
show the cog file
mixedCase yikes
code from gitbruh moment
i am incredibly stupid so i have no idea what you are asking of me
It's not from the official repo
How many files you have for your bot?
@final iron I can't find guild.members can you send me doc link?
i use to have this right but my brain isnt functioning, how would i make this see if they have the administrator permission ```py
if member.permissions == administrator:
await ctx.send("")
return
!d discord.Guild.members
property members```
A list of members that belong to this guild.
Well your on your own because I user multiple files not just one for cogs
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
@echo wasp this is all my code
how do i fix this?
@commands.command()
@commands.has_permissions(administrator = True)
async def unban(self, ctx, user: nextcord.User, *, reason=None):
await self.ctx.guild.unban(user=user, reason=reason)
title = f"Unbanned {user}"
description = f"I have successfully unbanned {user.mention} for reason: {reason}."
embed=nextcord.Embed(title={title}, description=description, color=0xfd9fa1)
await ctx.send(embed=embed)
@final iron why doesn't this work properly I only get the number 1 in guild name but it doesn't do all members code:
@commands.command(name="update", description="Updates the member count!")
async def update(self, ctx):
guild = self.client.get_guild(8048646776012184977438)
channel = self.client.get_channel(966846277667783380556900)
await channel.edit(name=f"{len(guild.members)}")
await ctx.send("Member count has been updated!")```
i dont think you have to put {title} just title
Do you have intents?
oh but whats wrong with the ctx.send part?
i think so
Show them
i think thats why lmfao
o
if it doesnt work lmk
uhh no its still the same error
ye
I define intents in main file do I need to provide intents in cog aswell?
no need for self
still do be needing help
its a cog lmao u need self
you do not.
self.ctx.guild?
self.ctx.guild.send?
💀
You shouldn't be using self
not even in a cog?
that's not his problem
its a basic attribute error
😳self.ctx.message.author.guild
🗿
oh but i wanted it to send in the channel that i type the command in
i use to have this right but my brain isnt functioning, how would i make this see if they have the administrator permission ```py
if member.permissions == administrator:
await ctx.send("")
return
just do ctx.send()
@commands.command(name='mute', description='mute a user from all channels', usage='mute (user) [duration] [reason]', aliases='timeout')
async def mute(self, ctx, member: discord.Member, time=None):
role = discord.utils.get(ctx.guild.roles, name="muted")
if role not in ctx.guild.roles:
perms = discord.Permissions(send_messages=False, speak=False)
await guild.create_role(name="muted", permissions=perms)
if time:
if self.convert(time) > -1:
if time:
tempmute = self.convert(time)
await member.add_roles(role)
await ctx.send(f"**{member}** has been muted 👍")
await asyncio.sleep(tempmute)
await member.remove_roles(role)
elif not time:
await member.add_roles(role)
await ctx.send(f"**{member}** has been muted 👍")
how do i make it so it sets the channel perms for the role instead of just the global role perms?
!d discord.ext.commands.has_permissions or, if ctx.author.guild_permissions.administrator:
@discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member has all of the permissions necessary.
Note that this check operates on the current channel permissions, not the guild wide permissions.
The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions").
This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingPermissions "discord.ext.commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
i did that and it was returning null values ig ill try again
yeah i have
@commands.command()
@commands.has_permissions(administrator = True)
async def unban(self, ctx, user: nextcord.User, *, reason=None):
await self.ctx.guild.unban(user=user, reason=reason)
title = f"Unbanned {user}"
description = f"I have successfully unbanned {user.mention} for reason: {reason}."
embed=nextcord.Embed(title=title, description=description, color=0xfd9fa1)
await ctx.send(embed=embed)
ctx.guild.unban
people love ignoring me dont they
anyone?
they always love listening to sarthak but not me like i get it hes cooler😔
sarth also stole my glory yesterday too
😔
#bansarthak 😡 ✊
lol
Does anyone know why I'm getting this error? Code -> https://paste.pythondiscord.com/ucemasikar
I call the classes with
view = HelpMenu().add_item(CogSelect(self.bot))
Basically, I'm trying to create a modular view where I can add different parts depending on what the user is looking at (main help menu, specific cog, etc.)
!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.pythondiscord.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.
Ain't no way I'm clicking on some random link
Ok I'll get new link ig, one sec
https://paste.pythondiscord.com/ucemasikar @final iron
._. u didnt rlly specify where to remove the self
anyone?
#discord-bots message
bro the traceback said where the error was
!trace
Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.
A full traceback could look like:
Traceback (most recent call last):
File "my_file.py", line 5, in <module>
add_three("6")
File "my_file.py", line 2, in add_three
a = num + 3
TypeError: can only concatenate str (not "int") to str
If the traceback is long, use our pastebin.
see how a traceback shows the error lines?
oh


Does anyone know why I'm getting this error? Code -> https://paste.pythondiscord.com/ucemasikar
I call the classes with
view = HelpMenu().add_item(CogSelect(self.bot))
Basically, I'm trying to create a modular view where I can add different parts depending on what the user is looking at (main help menu, specific cog, etc.)
Is there a limit to how many .add_field you can put a embed on. cause i tried putting 37 through a loop and some are missing
Created my first bot.
tried to start it.
Got rate limited.
Is this normal?
You're bound by the 6000 character limit
Are you using replit?
yeah
why not?
wait really im using it aswell lol
using discord.js on replit does not rate limit me
but free.
I have 0 money
Did u do super().__init__() in CogSelect’s __init__
I'd rather use other free hosts
Like?
Yep
I can't recall the name but it have 1gb ram, enough storage and cpu power
your programming language and Library has nothing to do with discord ratelimits
discord bots don't take much power anyways
Oracle free tier, AWS free tier
Well. My discord.js bot runs fine on Replit.
My discord.py does not
That doesn't matter
^
Rate limiting is done server-side, so your wrapper doesn't matter
Using discord.js does not give you a higher rate limit
sounds like a you issue, since there are already people using replit with discord.py
It's really not
Well. I dont know what to tell you.
never got rate limited with Discord.js.
Didnt get it to work with discord.py
Replit is notorious for being very bad at hosting
so I should switch to aws?
it's shared ip hosting it's bad
Does anyone know why I'm getting this error? Code -> https://paste.pythondiscord.com/ucemasikar
I call the classes with
view = HelpMenu().add_item(CogSelect(self.bot))
Basically, I'm trying to create a modular view where I can add different parts depending on what the user is looking at (main help menu, specific cog, etc.)
Coincidence. Replit is very unreliable and it's very feasible that it just happened to not work at the moment
how can i add more things to a json file
That's not even a question. That or oracle free tier
which one would you prefer?
anyone except replit 😆
I personally use AWS but oracle free tier is heralded as well
Mostly because my bot has a dashboard and I need a domain as well
And I also use S3 for some features
Google cloud services is a good option too
I assume it's harder to use?
any of the big ones really
It's meant for professionals like large companies and startups alike, so the interface is a bit tricky but that's because it has a lot of features
quick question has anyone made a twitter api discord bot?
"twitter api discord bot" clarify?
is it free?
what do you mean
they probably have a free tier
nvm
most do just so they can rope you into their paid plans
isn't heroku a free host
Heroku is just as bad as replit
yeah there's a free tier which you can use for 1 year, given that you need a Credit card/any payment validation
mhm i feel like vps is the only good option
but only free for 1 year? right?
Yup
ill stick to aws then
can I get the id for PartialInteractionMessage ?
For small-medium sized bots you can use a raspberry PI or some old laptop
aws gives only one year too
so all the code is written in python, im using tweepy to stream certain users tweets in real time save them and then post to discord using a discord bot. I have a problem tho where both bots don't work together. whichever code is on top runs and the other doesnt
Yeah that's how "blocking" works
You'll either have to thread it or find some other pub/sub method
And also twitter has a webhook you don't even have to write any code
replit is free forever. any other service that is that?
How do I get just the count out of this? [<Member id=893853683136217118 name="Bro's SMP Bot" discriminator='7548' bot=True nick=None guild=<Guild id=8048640554184977438 name="Bro's Gun Server (Season 1)" shard_id=None chunked=False member_count=81>>]
oracle has very powerful machines, free forever
they do charge you $1 to make sure you enter a valid cc
thats why i was asking if anyone has done anything similar cause i've been tryna thread it, multiprocess, async whatever but thanks anyway
use twitter's webhooks