#discord-bots

1 messages · Page 726 of 1

honest vessel
#

oh I, missed that thought ut was |

slate swan
#

yah

ebon island
#

the type hinting worked perfectly 🙂

slate swan
blazing lynx
#

[<UserFlags.hypesquad_bravery: 64>]

#
str(member.public_flags.all())
stray thistle
#

hey i need some help

slate swan
#

Then ask, we sadly can't guess.

#

!e @ebon island

x = lambda a : a + 10
print(x(5))
unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

15
stray thistle
#
async def echo(ctx, *, args=None):
  if args ==None:
    return
  else:
    await ctx.send(f"{args.strip()}")```
slate swan
#

!d str.strip

unkempt canyonBOT
#

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:
stray thistle
#

i want to avoid the bot from pinging here or everyone if someone tries to make it saying that

slate swan
#

if its just that

#

why strip?

#

yeah thats used to split a str?

slate swan
#

it takes a AllowedMentions object

slate swan
slate swan
stray thistle
#

😅

slate swan
#

hello I got raided can someone make simple ban tool that does: if message includes whatever ban user

slate swan
#

orrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr

#

We don't code for you

slate swan
slate swan
#

thats one way of doing it

slate swan
#

another way is just removing the everyone mentions from bot completely

honest vessel
stray thistle
#

.send(allowed_mentions=discord.AllowedMentions(everyone=False, here=False))

#

does that work too ?

slate swan
#

no

#

everyone and here are same

stray thistle
#

oh

#

nice to know

blazing lynx
#

hey @slate swan " [<UserFlags.hypesquad_bravery: 64>]"

#

i used ```py
str(member.public_flags.all())

slate swan
#

It returns a list, iterate over it

blazing lynx
#

so int instead of str?

slate swan
#

Iterate

honest vessel
#

join em into a str

slate swan
#

For loop

#

Basic list looping

blazing lynx
#

huh

slate swan
#

Then you can do whatever you want with each flag

honest vessel
#

kinda one core thing to learn

slate swan
#

or list comprehensions😳

honest vessel
#

@slate swan are u working for winrar or whatsup with the obsession?

stray thistle
slate swan
honest vessel
#

@slate swan i might be associated with winzip

slate swan
#

Sounds great.

honest vessel
#

😄

stray thistle
#

seems like the man went off discord

#

anyone else ? 😅

honest vessel
#

no i dont kno ducky_angel

stray thistle
#

how does the bot repeat the args then

slate swan
#

thats just making if the msg has that mention it wont send

dense coral
#
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?

honest vessel
#

🗒️ noted

slate swan
#

@stray thistle

.send(args, allowed_mentions=discord.AllowedMentions(everyone=False))
dense coral
#

No error

unkempt canyonBOT
#

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...
slate swan
#

lol weird

slate swan
#

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")
unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

001 | correct
002 | continues
blazing lynx
#
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}")

honest vessel
#

avatar.url i think

slate swan
unkempt canyonBOT
#

@slate swan :warning: Your eval job has completed with return code 0.

[No output]
slate swan
#

Yeah, .avatar is an attachment

#

!d discord.Member.avatar

unkempt canyonBOT
#

