#discord-bots
1 messages · Page 726 of 1
yah
the type hinting worked perfectly 🙂

hey i need some help
@slate swan :white_check_mark: Your eval job has completed with return code 0.
15
async def echo(ctx, *, args=None):
if args ==None:
return
else:
await ctx.send(f"{args.strip()}")```
!d str.strip
str.strip([chars])```
Return a copy of the string with the leading and trailing characters removed. The *chars* argument is a string specifying the set of characters to be removed. If omitted or `None`, the *chars* argument defaults to removing whitespace. The *chars* argument is not a prefix or suffix; rather, all combinations of its values are stripped:
```py
>>> ' spacious '.strip()
'spacious'
>>> 'www.example.com'.strip('cmowz.')
'example'
``` The outermost leading and trailing *chars* argument values are stripped from the string. Characters are removed from the leading end until reaching a string character that is not contained in the set of characters in *chars*. A similar action takes place on the trailing end. For example:
i want to avoid the bot from pinging here or everyone if someone tries to make it saying that
no need for the f string
if its just that
why strip?
yeah thats used to split a str?
while .send() , use the allowed_mentions kwarg
it takes a AllowedMentions object
strip != split
oh my bad got confused
how do i implement that in the code ? i mean i just started coding...
😅
🏃
hello I got raided can someone make simple ban tool that does: if message includes whatever ban user
a filter?
orrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
We don't code for you
.send(allowed_mentions=discord.AllowedMentions(everyone=False))```
Yes if it includes certain word it bans
thats one way of doing it
on message lol
another way is just removing the everyone mentions from bot completely
i can almost guess... indentations 😄
.send(allowed_mentions=discord.AllowedMentions(everyone=False, here=False))
does that work too ?
hey @slate swan " [<UserFlags.hypesquad_bravery: 64>]"
i used ```py
str(member.public_flags.all())
It returns a list, iterate over it
so int instead of str?
Iterate
join em into a str
huh
kinda one core thing to learn
or list comprehensions😳
@slate swan are u working for winrar or whatsup with the obsession?
sorry again but where do i put this then(f"{args.strip()}")
I could ask the same, are you a detective or what's up with the obsession?
@slate swan i might be associated with winzip
Sounds great.
😄
no where
no i dont kno 
how does the bot repeat the args then
thats just making if the msg has that mention it wont send
client.command(pass_context=True)
@commands.has_permissions(manage_messages=True)
async def clear(ctx, amount : int=None):
if amount == None:
await ctx.reply("Please Write a Number!")
elif amount == 0:
await ctx.send("I can not delete `0` messages.")
await ctx.send(f'**`{amount}` messages cleared.**')
await ctx.message.delete()
await ctx.channel.purge(limit=amount)```
No working
who?
🗒️ noted
@stray thistle
.send(args, allowed_mentions=discord.AllowedMentions(everyone=False))
No error
thanks
await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True)```
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.
Examples
Deleting bot’s messages...
lol weird
Anyone know?
just saying after that elif it would continue to execute the code there
i suggest you return
the function
!e
if 1 == 1:
print("correct")
print("continues")
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | correct
002 | continues
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attribute 'avatar_url'
embed.set_thumbnail(url=f"{member.avatar_url}")
avatar.url i think
!e
def function() -> str:
if 1 == 1:
return "correct"
print("continues")
@slate swan :warning: Your eval job has completed with return code 0.
[No output]
property avatar```
Equivalent to [`User.avatar`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.avatar "discord.User.avatar")
!d discord.Asset.url
property url: str```
Returns the underlying URL of the asset.
kk
.url
thanks for helping
why we here give n take
@commands.command()
async def test(ctx,arg):
await ctx.send(arg)
this is my code
and I expect when send test in discord this send me a message from that channel like this:
ark: $test hello
bot: hello
what's wrong
!d discord.Member
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User").
x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.
hash(x) Returns the member’s hash.
str(x) Returns the member’s name with the discriminator.
ExtensionFailed: Extension 'cogs.moderation' raised an error: SyntaxError: invalid syntax (moderation.py, line 117)
@commands.command()
async def unmute(self, ctx, user: Redeemed):
await user.remove_roles(discord.utils.get(ctx.guild.roles, name="Muted") # removes muted role
await ctx.send(f"{user.mention} has been unmuted")
Add another ) after user.remove_roles
self
your missing the self arg
Thanks but I don't think so
yes you do
@commands.command() decorator is for cogs
so you will need self to access the class objs
like this?
@commands.command()
async def test(self,ctx,arg):
await ctx.send(arg)
yes
but doesn't work
is it in a cog?
sorry but I don't know what is cog 🥲
show your code without the token
import discord
from discord import member
from discord.ext import commands
bot = commands.Bot(command_prefix='-')
class MyClient(discord.Client):
async def on_ready(self):
print('Logged on as {0}!'.format(self.user))
async def on_message(self, message):
print('Message from {0.author}: {0.content}'.format(message))
from discord.ext import commands
@commands.command()
async def test(self,ctx,arg):
await self.send(arg)
client = MyClient()
client.run('..')
old tutorial?
and why are you subclassing discord.Client
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix='-')
@bot.event
async def on_ready():
print(f'Logged on as {bot.user}')
@bot.command()
async def test(ctx,arg):
await ctx.send(arg)
bot.run('..')
@covert turret
lovely 💞
thanks
What do I do if my bot keeps removing users reactions when they press another reaction made from a different bot?
I don’t have a code ._.
It’s just removing all these peoples reactions for some reason
And some of the commands won’t work anymore, cuz my bot needs admin but if it doesn’t have admin it doesn’t do it anymore
It’s my bot, but I have different bots in my server that does reactions like yagpdb
And whenever someone presses a reaction, it removes it and I figured out my bot was doing it
does py await channel.send("message") return nextcord.Message?
So I was just asking what to do cuz idk what to do
class Bank(commands.Bot):
def __init__(self) -> None:
super().__init__(
command_prefix=commands.when_mentioned_or("!"),
intents = disnake.Intents.all(),
help_command=None)
def setup(self) -> None:
for filename in os.listdir("./bank/cogs"):
if filename.endswith("py"):
self.load_extension(f"bank.cogs.{filename[:-3]}")
def run(self) -> None:
self.setup()
super().run(TOKEN, reconnect=True)
async def on_ready(self) -> None:
print("Bank is online")
why is my bot not running i get no errors raised and token is added im not sure why its not running and not triggering on ready
!d discord.Message
class discord.Message```
Represents a message from Discord.
x == y Checks if two messages are equal.
x != y Checks if two messages are not equal.
hash(x) Returns the message’s hash.
!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.
Which function does this need?
wdym
@bot.command()
async def deletemsg(?):
await delete('1', delay=None)
yo why doesn't this detect when a member joins?
print("[INFO]:{member} has joined")
it just doesn't say anything
did you added the event decorator?
no it doesnt know what to delete and you should add the context of the msg
i had it as like @bot.event
and it still did nothing
@covert turret ```py
@bot.command()
async def deletemsg(ctx: commands.Context) -> None:
await ctx.message.delete(delay=None)
I expect when I send hello bot react and delete my message
class MyBot(commands.Bot):
def __init__(self, command_prefix, self_bot):
commands.Bot.__init__(self, command_prefix=command_prefix, self_bot=self_bot)
self.message1 = "[INFO]: Bot now online"
self.message2 = "Bot still online"
self.add_commands()
async def on_ready(self):
print(self.message1)
def add_commands(self):
@self.command(name="status", pass_context=True)
async def status(ctx):
await ctx.message.delete()
embed = discord.Embed(title = "Cosmic Overground Status", description = "The bot is **ONLINE** ✅", color = discord.Color.green())
embed.set_footer(icon_url = ctx.author.avatar_url, text = f"Requested by {ctx.author.name}")
await ctx.send(embed=embed)
async def on_member_join(member):
print("[INFO]:{member} has joined")
😢 💞
why isnt that in a cog
Damn, buddy! What's "async def", I'm new to python, never seen that syntax! Just "braving-it"...
?
idk cogs seems more complex
your subclassing commands.Bot?
its the same thing
subclassing
I might
theres nothing different
separate it into sections later
your just subclassing commands.Cog
but for now it doesn't really matter, I just don't get why the event thing is dodgy
anyone?
bro, why you haven't developer trophy?
did you if main it
wdym
if main:
etc
you mean the badge and you cant get it anymore
no need for it iirc
how to get bots uptime
but u can
what are you refering to
how to get bots uptime
@slate swan
you cant get it anymore
oh shit
lol
i actually needed it
lol not very familiar with subclassing the bot class lol
yeah the events just dont event
do you have intents?
I don't know what you mean
!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.
tbh i would use a cog its way better and sorted for commands and events
so youll have a file only for your bot class
k
@kindred drum heres a tutorial for cogs pretty easy if you know about subclassing
-> https://tutorial.vcokltfre.dev/tutorial/05-cogs/
Cogs are a very important part of discord.py which allow you to organise your commands into groups - not to be confused with actual command groups, which will be explained later in the tutorial.
Does anyone got a Webhosting (free) for discord.py bots I use replit and uptimerobot but it goes offline about 30m-1h
You need an external bot to track it lol
lol
Like if you add your bot to https://discord.bots.gg you will be able to use their server's bot to see uptime of yours
😐
M I got an idea
Bot for hosting bots (time to burn the vps out)
Maybe exists already
You can make a bot that creates a file and write some basic code in it and then run it on your VPS.
ive been using it and have had near 100% uptime.
or does uptimerobot go off
i don’t know like he goes offline 30m-1h after turning on then I need to go to replit again and click the run button
but I get ratelimeted after 4-5 times
That kinda dumb
wym
what is the code you have for the uptime
like I connected my code from replit to uptimerobot, or what do you mean?
from threading import Thread
app = Flask('')
@app.route('/')
def home():
return "Hello. I am ded!"
def run():
app.run(host='0.0.0.0',port=8080)
def keep_alive():
t = Thread(target=run)
t.start()```
with an address
yup that’s my keep_alive.py
i can send mine too
from flask import Flask
from threading import Thread
app = Flask('')
@app.route('/')
def main():
return "connected"
def run():
app.run(host="0.0.0.0", port=8080)
def keep_alive():
server = Thread(target=run)
server.start()
That’s mine
i got the keep alive from a friend which made couple of bots
and you have keep alive in main correct
from keep_alive import keep_alive
keep_alive()
so I Switch Import keep_alive to the first line u typed and keep_alive.keep_alive() to ur second line?
i did. but now i got a error in a other line ugh
try copying my keep alive into yours and see if that works
from threading import Thread
app = Flask('')
@app.route('/')
def home():
return "Hello. I am ded!"
def run():
app.run(host='0.0.0.0',port=8080)
def keep_alive():
t = Thread(target=run)
t.start()```
i did. but I can’t run bc I just got a other error in (user)
before i shut my last one off it was up for 248 hrs
oh cool
Anything wrong at this (sorry for phone I just don’t have my pc rn)
i suppose no
so just use ctx
no need for channel
idk I’m very new to coding? Did I?
unban command btw
no need for channel
but rn I don’t understand what’s wrong with the ctx.channel.send(f‘Unbanned
{user.mention}“)
just use ctx
context has a .send attr alone
u are using both ' and "
and await it .send is a coro
nvm in the image its both "
doesnt matter
does it not
I don’t if it’s because ur on phone but ur indentation is weird
you should indent it
did you awaited it?
!blocking
Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.
What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:
import discord
# Bunch of bot code
async def ping(ctx):
await ctx.send("Pong!")
What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.
async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!
Okay thank you for ur tip I’ll try coding other stuff in future.
Can somebody help with a discord bot which is awaiting a user message?
you can get the channel get so it would be
bot.get_channel(int)
For me ctx is lil hard but my friend said it’s lil easier
no you can still code it its just difficult
ctx is a class
!d discord.ext.commands.Context
class discord.ext.commands.Context(*, message, bot, view, args=..., kwargs=..., prefix=None, command=None, invoked_with=None, invoked_parents=..., invoked_subcommand=None, ...)```
Represents the context in which a command is being invoked under.
This class contains a lot of meta data to help you understand more about the invocation context. This class is not created manually and is instead passed around to commands as the first parameter.
This class implements the [`Messageable`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable "discord.abc.Messageable") ABC.
i always get error unident does not match outher indeation level
!indents
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
to follow pep8 each level should be 4spaces
whenever i see examples i always see foo and bar, why?
just function names lol
doesnt matter
so, when i add a members avatar in my message, it shows the full image, how do i show the image at the top?
but like not just in that. i see it everywhere. i always wonder why foo and bar
thats the image size
^
function naming thats all
dont use time.sleep
dam, is there a way to decrease it?
Pep8 recommends 4 spaces but also says that "The 4-space rule is optional for continuation lines"
you could send it in a embed as a thumbnail
¯_(ツ)_/¯
how do i do that?
class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
set the avatar
how do you send them so fast
idk
!d discord.ext.commands.Context
docs command from discord ext commands Context is upper case as its a class you should always name your classes capitalized
!blocking
Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.
What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:
import discord
# Bunch of bot code
async def ping(ctx):
await ctx.send("Pong!")
What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.
async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!
should be
await asyncio.sleep(float)
to sleep on the async function only and not the whole bot
event loop is already running when running asyncio.get_event_loop() inside of discord bot
im using discord.Client
(cant use nest asyncio incompatible with other library)
is there a way to change where the icon appears? bc at the moment in my embed it appears in the left-mid,
not really as its the avatar
i want it to show up next to the username, which is def not bot#9637
:o
and i suggest to use a task loop
well i just sent all the places that embeds have
i have mine like this, the user avatar shows up in the top right, so its kinda next to the username ig
not really
it might work
ye embed.set_image()
i tried that
k imma try
i keep getting
ModuleNotFoundError: No module named 'bank'
heres the file
from bot import Bank
if __name__ == "__main__":
Bank().run()
bot is the file that has the bank class and i edited the bank class while this file was open and it then raised the error and yes the main file and the bot file are in the same directory
can you send the code for the bank class?
class Bank(commands.Bot):
def __init__(self) -> None:
super().__init__(
command_prefix=commands.when_mentioned_or("!"),
intents = disnake.Intents.all(),
help_command=None)
def setup(self) -> None:
for filename in os.listdir("directory"):
if filename.endswith("py"):
self.load_extension(f"bank.cogs.{filename[:-3]}")
def run(self) -> None:
self.setup()
super().run(TOKEN, reconnect=True)
async def startup_function(self) -> None:
await self.wait_until_ready()
await self.change_presence(status=disnake.Status.online, activity=disnake.Game(name="!help"))
async def on_ready(self) -> None:
print("Bank is online")
async def on_command_error(self, ctx, error):
embed = disnake.Embed(
title="Command Error",
description=error,
timestamp=datetime.datetime.utcnow())
await ctx.send(emebd=embed)
did you try saving and restarting your editor?
i did
but nothing
and i think my startup_function will give me an error but thats not the point
which line did the error occur?
no line it just gaved me that error
try to import bot directly and access bank by doing bot.bank
ill check maybe ill try a wildcard import
nah nvm i solved the error but im getting something else so im fixing it
it was my for loop lol
when i do py embed = discord.Embed() embed.set_author() what fields do i add?
i mean i understand the name and icon_url, but url?
!d discord.Embed.set_author
set_author(*, name, url=Embed.Empty, icon_url=Embed.Empty)```
Sets the author for the embed content.
This function returns the class instance to allow for fluent-style chaining.
The URL for the author.
where would i find that?
not sure what it means
alr
how do you make a table using sqlite3 on replit?
bans = await ctx.guild.bans()
loop = [f"{u[1]} ({u[1].id})" for u in bans]
_list = "\r\n".join([f"[{str(num).zfill(2)}] {data}" for num, data in enumerate(loop, start=1)])
await ctx.send(f"ini\n{_list}")```
New to Discord Py. I copied this from Stack Overflow, but I'm not sure how to get it to run on command
- you should make sure you have a solid understanding of python before you even attempt discord.py as the library is not beginner friendly
- you should never copy anything directly from stackoverflow as it's most likely outdated and you won't learn anything from it
i keep getting this error
disnake.ext.commands.ExtensionNotFound
Traceback + code?
atleast basics of python* (just a correction i think)
works for me
Nah discord.py is not a beginner library, it has advanced concepts such as asyncio and you need to have a solid understand of the language and concepts such as asynchronous programming. Otherwise it's quite difficult to go deeper and learn new things with the library
if you wanna use discord.py, you need understandings of python, asynchronous programming, and Object Oriented Programming
disnake.ext.commands.errors.ExtensionNotFound: Extension 'helpcommand' could not be loaded.
the code
def setup(self) -> None:
self.load_extension("helpcommand")
and the file name is correct
i dont really know anything about asynchronous programming
but i still coded a bot that is working
It's important to know, not just knowing "just stick await at the front of stuff and async at the front of functions"
Sure you can make a bot that is working, but anyone can do that with little effort
It requires more skill to do creative problem solving and create complex features
ok thanks for info
Not trying to put you down of course
mhm, like understanding how coroutines work.
But I believe you should always prioritise learning new things over just making something that works
ill learn stuff about object oriented and async programming
After all that's the goal of coding imo, learning new things and having fun rather than just touching the surface on everything
i just know little of basics of python i guess
Trust me, the whole async thing makes much more sense once you put some effort into it. Asynchronous programming isn't just python either, you see it everywhere in different languages too

ok i know
ill learn stuff like this in future
thanks for info
Is helpcommand.py in the root directory of the project or nested in a folder?
Awesome, wish you luck
in a folder
You should include that
oh wait
thanks
you too
i need to add the folder name dont i

It happens to the best of us
yep
ok i have a question
message.attachments is what you're looking for
for filename in os.listdir(""):
if filename.endswith("py"):
self.load_extension(f"{filename[:-3]}")
what do i add because when i add the sub folder it just thinks its a module
my file structure is
pythonstuff/banker/cogs
how would i load each extension
ctx.message 🧠
!d discord.Message.attachments
A list of attachments given to a message.
I highly suggest to start using relative paths
!d discord.ext.commands.Context.message
The message that triggered the command being executed.
wdym
once you'll move your project to another folder, it won't find the files anymore
prob wont lol
not a problem
the last line is your problem btw
because?
print what you'll load and you'll see it yourself
alr
why would i
its just one cog?
tell me what it prints, you'll see
what would i print filename?
wdym
Hey im trying to get my csv cmd to add a new line instead of replacing a like here is my code
appendCSV('rr.csv', [ctx.message.content.replace('/add ','') ])
I'm talking english you know perfectly what i mean
print the string you're putting in the load function...
your giving me a hard stroke
im loading a file nothing else are you ok?
it just says it failed to load the extension?
you're loading it wrong, as mentioned earlier
if you were to PRINT what you load aka what the stinky string is
you'll see for yourself
im not loading it wrong lol'
cool that you're trying that
it just says it failed to load the filename aka the extension
and that doesn't mean you're loading it wrong? aight
disnake.ext.commands.errors.ExtensionNotFound: Extension 'helpcommand' could not be loaded.
seems to find the cog
why would you think that? It just tells you what extension he failed to load 😆
then what am i doing wrong?
it's a fucking ExtensionNotFound error and you're telling me it finds the cog? come on man
im having allot of strokes rn
all I need to see is the tree structure of your project
in that tree structure, you'll name me the main bot file and the cog file
and I'll tell you EXACTLY what string needs to be in the stinky load function
pythonstuff/banker/cogs
no, don't do me like that
is the file structure which the main and bot file are in
run the tree command on your project folder
i have zero idea wdym
google "tree command windows"
tree command? 😂
you mean the one in cmd?
yes
smh couldve said that
it's to see a visual representation of your file system
├───python projects
│ │ ├───.idea
│ │ │ └───inspectionProfiles
│ │ ├───banker
│ │ │ ├───cogs
│ │ │ │ └───__pycache__
│ │ │ └───__pycache__
why tf is my cog not there
🧍♂️
it is
it's not your full tree structure obv
theres more bot folders lol
clean that shit up 🤷♂️
but it's what they wish to share 🤡
alr, do as you wish, then I can't help any further
theirs nothing else just folders with subfolders
well, if you can't see your bot project file structure, then I can't either
wdym
bruh, it means that I can't help you if I don't have any idea what your file structure looks like
that is not necessary
i do you just want to see my other bots files what for?
you don't need to. I have a solution
ofc not, I just want to know the relative path between your bot file and your cog
of?
one moment
for (root, dirs, file) in os.walk(path):
for f in file:
if '.py' in f:
#code
not sure if it works on windows 100% but try
just make sure you define path
and import os
├───python projects
│ │ │
│ │ ├───banker
│ │ │ ├───__bot__ and __main__
│ │ │ ├───cogs
│ │ │ └───__helpcommand__
│ │ │
useless
you wanna see my other bots folders smh
don't bother
you have to use the /f parameter to view files 🧠
im just gonna find the solution my self smh your help is questionable
if you want to find files do
for (root, dirs, file) in os.walk(path):
for f in file:
if '.mp3' in f:
#code
then OR your for loop is empty
OR your if statement is false
you could also do
tree . /f
which will give you the file structure, files included
why run tree? I believe they wanted to find files inside the program
his relative path to his cog is just wrong, he hasn't figured it out yet
they doesent need to run tree even still. If they know where they put cogs then they can put it back
because the order of your parameters in your function are wrong
first self (in a class ALWAYS), then ctx, then other args
also, if you want to make this userfriendly, I'd make the submit command only possible if it was used as reply on a previous message, that way, the bot knows which message to look for, instead of adding it as a stupid argument
you can get the message object of the message whom the author replied to by
ctx.message.reference.resolved
self always isnt needed
ofc, not, that's why I'm explaining in the ()
in his case yes he would need it in params but sometimes functions dont need self in params
as mentioned...
yeah then why say its always needed when its not very true?
~in a class, that's always the first parameter
🤷♂️
only if it is a static or class method
some classes dont have a init
yeah
yeah
but you'd very rarely be using static or class methods unless that method doesn't care about the instance
if you have a bot class, and you want to create an embed for some reason in that bot class for something, it could be a static method since the bot method doesn't matter to it:
class Bot(_BotBase):
...
@staticmethod
async def error_embed(error) -> Embed:
eEmbed = Embed(title=f"{error}", color=0xFF0000)
return eEmbed
you'll have to be more specific than that
so i save the user's id in my database, then when they ask for their name from database, i wanna convert them into names, since i have id not name in database, how to do that
do you already have a command for it?
yes
send it
wait
and to convert into name use user.name?
i think (not sure)
user.display_name
ok, lemme try
helll yeash finnaly it works, thanks @worldly bane and @slim ibex
np
how could i make a bot autonuke a chat?
y
bruh why
prob just to clear the whole chat
Can you be more descriptive?
If you're trying to nuke a discord server I'm afraid we can't help with that
no like, delete and readd the channel
so its like nuked
@bot.command()
@commands.guild_only()
@commands.has_permissions(manage_channels = True)
async def nuke(ctx):
pos = ctx.channel.position
new = await ctx.channel.clone()
await ctx.channel.delete()
await new.edit(position = pos)
embed = discord.Embed(description=f"nuked this channel :thumbsup:",color=color)
await new_channel.send(embed = embed)```
i have that but i want to be able to make a command to be able to set a timer to like execute that command every x amount of minutes or hours
!d discord.ext.tasks.loop
discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
Why is it that default avatars dont resize to the specified size?
# Open badge and users avatar
badge = Image.open('./core/assets/badge.png')
asset = user.display_avatar.with_size(128).with_format('png')
data = BytesIO(await asset.read())
pfp = Image.open(data)
# Paste user avatar
pfp.resize((135, 137))
badge.paste(pfp, (46, 48))
in the event on_guild_channel_create(channel) how how do you get who created the channel
AFAIK, you can't, you can check the audit logs when a text channel is created and start from there though
With the event that runs when a channel is created
hey guys i was trying a copypasta for a code to play music but it doesnt seem to work can someone help?
from what source are you playing the music?
yt
!ytdl
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)
oh ok thnaks for letting me know
👀
no worries , you still are allowed to use ffmpeg to play music files
How could I prevent a check from printing an error to console whenever it fails?
Its not a check on a command
Its a global check
how can you make commands that only a specific guild can use
back to what we were talking about how do I get the name of the channel from the audit log data
I'm not sure if theres a decorator but you could just:
if ctx.guild.id == Id here:
...
else:
return
you can use on_command_error and use commands.CheckFailure to check if its a check fail , though all command checks are CheckFailture so you would need to takee care of it
If theres no decorator you could make your own custom one
!d discord.ext.commands.CheckFailure
exception discord.ext.commands.CheckFailure(message=None, *args)```
Exception raised when the predicates in [`Command.checks`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command.checks "discord.ext.commands.Command.checks") have failed.
This inherits from [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError")
eh, ill just use @commands.check(func) easy
wait how do you get the guild id ctx.guild.id i think right?
Yes
cool cool
You get the channel object from the audit logs and channel.name would do it
I think I understand
Wouldn't this ingest all the other errors though?
Not all
But from the docs:
An error handler that is called when an error is raised inside a command either through user input error, check failure, or an error in your own code.
An error handler that is called when an error is raised inside a command either through user input error, check failure, or an error in your own code.
you can deal with multiple checks in the same handler right?
also , do you just want to send a message if the check fails?
Its a blacklisted check so I wouldn't want any response
And its annoying having the error in console
Another issue with on_command_error is it will ingest other check errors and actual errors in my code which means I won't be able to see which line the error is in
Use the traceback library
traceback.print_exc()
I see way too many people having on_command_error that do something like
def on_command_error():
if isinstance(...):
# do something
and just leave it at that
@bot.event
async def on_guild_channel_create(channel):
json = mongo.find_guild(channel.guild.id)
channel = json['channel-id']
async for entry in channel.guild.audit_logs(limit = 1, action=nextcord.AuditLogEntry.channel_create):
embed = nextcord.Embed(title='channel Creation Log', color = nextcord.Color.purple())
embed.add_field(name='Channel Name', value=channel.name)
embed.add_field(name='Channel Creator', value=entry.author)
channel = bot.get_channel(channel)
await channel.send(embed=embed)
I have this code and I get this error
await coro(*args, **kwargs)
File "/home/ian/bots/main.py", line 53, in on_guild_channel_create
async for entry in channel.guild.audit_logs(limit = 1, action=nextcord.AuditLogEntry.channel_create):
AttributeError: 'Int64' object has no attribute 'guild'
what can I use instead
You probably stored it as an ID in your database
I'm assuming you mean something like this:
traceback.print_exception(type(error), error, error.__traceback__)
Yeah that works as well
Alr
Hiii
what is the code for embeding images with url?
or what is the code for viewing a pic?
Thanksss
bc this is our problem
put quotes
thanks
thanksss
if you use discord.py 2.0 or any forks here:
https://github.com/Rapptz/discord.py/blob/master/examples/views/confirm.py
how do i find a channel id from a channel that the bot made
and also from the author of a command
If you created the channel using code, then you it always returns the channel object.
So you can do
new_channel = await x.create_text_channel(...)
print(new_channel.id)
If i put no intents it gives me a await is outside function error and if i add any intents it says unexpected intent anyone know why?
Indentation error Basically mobile programming in a nutshell
that error doesnt have anything to do with intents at all
your await keyword is outside of an async function
just move it inside one
use a mobile ide
Is that on the appstore? Ive been looking for a python app for ages
not so sure bout apple
thats why ive been using replit on my phone i cant find one + it lets me swap between my phone and pc
I have and it gives me a unexpected intent error
give full code
@client.command()
async def gwend(ctx, user: discord.Member = None):
if user == None:
user = ctx.author
gwened = image.open("gwen.png")
asset = ctx.author.avatar_url_as(size = 128)
data = bytesIO(await asset.read())
pfp = Image.open(data)
pfp = pfp.resize((643,1250))
gwened.paste(pfp,69,420)
gwened.save("gwen.png")
await ctx.reply(gwen.png)
do you not see it?
its basic python
Sorry i cant tell what ive done wrong im still fairly knew to python
Someone pls help me with this
your supposed to indent everything below async def gwend(ctx, user: discord.Member = None):
Now it does this
don't put a space before async
Ok its not giving me any errors now ty
Np
Aparently image isnt defined but its part of the import (exactly from the video)
Could you help me pls?
show imports
Why you are ignoring me!!!
you don't send code so how can we help
did you install asyncio using pip?
I don’t have much experience with that
Im not sure tbh the code is the same as the video tho the video was made oct 2020 it’s probably out of date

how do i get id of the mentioned role ?
I actually deleted it because someone with the same error told me
That is my guess too
some replit error
simple: just dont use replit lol
So what should I do?
.
There isn't something better for phone
bro you're coding on a phone
also have you pip installed it?
then don't code on a phone
Its replit
I have no free access to pc, it's locked😢
Its no different to coding replit on pc
wdym
My cant even run chrome + i dont have access to it 99% of the time
Yes
ok
doesnt change the fact that replit is bad
Do u have the same bug that when you hold the "delete" button in 1-3 seconds replit just change the order of the code?
Sometimes yea
It's so ANNOYING
Ikr
lolllllll
bro it's supposed to be a string
how would i get/see the permissions the command user (ctx.author) has
!d discord.TextChannel.permissions_for
permissions_for(obj, /)```
Handles permission resolution for the [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role").
This function takes into consideration the following cases...
hmm example
It clearly shows everything you need.
Use .permissions_for() on a discord.TextChannel object, and give as parameter the member.
does it return a list or tuple or something
wait why are we using a discord.TextChannel
Anyone know how I can get the last image posted into the chat then download it?
For example say someone posted an image, then did /save then the bot would download the image
I'm using pycord if it matters but I doubt it
any word yet on what the python-discord bot wrapper will switch to? or a link to a discussion on the future?
help me thanks
as per the error message, you have the wrong indentation level near that link. the red squiggly line is a hint to that.
Command raised an exception: AttributeError: 'Guild' object has no attribute 'create_channel'
i keep getting this error when trying to make a channel
thanks
look at the API documentation, does the object you are trying to interact with have the "create_channel" function?
well no but then how would you create a chanenl
i cannot say as i am not reading the documentation. try searching for it?
!d discord.Guild.create_text_channel
await create_text_channel(name, *, reason=None, category=None, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`TextChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel "discord.TextChannel") for the guild.
Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to create the channel.
The `overwrites` parameter can be used to create a ‘secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.
Note
Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
oh mt thing was a ctx.message.guild obj oh
!d disnake.Guild.channels
property channels: List[GuildChannel]```
A list of channels that belongs to this guild.
cool cool it exists
@heavy folio Command raised an exception: AttributeError: type object 'Guild' has no attribute 'create_channel'
disnake?
!d disnake.Guild.create_text_channel
await create_text_channel(name, *, reason=None, category=None, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`TextChannel`](https://docs.disnake.dev/en/latest/api.html#disnake.TextChannel "disnake.TextChannel") for the guild.
Note that you need the [`manage_channels`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.manage_channels "disnake.Permissions.manage_channels") permission to create the channel.
The `overwrites` parameter can be used to create a ‘secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.10)") of overwrites with the target (either a [`Member`](https://docs.disnake.dev/en/latest/api.html#disnake.Member "disnake.Member") or a [`Role`](https://docs.disnake.dev/en/latest/api.html#disnake.Role "disnake.Role")) as the key and a [`PermissionOverwrite`](https://docs.disnake.dev/en/latest/api.html#disnake.PermissionOverwrite "disnake.PermissionOverwrite") as the value.
Note
Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://docs.disnake.dev/en/latest/api.html#disnake.TextChannel.edit "disnake.TextChannel.edit") will be required to update the position of the channel in the channel list...
weird
if discord.py has it, disnake most likely has the same thing as well
wait a fking second i put it as create_channel not create_text_channel
set_author(*, name, url=Embed.Empty, icon_url=Embed.Empty)```
Sets the author for the embed content.
This function returns the class instance to allow for fluent-style chaining.
Change str to url
okay thanks
try ctx.author.avatar
ohhh
ohhhh
can i put a gif into an embed?
!d discord.Embed.set_thumbnail
set_thumbnail(*, url)```
Sets the thumbnail for the embed content.
This function returns the class instance to allow for fluent-style chaining.
Changed in version 1.4: Passing [`Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty") removes the thumbnail.
depends what site the emoji is from
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: CardMissing: Card missing```
How would I catch the exception after the ``CommandInvokeError``? I am catching via the on_command_error event
!d discord.ext.commands.errors.CommandInvokeError
exception discord.ext.commands.CommandInvokeError(e)```
Exception raised when the command being invoked raised an exception.
This inherits from [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError")
ik its an exception but i wanna grab the exception after the invoke error
you just do if isinstance(error, commands.error.CommandInvokeError)
Command raised an exception: CardMissing: Card missing this bit
then CardMissing: Card missing this bit
probably like
as that is my final error
idk but you can just test it
print(dir(error))
test it, trial and error is what people used before having a support dial at every corner
mmm
says you
😳
You say the r word like how you say “you”
and it’s the only word in your dictionary apart from fucker and bitch and mf
I don’t say the R word on this prestigious upstanding server
and to clarify, i do not say bitch
True
@velvet tinsel yeah, please don't use the r-word here.
k
||dk is this database or bot, but this kinda hav connection with bot so..|| why a table in my database is wiped out when i rerun my bot code
||show your code ||
how would i make the bot make a text channel i keep getting 'Guild' object has no attr 'create_text_channel'
@bot.command()
async def test(ctx):
with open("banns.txt", "r") as f:
if ctx.author.id in f:
await ctx.send('nop')
else:
await ctx.send('hi')```
i am trying to make my bot reply no if the user id is in a txt file but it always reply with yes even if the id is in the txt file
the ids are in the way
"793206762101669948"
how do you embed.set_image / embed.set_thumbnail using url/str?
url=
i guess
!d discord.Embed.set_thumbnail
set_thumbnail(*, url)```
Sets the thumbnail for the embed content.
This function returns the class instance to allow for fluent-style chaining.
Changed in version 1.4: Passing [`Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty") removes the thumbnail.
set_image(*, url)```
Sets the image for the embed content.
This function returns the class instance to allow for fluent-style chaining.
Changed in version 1.4: Passing [`Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty") removes the image.
this too
indents and also you gotta read tbe file first
hmm but i am using with open('banns.txt', 'r') as f: to read the file
is it possible the bot is replying because the way i have typed the ID in the txt file?
if ctx.author.id in f.readlines():
f.readlines returns a list with all the lines
if your id's are listed as one line for one id, it will work
its giving this error now
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'in <string>' requires string as left operand, not int
how do i use await asyncio.sleep to make this event sleep for 15m?
if str(ctx.author.id)
I guess its considering the ID as a string? and comparing them?
it's considering the id as an int
that's the problem
convert it to str
await asyncio.sleep(15*60)

meth
are you using an SQL/JSON database
!d discord.Guild.create_text_channel
await create_text_channel(name, *, reason=None, category=None, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`TextChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel "discord.TextChannel") for the guild.
Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to create the channel.
The `overwrites` parameter can be used to create a ‘secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.
Note
Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...

hi
the problem in this pic is the daily commands are invalid syntax
so what we will do?
oh thankssss
its not working
too bad idt you can typehint stuff on replit correct me if im wrong
on replit.
what?
Can
If you have a database and you are able to change the prefix, you would have to create a separate function to see the function for the context guild and put the function after the = for command prefix
Like purge all the messages in it?
Well then you can only choose one prefix
But how do I do the bot var thing
:/ it works
bot.helmet?
Ya helmet is the var name
oh the prefixes work?
So bot.helmet?
make it so the bot detects what channel the message is in then to purge it, instead of purge #channel name as it would be an ID
Nola I use the dumb way
why can't you
it doesn't make sense
unless you mean like replit runs a python version that doesn't support typehinting
Btw how to do the bot var thing
it does work like that, but I don’t know if you can pass special things into the commands.Bot function
Let me check the docs rq
Okok thanks
ofc sql
It doesn’t seem like you can do that @loud junco
Then how do I make bot var that I can use everywhere in the bot without having the scoping error
Hey @small igloo!
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:
f
!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.
Are you using cogs or anything like that. Or are your commands all in one file
and you can have multiple prefixes
All in one
if the variable is defined globally, there should be no scoping issues
But pepo tell me not to do global var
Someone mentioned me?
well don't
:/
You don’t
just define botvars outside of the constructor
its so hard to code omg
A global variable is a variable not declared In a specific function
nobody
isn't bot is coded for free?
why not just add case_insensitive=True, @loud junco
TO your bot = commands.Bot
yeah
then you can have just 1 prefix
and it will accept nomatter how u typeit
same for commands name
Case sensitive = false :/
its case_insensitive=True
Okok
red underline :V
that's no error
dis maybe
Lemme send the pic again
how to change prefix (not in code, like.... $change_prefix[prefix] also how to make bot space insensitive)
Maybe the comma
not work last time
just why
@cold sonnet
help pls
remove "()" might help in event
on event
thx
k, np
is this for my grammar or helping that joly
try @on_event
property name```
Equivalent to [`User.name`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.name "discord.User.name")
hi,i am working on crypto prices bot and i got crypto live prices working on command,but i wanna update them in my nickname,how do i change nick name of bot every 60 seconds?
doesn't that show the discriminator too?
how show the discriminator?
i try this
hm
yes
stop using replit
no
sec
it doesn't lol, you have to do member.name + "#" + member.discriminator if you want it
pretty sure you don't
how do i edit bots nickname?
what host are you using
try using member.name yourself
I'm sitting in a car
and
Just use the member object only, it will return ur name+discrim
thx
kayle has blessed us with his wisdom
really?no one?
but I remember I've been using the member.name + member.discriminator stuff until I replaced it with only one attribute
how come whenever I try to print my own object, it returns an incomprehensible string (the address where the object is stored in), whereas if I print a member object, it returns the members name and tag?
!d discord.ext.commands.Bot.change_presence
how did danny do that
await change_presence(*, activity=None, status=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Changes the client’s presence.
Example
```py
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)
``` Changed in version 2.0: Removed the `afk` keyword-only parameter.
incomprehensible meaning what? smth like this? <Member=kayle discrim=6969>
yeah,but i dont understand how do i change nick name?
wait
ye sure
Any idea why this wont trigger?
@bot.event
async def on_thread_join(thread):
print("# THREAD CREATED #")
await thread.join()
``` i have also `intents.guilds = True`
!d discord.Member.edit
await edit(*, nick=..., mute=..., deafen=..., suppress=..., roles=..., voice_channel=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the member’s data.
Depending on the parameter passed, this requires different permissions listed below...
no lol, if I try to print an object that I made on my own it returns something like <object ff17719189f>, which iirc is the address the object is stored at. whereas if I print a member object, it returns their username. just wondering how danny made it do that
yes
why are you joining the thread again
how do i do that on my bot?when i try to do client.edit(nick = 'Name') just doesnt work
do client.user.edit()
@slate swani trying to get bot to join a thread when i create one
!d discord.ClientUser
class discord.ClientUser```
Represents your Discord user.
x == y Checks if two users are equal.
x != y Checks if two users are not equal.
hash(x) Return the user’s hash.
str(x) Returns the user’s name with discriminator.
@client.event async def on_message(message): if message.content=='price': await client.user.edit(nick = str(price))
still doesnt work
nah
what about the user are you trying to edit
it my bot
let me try
iirc on_thread_join triggers when the bot joins a thread (correct me if I'm wrong), so you're basically making it join the thread twice
https://github.com/Rapptz/discord.py/blob/master/discord/member.py#L300-L307 using the __str__/__repr__ dunder
discord/member.py lines 300 to 307
def __str__(self) -> str:
return str(self._user)
def __repr__(self) -> str:
return (
f'<Member id={self._user.id} name={self._user.name!r} discriminator={self._user.discriminator!r}'
f' bot={self._user.bot} nick={self.nick!r} guild={self.guild!r}>'
)```
self._user being your name and discriminator
it dosnt join thread at all, how i make it join a thread then? 🙂
i want it to join thread why i as user create a thread
!d discord.on_thread_join
discord.on_thread_join(thread)```
Called whenever a thread is joined or created. Note that from the API’s perspective there is no way to differentiate between a thread being created or the bot joining a thread.
Note that you can get the guild from [`Thread.guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Thread.guild "discord.Thread.guild").
This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
New in version 2.0.
works man ty
👍
@boreal ravinei have that but it dosnt trigger when i create a thread
class discord.Intents(**kwargs)```
Wraps up a Discord gateway intent flag.
Similar to [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.
To construct an object you can pass keyword arguments denoting the flags to enable or disable.
This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
New in version 1.5...
they are enabled by default
am stupid i forgot to check role permissions for threads 😄
no