property avatar```
Equivalent to [`User.avatar`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.avatar "discord.User.avatar")
blazing lynx
#

kk

#

so member.avatar sends the mentioned users avatar url?

slate swan
#

!d discord.Asset.url

unkempt canyonBOT
slate swan
#

member.avatar returns a discord.Asset object

#

and discord.Asset has .url attribute

blazing lynx
#

kk

slate swan
#

.url

honest vessel
#

ye .url

#

display_avatar.url

blazing lynx
#

thanks for helping

honest vessel
#

why we here give n take

manic wing
#

i mean do it in the server

#

my jesterbot has it

#

the pypi command

#

smh, anyway 🙃

mighty dust
#

any reasons why a program wont open and read a text file?

#

wait wrong channel

covert turret
#

@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

ebon island
#

!d discord.Member

unkempt canyonBOT
#

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.
blazing lynx
#
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")
torn sail
#

Add another ) after user.remove_roles

slate swan
#

your missing the self arg

covert turret
slate swan
#

@commands.command() decorator is for cogs

#

so you will need self to access the class objs

covert turret
covert turret
#

but doesn't work

slate swan
#

is it in a cog?

covert turret
slate swan
covert turret
# slate swan 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('..')

slate swan
#

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

slate swan
#

yw

outer violet
#

What do I do if my bot keeps removing users reactions when they press another reaction made from a different bot?

slate swan
#

code please

#

you could add a check to see if they're reacting to another bot

outer violet
#

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

slate swan
#

is it someone else's bot?

outer violet
#

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

opal skiff
#

does py await channel.send("message") return nextcord.Message?

outer violet
slate swan
#
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

covert turret
#

!d discord.Message

unkempt canyonBOT
#

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.
covert turret
#

!d discord.Message.delete

unkempt canyonBOT
#

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.
covert turret
slate swan
covert turret
#

@bot.command()
async def deletemsg(?):
await delete('1', delay=None)

kindred drum
#

yo why doesn't this detect when a member joins?

     print("[INFO]:{member} has joined")

#

it just doesn't say anything

slate swan
slate swan
kindred drum
#

and it still did nothing

slate swan
#

@covert turret ```py
@bot.command()
async def deletemsg(ctx: commands.Context) -> None:
await ctx.message.delete(delay=None)

covert turret
kindred drum
#

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")
obtuse compass
kindred drum
slate swan
#

its the same thing

#

subclassing

kindred drum
#

I might

slate swan
#

theres nothing different

kindred drum
#

separate it into sections later

slate swan
#

your just subclassing commands.Cog

kindred drum
#

but for now it doesn't really matter, I just don't get why the event thing is dodgy

covert turret
kindred drum
#

did you if main it

slate swan
kindred drum
#

if main:
etc

slate swan
slate swan
blazing lynx
#

how to get bots uptime

covert turret
slate swan
blazing lynx
#

how to get bots uptime

covert turret
#

@slate swan

slate swan
covert turret
slate swan
#

lol

slate swan
kindred drum
#

I still can't get this thing to work

slate swan
kindred drum
#

yeah the events just dont event

slate swan
kindred drum
#

I don't know what you mean

slate swan
#

!intents

unkempt canyonBOT
#

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.

kindred drum
#

yes

#

I do

slate swan
#

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

kindred drum
#

k

slate swan
#

@kindred drum heres a tutorial for cogs pretty easy if you know about subclassing
-> https://tutorial.vcokltfre.dev/tutorial/05-cogs/

slate swan
#

Does anyone got a Webhosting (free) for discord.py bots I use replit and uptimerobot but it goes offline about 30m-1h

vale wing
vale wing
#

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

slate swan
#

😐

velvet tinsel
#

free stuff always have a con

#

a big one.

vale wing
#

M I got an idea

#

Bot for hosting bots (time to burn the vps out)

#

Maybe exists already

blazing lynx
#

huh

#

confusion

dapper cobalt
winter moth
#

or does uptimerobot go off

slate swan
#

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

winter moth
slate swan
winter moth
#
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()```
slate swan
#

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

winter moth
#

and you have keep alive in main correct

slate swan
#

keep_alive.keep_alive()

#

This?

#

and I have import keep_alive

winter moth
#

from keep_alive import keep_alive

keep_alive()

slate swan
#

so I Switch Import keep_alive to the first line u typed and keep_alive.keep_alive() to ur second line?

winter moth
#

that at the top

#
keep_alive()
bot.run(os.getenv('token'))``` 
at the bottom
slate swan
#

i did. but now i got a error in a other line ugh

winter moth
#

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()```
slate swan
#

i did. but I can’t run bc I just got a other error in (user)

winter moth
#

before i shut my last one off it was up for 248 hrs

slate swan
#

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

dire folio
#

u are using both ' and "

slate swan
#

and await it .send is a coro

dire folio
#

nvm in the image its both "

slate swan
dire folio
#

does it not

slate swan
#

nope

#

they need to be paired tho

torn sail
# slate swan

I don’t if it’s because ur on phone but ur indentation is weird

slate swan
#

i now did ctx.send instead of ctx.channel.send

#

but still wrong

dire folio
#

you should indent it

slate swan
#

!blocking

unkempt canyonBOT
#

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!

slate swan
#

Okay thank you for ur tip I’ll try coding other stuff in future.

quartz torrent
#

Can somebody help with a discord bot which is awaiting a user message?

slate swan
#

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

slate swan
slate swan
#

!d discord.ext.commands.Context

unkempt canyonBOT
#
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.
slate swan
unkempt canyonBOT
#

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

slate swan
#

to follow pep8 each level should be 4spaces

dire folio
#

whenever i see examples i always see foo and bar, why?

slate swan
#

doesnt matter

quaint epoch
#

so, when i add a members avatar in my message, it shows the full image, how do i show the image at the top?

dire folio
slate swan
dire folio
#

^

slate swan
#

dont use time.sleep

quaint epoch
cloud dawn
slate swan
quaint epoch
slate swan
#

!d discord.Embed

unkempt canyonBOT
#

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.
slate swan
#

set the avatar

dire folio
#

how do you send them so fast

slate swan
#

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

unkempt canyonBOT
#

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!

slate swan
#

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)

quartz torrent
quaint epoch
#

is there a way to change where the icon appears? bc at the moment in my embed it appears in the left-mid,

quaint epoch
#

i want it to show up next to the username, which is def not bot#9637

quaint epoch
slate swan
quaint epoch
#

i don't get it

#

forgive me for my stupidity

slate swan
dire folio
#

not really

#

it might work

quaint epoch
#

i tried that

slate swan
#

check what i sent

quaint epoch
#

k imma try

slate swan
#

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

quaint epoch
slate swan
# quaint epoch 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)
quaint epoch
slate swan
#

but nothing

#

and i think my startup_function will give me an error but thats not the point

quaint epoch
slate swan
quaint epoch
slate swan
slate swan
#

it was my for loop lol

quaint epoch
#

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?

slate swan
#

!d discord.Embed.set_author

unkempt canyonBOT
#

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.
slate swan
#

The URL for the author.

quaint epoch
slate swan
quaint epoch
slate swan
#

how do you make a table using sqlite3 on replit?

spice adder
#
    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
sick birch
slate swan
#

i keep getting this error

disnake.ext.commands.ExtensionNotFound
sick birch
#

Traceback + code?

supple summit
#

works for me

sick birch
#

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

patent lark
#

if you wanna use discord.py, you need understandings of python, asynchronous programming, and Object Oriented Programming

sick birch
#

There's a section in the d.py server where it basically says just that

slate swan
#

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

supple summit
#

but i still coded a bot that is working

sick birch
#

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

supple summit
#

ok thanks for info

sick birch
#

Not trying to put you down of course

patent lark
#

mhm, like understanding how coroutines work.

sick birch
#

But I believe you should always prioritise learning new things over just making something that works

supple summit
#

ill learn stuff about object oriented and async programming

sick birch
#

After all that's the goal of coding imo, learning new things and having fun rather than just touching the surface on everything

supple summit
#

i just know little of basics of python i guess

sick birch
#

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

supple summit
#

ill learn stuff like this in future

#

thanks for info

sick birch
sick birch
sick birch
#

You should include that

slate swan
#

oh wait

supple summit
slate swan
#

i need to add the folder name dont i

sick birch
#

you do

#

seperated by dots

slate swan
#

yeah ik

#

smh sorrypithink

patent lark
sick birch
#

It happens to the best of us

slate swan
#

yep

slate swan
potent spear
#

message.attachments is what you're looking for

slate swan
#
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

potent spear
#

ctx.message 🧠

patent lark
#

!d discord.Message.attachments

unkempt canyonBOT
potent spear
patent lark
#

!d discord.ext.commands.Context.message

unkempt canyonBOT
potent spear
# slate swan wdym

once you'll move your project to another folder, it won't find the files anymore

potent spear
slate swan
potent spear
#

print what you'll load and you'll see it yourself

slate swan
#

alr

slate swan
#

its just one cog?

potent spear
slate swan
slate swan
#

wdym

storm steppe
#

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 ','') ])

potent spear
# slate swan wdym

I'm talking english you know perfectly what i mean
print the string you're putting in the load function...

slate swan
#

im loading a file nothing else are you ok?

#

it just says it failed to load the extension?

potent spear
slate swan
#

im not loading it wrong lol'

slate swan
#

it just says it failed to load the filename aka the extension

potent spear
#

and that doesn't mean you're loading it wrong? aight

slate swan
#

disnake.ext.commands.errors.ExtensionNotFound: Extension 'helpcommand' could not be loaded.

#

seems to find the cog

potent spear
potent spear
#

it's a fucking ExtensionNotFound error and you're telling me it finds the cog? come on man

slate swan
#

im having allot of strokes rn

potent spear
#

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

slate swan
#

pythonstuff/banker/cogs

potent spear
#

no, don't do me like that

slate swan
#

is the file structure which the main and bot file are in

potent spear
#

run the tree command on your project folder

slate swan
#

i have zero idea wdym

potent spear
#

google "tree command windows"

mint jewel
#

tree command? 😂

slate swan
#

you mean the one in cmd?

mint jewel
#

yes

slate swan
#

smh couldve said that

mint jewel
#

it's to see a visual representation of your file system

slate swan
#
├───python projects
│   │   ├───.idea
│   │   │   └───inspectionProfiles
│   │   ├───banker
│   │   │   ├───cogs
│   │   │   │   └───__pycache__
│   │   │   └───__pycache__
#

why tf is my cog not there

#

🧍‍♂️

mint jewel
#

it is

potent spear
#

it's not your full tree structure obv

slate swan
potent spear
mint jewel
slate swan
#

now what do i do🧍‍♂️

potent spear
#

alr, do as you wish, then I can't help any further

slate swan
#

theirs nothing else just folders with subfolders

potent spear
#

well, if you can't see your bot project file structure, then I can't either

potent spear
#

bruh, it means that I can't help you if I don't have any idea what your file structure looks like

slate swan
mint jewel
potent spear
#

ofc not, I just want to know the relative path between your bot file and your cog

slate swan
mint jewel
#

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

slate swan
potent spear
#

useless

slate swan
#

you wanna see my other bots folders smh

mint jewel
#

don't bother

potent spear
slate swan
#

im just gonna find the solution my self smh your help is questionable

mint jewel
potent spear
#

then OR your for loop is empty
OR your if statement is false

potent spear
mint jewel
#

why run tree? I believe they wanted to find files inside the program

potent spear
#

his relative path to his cog is just wrong, he hasn't figured it out yet

mint jewel
#

they doesent need to run tree even still. If they know where they put cogs then they can put it back

potent spear
#

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

potent spear
slate swan
potent spear
#

as mentioned...

slate swan
#

yeah then why say its always needed when its not very true?

potent spear
#

~in a class, that's always the first parameter
🤷‍♂️

slim ibex
slate swan
slate swan
slim ibex
#

you need an __init__ method to instantiate the bot instance

#

if you are using cogs

slate swan
#

yeah

slim ibex
#

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
small igloo
#

how to convert ID into name

#

how to convert ID into name

slim ibex
#

you'll have to be more specific than that

small igloo
slim ibex
#

do you already have a command for it?

small igloo
slim ibex
#

send it

small igloo
worldly bane
#

user = await client.fetch_user(id)

#

Should work i think

small igloo
worldly bane
slim ibex
#

user.display_name

small igloo
small igloo
slim ibex
#

np

slate swan
#

how could i make a bot autonuke a chat?

worldly bane
small igloo
obsidian ledge
#

prob just to clear the whole chat

final iron
#

If you're trying to nuke a discord server I'm afraid we can't help with that

slate swan
#

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

obsidian ledge
#

like delete the channel then recreate it?

#

like clone it?

unkempt canyonBOT
#

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").
lapis lintel
#

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))
muted lynx
#

in the event on_guild_channel_create(channel) how how do you get who created the channel

lapis lintel
muted lynx
#

when do you use audit logs exactly

#

where

lapis lintel
#

With the event that runs when a channel is created

muted lynx
#

I want to use them but like do you use then in an event

#

oh k

spark estuary
#

hey guys i was trying a copypasta for a code to play music but it doesnt seem to work can someone help?

slate swan
spark estuary
slate swan
#

!ytdl

unkempt canyonBOT
#

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)
spark estuary
keen talon
#

👀

slate swan
#

no worries , you still are allowed to use ffmpeg to play music files

final iron
#

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

shadow wraith
#

how can you make commands that only a specific guild can use

muted lynx
final iron
slate swan
final iron
#

If theres no decorator you could make your own custom one

slate swan
#

!d discord.ext.commands.CheckFailure

unkempt canyonBOT
#

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")
shadow wraith
#

eh, ill just use @commands.check(func) easy

#

wait how do you get the guild id ctx.guild.id i think right?

final iron
#

Yes

shadow wraith
#

cool cool

lapis lintel
muted lynx
#

I think I understand

final iron
#

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.

slate swan
# final iron Wouldn't this ingest all the other errors though?

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?

final iron
#

Its a blacklisted check so I wouldn't want any response

#

And its annoying having the error in console

final iron
#

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

sick birch
#

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

muted lynx
#
@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

sick birch
#

You probably stored it as an ID in your database

muted lynx
#

oh yeah thanks

#

that should work

final iron
sick birch
#

Yeah that works as well

final iron
#

Alr

lucid gazelle
#

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

cobalt jacinth
#

how does this change ?

worldly bane
slate swan
cobalt jacinth
#

thanks

lucid gazelle
worldly bane
agile adder
#

how do i find a channel id from a channel that the bot made

#

and also from the author of a command

slate swan
#

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)
agile adder
#

ah stanks

#

thanks*

jaunty wraith
#

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?

final iron
#

Indentation error Basically mobile programming in a nutshell

jade crater
#

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

jaunty wraith
heavy folio
#

not so sure bout apple

jaunty wraith
jaunty wraith
worldly bane
jaunty wraith
# worldly bane 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)

heavy folio
#

do you not see it?

jaunty wraith
slate swan
#

Someone pls help me with this

worldly bane
worldly bane
jaunty wraith
#

I didnt

#

Then it gives this error

worldly bane
#

indent this too

#

you have a space before await too

jaunty wraith
worldly bane
jaunty wraith
# worldly bane Np

Aparently image isnt defined but its part of the import (exactly from the video)

#

Could you help me pls?

jaunty wraith
#

from PIL import Image
from io import BytesIO

#

They are the new ones

slate swan
worldly bane
slate swan
#

-_-

#

Read the error

worldly bane
worldly bane
jaunty wraith
cobalt jacinth
#

how do i get id of the mentioned role ?

slate swan
worldly bane
heavy folio
#

simple: just dont use replit lol

slate swan
#

So what should I do?

heavy folio
slate swan
velvet tinsel
velvet tinsel
slate swan
#

I have no free access to pc, it's locked😢

jaunty wraith
#

Its no different to coding replit on pc

velvet tinsel
velvet tinsel
#

bruh

jaunty wraith
#

My cant even run chrome + i dont have access to it 99% of the time

velvet tinsel
heavy folio
jaunty wraith
#

I know its bad

#

But every app i try to use doesnt work

slate swan
# jaunty wraith Yes

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?

slate swan
jaunty wraith
#

Ikr

velvet tinsel
heavy folio
velvet tinsel
#

just get a pc

lucid gazelle
#

hi so I try to put quotes

#

and it didnt work HUHU

velvet tinsel
#

bro it's supposed to be a string

lucid gazelle
#

help me

#

ohhh

#

thankssss

shadow wraith
#

how would i get/see the permissions the command user (ctx.author) has

heavy folio
#

!d discord.TextChannel.permissions_for

unkempt canyonBOT
#

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...
shadow wraith
#

hmm example

slate swan
#

It clearly shows everything you need.

#

Use .permissions_for() on a discord.TextChannel object, and give as parameter the member.

shadow wraith
#

does it return a list or tuple or something

#

wait why are we using a discord.TextChannel

pliant compass
#

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

lucid gazelle
#

its an error

#

we put the string and its an error again

#

what's wrong with this?

upper swan
#

any word yet on what the python-discord bot wrapper will switch to? or a link to a discussion on the future?

lucid gazelle
upper swan
shadow wraith
#

Command raised an exception: AttributeError: 'Guild' object has no attribute 'create_channel'

i keep getting this error when trying to make a channel

lucid gazelle
#

thanks

upper swan
shadow wraith
#

well no but then how would you create a chanenl

upper swan
heavy folio
#

!d discord.Guild.create_text_channel

unkempt canyonBOT
#

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...
shadow wraith
#

oh mt thing was a ctx.message.guild obj oh

heavy folio
#

for embed.set_image

shadow wraith
#

!d disnake.Guild.channels

unkempt canyonBOT
shadow wraith
#

cool cool it exists

#

@heavy folio Command raised an exception: AttributeError: type object 'Guild' has no attribute 'create_channel'

shadow wraith
#

yeah

#

i just say discord to actually get answered x]

heavy folio
#

!d disnake.Guild.create_text_channel

unkempt canyonBOT
#

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...
shadow wraith
#

weird

heavy folio
#

if discord.py has it, disnake most likely has the same thing as well

shadow wraith
#

wait a fking second i put it as create_channel not create_text_channel

velvet tinsel
#

R.I.P

#

!d discord.Embed.set_author

unkempt canyonBOT
#

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.
lucid gazelle
#

the code is ok, but why is it not working?

slate swan
lucid gazelle
#

okay thanks

velvet tinsel
#

try ctx.author.avatar

heavy folio
#

ctx.author does it

lucid gazelle
#

ohhh

velvet tinsel
#

ohhhh

junior terrace
#

can i put a gif into an embed?

manic wing
unkempt canyonBOT
#

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.
manic wing
#

depends what site the emoji is from

slate swan
#
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
manic wing
#

!d discord.ext.commands.errors.CommandInvokeError

unkempt canyonBOT
#

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")
slate swan
#

ik its an exception but i wanna grab the exception after the invoke error

manic wing
#

you just do if isinstance(error, commands.error.CommandInvokeError)

slate swan
#

Command raised an exception: CardMissing: Card missing this bit

#

then CardMissing: Card missing this bit

manic wing
#

probably like

slate swan
#

as that is my final error

manic wing
#

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

slate swan
#

mmm

manic wing
#

wooooow no saying the R word!

#

naughty naughty

velvet tinsel
manic wing
#

😳

velvet tinsel
#

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

manic wing
#

I don’t say the R word on this prestigious upstanding server

#

and to clarify, i do not say bitch

velvet tinsel
#

True

bitter depot
#

@velvet tinsel yeah, please don't use the r-word here.

velvet tinsel
#

yert k

small igloo
#

||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

shadow wraith
#

how would i make the bot make a text channel i keep getting 'Guild' object has no attr 'create_text_channel'

slate swan
#
@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"

lucid gazelle
#

how do you embed.set_image / embed.set_thumbnail using url/str?

heavy folio
unkempt canyonBOT
#

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.
heavy folio
#

using url kwarg

#

!d discord.Embed.set_image

unkempt canyonBOT
#

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.
heavy folio
#

this too

heavy folio
slate swan
#

is it possible the bot is replying because the way i have typed the ID in the txt file?

cold sonnet
#

f.readlines returns a list with all the lines

#

if your id's are listed as one line for one id, it will work

slate swan
#

its giving this error now
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'in <string>' requires string as left operand, not int

steel void
#

how do i use await asyncio.sleep to make this event sleep for 15m?

cold sonnet
slate swan
#

I guess its considering the ID as a string? and comparing them?

cold sonnet
#

that's the problem

#

convert it to str

cold sonnet
gaunt ice
cold sonnet
#

you can replace it with 900

#

to spare the computer from doing meth

boreal ravine
cold sonnet
unkempt canyonBOT
#

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...
cold sonnet
lucid gazelle
#

hi

#

the problem in this pic is the daily commands are invalid syntax

#

so what we will do?

cold sonnet
#

@is_registered()
?

#

can't think of anything else

lucid gazelle
#

oh thankssss

lucid gazelle
heavy folio
# lucid gazelle

too bad idt you can typehint stuff on replit correct me if im wrong

cold sonnet
#

what

#

you can't... typehint?

heavy folio
#

on replit.

lucid gazelle
#

what?

cold sonnet
#

@lucid gazelle try it without the
: commands.Context

#

it isn't needed anyways

lucid gazelle
#

ohhh okay

#

thanksss

loud junco
#

Is this how bot var works?

slim ibex
#

no

#

not sure if the prefix can be a list of prefixes

slim ibex
#

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?

loud junco
#

I'm not changing the prefix

#

Every server same prefix

slim ibex
#

Well then you can only choose one prefix

loud junco
#

But how do I do the bot var thing

loud junco
slim ibex
#

bot.helmet?

loud junco
#

Ya helmet is the var name

slim ibex
#

oh the prefixes work?

loud junco
#

So bot.helmet?

slate swan
#

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

loud junco
#

@slim ibex it works

slim ibex
#

oh ok

#

Never seen multiple like that before

#

my fault

loud junco
#

Nola I use the dumb way

slate swan
#

it doesn't make sense

#

unless you mean like replit runs a python version that doesn't support typehinting

loud junco
slim ibex
#

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

loud junco
#

Okok thanks

small igloo
slim ibex
#

It doesn’t seem like you can do that @loud junco

loud junco
#

Then how do I make bot var that I can use everywhere in the bot without having the scoping error

unkempt canyonBOT
#

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:

https://paste.pythondiscord.com

small igloo
loud junco
#

!paste

unkempt canyonBOT
#

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.

loud junco
#

Use this

#

@small igloo

cold sonnet
#

you define botvars outside of the constructor

slim ibex
cold sonnet
#

and you can have multiple prefixes

slim ibex
#

if the variable is defined globally, there should be no scoping issues

loud junco
#

But pepo tell me not to do global var

velvet tinsel
#

Someone mentioned me?

cold sonnet
#

well don't

loud junco
#

:/

slim ibex
#

You don’t

cold sonnet
#

just define botvars outside of the constructor

lucid gazelle
#

its so hard to code omg

slim ibex
#

A global variable is a variable not declared In a specific function

cold sonnet
lucid gazelle
#

im new so, its hard for me

#

Who wants to code for a bot for free?

slim ibex
#

nobody

lucid gazelle
#

help HEJSJSJJS

#

I mean yeah ig bc its free

loud junco
#

Isn't working also

small igloo
honest vessel
#

why not just add case_insensitive=True, @loud junco

loud junco
#

Where do I add

#

After prefix?

honest vessel
#

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

loud junco
#

bot = commands.Bot(command_prefix= 'rpm', case_sensitive = False

#

Like this?

honest vessel
#

but you want it True

#

😄

loud junco
#

Case sensitive = false :/

honest vessel
#

its case_insensitive=True

loud junco
#

Okok

cold sonnet
#

why is there a comma

small igloo
cold sonnet
#

that's no error

small igloo
cold sonnet
#

that's a mistake not the error that would help us fix it

#

but yeah

loud junco
#

Lemme send the pic again

small igloo
#

how to change prefix (not in code, like.... $change_prefix[prefix] also how to make bot space insensitive)

velvet tinsel
small igloo
#

not work last time

cold sonnet
#

just why

slate swan
small igloo
#

@cold sonnet

slate swan
#

help pls

small igloo
honest vessel
#

on event

slate swan
small igloo
small igloo
honest vessel
#

nah it was before u edited

#

just to specific it more

loud junco
#

Fk that I'm raging now

#

Replit can't even let me edit the code peacefully

obsidian ledge
#

try @on_event

cold sonnet
#

u pinged me without pinging me

cold sonnet
#

therefore, ctx.guild won't work

slate swan
#

i fix this

#

thx

cold sonnet
#

good

#

:thumbsup_tone5:

slate swan
#

how get full name user (with tag)?

#

@cold sonnet

cold sonnet
unkempt canyonBOT
#

property name```
Equivalent to [`User.name`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.name "discord.User.name")
opaque wadi
#

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?

cold sonnet
#

doesn't that show the discriminator too?

slate swan
#

how show the discriminator?

slate swan
cold sonnet
#

hm

slate swan
cold sonnet
#

wait so does it

#

does it show the discriminator?

slate swan
slate swan
cold sonnet
#

member.display_name?

#

no prolly not

slate swan
#

sec

slate swan
cold sonnet
#

pretty sure you don't

opaque wadi
#

how do i edit bots nickname?

boreal ravine
slate swan
cold sonnet
#

I'm sitting in a car

slate swan
#

and

boreal ravine
slate swan
#

kayle has blessed us with his wisdom

opaque wadi
cold sonnet
#

but I remember I've been using the member.name + member.discriminator stuff until I replaced it with only one attribute

slate swan
cold sonnet
slate swan
#

how did danny do that

unkempt canyonBOT
#

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.
cold sonnet
#

wait I'm dumb

#

this isn't it

boreal ravine
opaque wadi
cold sonnet
#

wait

opaque wadi
#

ye sure

honest vessel
#

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`
boreal ravine
unkempt canyonBOT
#

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...
slate swan
cold sonnet
#

yes

slate swan
opaque wadi
honest vessel
#

@slate swani trying to get bot to join a thread when i create one

boreal ravine
#

!d discord.ClientUser

unkempt canyonBOT
#

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.
opaque wadi
#

still doesnt work

cold sonnet
slim ibex
#

what about the user are you trying to edit

cold sonnet
#

get a guild object

#

use guild.me.edit()

opaque wadi
opaque wadi
slate swan
unkempt canyonBOT
#

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}>'
    )```
boreal ravine
#

self._user being your name and discriminator

honest vessel
#

i want it to join thread why i as user create a thread

boreal ravine
#

!d discord.on_thread_join

unkempt canyonBOT
#

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.
opaque wadi
cold sonnet
#

👍

honest vessel
#

@boreal ravinei have that but it dosnt trigger when i create a thread

cold sonnet
#

is there a threads intent

#

!d discord.Intents

unkempt canyonBOT
#

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...
boreal ravine
honest vessel
#

am stupid i forgot to check role permissions for threads 😄

cold sonnet