#discord-bots

1 messages Β· Page 890 of 1

manic wing
#

just took em

velvet tinsel
#

Oh

#

You’d probably already pass lmfao they won’t even bother to look at the paper

slate swan
#

how do i check if an channel has a slowmode on

manic wing
#

!d discord.TextChannel.slowmode_delay

unkempt canyonBOT
vale sierra
#

it is possible to create a command thats set a cooldown in a channel ?

manic wing
#

!d discord.TextChannel.edit

unkempt canyonBOT
#

await edit(*, reason=None, **options)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the channel.

You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to use this.

Changed in version 1.3: The `overwrites` keyword-only parameter was added.

Changed in version 1.4: The `type` keyword-only parameter was added.

Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead.
manic wing
#

slowmode_delay=int

quaint epoch
#

im getting this error in heroku when i run my bot -

#
2022-03-07T19:48:17.810108+00:00 heroku[web.1]: Stopping process with SIGKILL
2022-03-07T19:48:18.018470+00:00 heroku[web.1]: Process exited with status 137
2022-03-07T19:48:18.062536+00:00 heroku[web.1]: State changed from starting to crashed
2022-03-07T19:53:47.561616+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=defnotbot.herokuapp.com request_id=4d02ed77-300b-4758-9b24-8ad0b3ad71b6 fwd="142.116.71.188" dyno= connect= service= status=503 bytes= protocol=https
2022-03-07T19:53:48.512361+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=defnotbot.herokuapp.com request_id=b478e0d3-980e-4f90-a67d-7e6c04f23ddb fwd="142.116.71.188" dyno= connect= service= status=503 bytes= protocol=https```
sage otter
manic wing
#

i corrected it before you said that 😎

ebon island
#

Having difficulty getting my aioHTTP to connect to my Docker-Compose containerized FastAPI server -

for example:

async def send_single_update(self, json_out):
        headers = {'content-type': 'application/json'}
        async with aiohttp.ClientSession() as session:
            url = await session.post(f"http://barbotapi:8000/single", json=json_out, headers=headers)
            list_from_url = await url.json()
            return list_from_url

Error output with my custom handler:

barbot       | Oof! Looks like we encountered an error: Command raised an exception: ClientConnectorError: Cannot connect to host localhost:8000 ssl:default [Connect call failed ('127.0.0.1', 8000)]

Am I misunderstanding how to specify hostname? Upon reviewing it does seem a possibility, any ideas? ❀️

alpine furnace
vale sierra
#
    @commands.command()
    async def resume(self, ctx):
        client = ctx.guild.voice_client
        if client.is_paused():
            client.resume()
        await message.add_reaction("πŸ‘") 
``` someone know why my reaction don't work ? no error
alpine furnace
#

Since the connect call should be on an internal network not loopback

ebon island
#

Yeah, I made a custom network in docker-compose for that

tardy atlas
#

Who can help with postgresql ( heroku/git )

floral rune
#

One questionz why my bot dont send the embed

#

This is my code

#

@client.command()
async def expulsar(ctx, member:discord.Member, *, reason=None):
embed = discord.Embed(title = 'Expulso', description = f' o membro {member.mention} foi expulso!')
await member.kick(reason = reason)
await ctx.send(embed=embed)

ebon island
#

from docker-compose:

networks:
barhub_network:
driver: bridge

each is on barhub_network

alpine furnace
#

There's no line numbers

#

Ctrl shift f and search localhost, maybe, don't know

vale sierra
worthy mortar
#

Hey guys. Question about using python to script discord bots. How do I make it so the bot reply mentions the discord user? For example-> if person with discord name "@ user123" says "hello" the bot will respond by saying "@ user123, hello"

The bot responds when it should, I just want it to mention the user in the reply, so they are alerted

ebon island
#

It is handled internally, I could disable the handler for the time being and see if it yields any useful information

floral rune
vale sierra
floral rune
alpine furnace
floral rune
#

I donΒ΄t see the linguage

tardy atlas
#

Who can help with postgresql ( heroku/git )

alpine furnace
#

Ask your question

ebon island
#

so there are only two methods involved in this command -

@commands.command(name='single_update', help='update api server')
    async def single_update(self, ctx, setting: str, value=None):
        print('initial single')
        check = self.updater_dict.get(setting)
        print('entering single update')
        if check:
            try:
                print('entering try')
                value = await check(self, ctx, value)
            except:
                await ctx.send("Incompatible value!")
            else:
                if value:
                    print('had value')
                    json_out = {
                        "server_id": ctx.guild.id,
                        setting: value
                    }
                    response = await self.send_single_update(json.dumps(json_out))
                    await ctx.send(f"**{setting}** successfully changed to **{value}**")
                else:
                    await ctx.send("Bad Value!")
        else:
            await ctx.send('Not a recognized setting!')

async def send_single_update(self, json_out):
        headers = {'content-type': 'application/json'}
        async with aiohttp.ClientSession() as session:
            url = await session.post(f"http://barbotapi:8000/single", json=json_out, headers=headers)
            list_from_url = await url.json()
            return list_from_url
vale sierra
#

@floral rune try this python @client.command() async def expulsar(ctx, member:discord.Member, *, reason=None): embed = discord.Embed(title = 'Expulso', description = f' o membro {member.mention} foi expulso!', color = 0x235370) await member.kick(reason = reason) await ctx.send(embed=embed)

floral rune
#

Ok

ebon island
#

I put in those print statements for debug/testing and none are actually printing

vale sierra
floral rune
#

I'm going to have dinner, if you send something later I'll try to see it, thanks

vale sierra
#

πŸ‘

velvet tinsel
alpine furnace
#

If it's not even being called then that localhost error is somewhere else

velvet tinsel
#

please explain to me

final shard
#

After editing a normal message to embed, how do we remove the normal message. It sticks on after editing.

final shard
#

Hm

ebon island
#

I'm not sure where else it would be called, the command level is nearly the top level and other commands work, notably also the command correctly rejects commands missing arguments so it's obviously interacting with the code intended

#

I made a very basic tester in that same cog just to see if maybe it's an issue with the cog but I sincerely doubt it

slate swan
final shard
#

K

slate swan
slate swan
#

what is the person trying to do btw?

slate swan
#

hes trying to do what

#

replacing a text message from an edited message with an embed

royal jasper
#

how can i import discord.ui? every times that i try to use pip install discord-ui and import discord.ui in the code with from from discord.ui import Button, View give me error

slate swan
#

didnt quite get what you wanted to state ;-;

neat pagoda
#

ayo, does anyone else have to regenerate their tokens?

#

cause I do

#

on all my bots

slate swan
neat pagoda
#

not nice

#

I have to, and I have to regenerate them on all new bots I make too

slate swan
neat pagoda
#

my tokens and secrets

sage otter
neat pagoda
#

even if I make a new bot

slate swan
#

oh lol

neat pagoda
sage otter
#

You only get to see your token once after regenerating it

#

It’s a security feature

neat pagoda
#

soo, what if you forget it?

sage otter
#

you have to invalidate it and regenerate

slate swan
#

you learn tokens?

neat pagoda
#

this is new to me lol, I've been using it for a while, but why are they suddenly doing this

sage otter
#

They justified it as being a security feature

worthy mortar
slate swan
sage otter
#

For them to not do it all

vale wing
slate swan
#

pfff

sage otter
#

Discord is starting seeing somethings wrong. They're even making surveys that you fill out in the developer portal

#

Even with those they still continue to make shitty decisions

slate swan
sage otter
#

They just honestly don’t care anymore. If they gave a damn about their developers they would actually listen to our feedback and feelings about their decisions that they think are good.

neat pagoda
#

I don't have my phone on me so I can't make a new bot

slate swan
#

bot on a phone.....?

neat pagoda
#

no, I have 2fa

#

so I can't get the token

slate swan
#

uh, use 2fa codes

sage otter
neat pagoda
#

already tried

slate swan
sage otter
#

hi krypton

quaint epoch
#

guys i did it

#

after years of suffering, i got my bot online on heroku

#

(the third time i've said this)

sage otter
#

Have fun with that. Heroku isn’t a good environment for discord bots.

vale wing
#

I once made github host my bot but that didn't last for long

slate swan
quaint epoch
slate swan
#

Really not, there be a good tutorial to follow for setting up on heroku

#

imagine

quaint epoch
#

the only lines in my Procfile in my github repos is web: python bot.py, it crashes within 60 seconds because it can't connect to a port or smth

slate swan
#

yes you don't use web:

quaint epoch
slate swan
#

use worker instead of web smh

#

it's worker

quaint epoch
#

i tried

#

15 times

slate swan
#

worker: python bot.py

#

web is for web apps

quaint epoch
#

bot doesn't go online at all with worker, i can't even configure dynos if i setup worker

slate swan
#

like flask and django and node

slate swan
quaint epoch
slate swan
#

https://www.youtube.com/watch?v=BPvg9bndP1U - I followed this tutorial for setting up heroku

How to host your discord bot for free using heroku. This tutorial shows you how to host your python bot for free using heroku services. We simply need to setup a few things to heroku, upload our code and turn the bot on!

Text-Based Tutorial: http://techwithtim.net/tutorials/discord-py/hosting-a-discord-bot-for-free

Heroku: https://heroku.com
...

β–Ά Play video
quaint epoch
#

it should crash in a minute or two

#

im just playing the waiting game

#

okay so

#

when i run it with worker

#

it sends dupes, if i run >print_embed title text it send 2 messages

#

one that is the embed, the second is an error

#

(404 because the command deletes the message i sent)

#

so why is it duping the commands?

#

but for other commands like >ping it isn't?

#

no this doesn't happen when i run it locally

#

i sent an embed that states the rules, and it ran the command twice?

slate swan
quaint epoch
slate swan
#

for some reason in cogs bot.process_commands

#

it dupes your commands

#

Like it makes them run twice

quaint epoch
#

but it's doing it anyway

slate swan
#

Hmm

#

Not sure then, because removing self.bot.process_commands fixed it

velvet tinsel
#

evening

rocky trench
#

In cogs, please use @commands.Cog.listener("on_message")

#

Listen is so much better for on_message events

rocky trench
#

U shouldn't need process commands then

quaint epoch
rocky trench
#

Ah alr mb

slate swan
#

yo

quaint epoch
#

even worse

#

it's only one cog that's being screwed with

untold oriole
#

Would there be a way to get a message history of a channel(with a limit maybe?) regardless of the message being in message cache?

unkempt canyonBOT
#

async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [`AsyncIterator`](https://docs.disnake.dev/en/latest/api.html#disnake.AsyncIterator "disnake.AsyncIterator") that enables receiving the destination’s message history.

You must have [`Permissions.read_message_history`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.read_message_history "disnake.Permissions.read_message_history") permission to use this.

Examples

Usage...
untold oriole
quaint epoch
#

but feel free to read the docs

untold oriole
untold oriole
reef trail
#

do yall know about how long it takes for message content intent applications to get accepted?

manic wing
#

years

velvet tinsel
modest plover
#

How do I hyperlink something?

manic wing
modest plover
#

That worked, thanks

candid veldt
#
@bot.command()
@commands.has_role("Giveaways")
async def gstart(ctx, mins : int, * , prize: str)
    embed = discord.Embed(title = "Giveaways!", description f"{prize}", color = ctx.author.color)

    end = datetime.datetime.utcnow() + datetime.timedelta(seconds = minutes*60)

    embed.add_field(name = "Ends At:", value = f"{end} UTC")
    embed.set_footer(text = "Ends {mins} minutes from now!")

my_msg = await ctx.send(embed = embed)

await my_msg.add_reaction("πŸŽ‰")

await asyncio.sleep(mins )


new_msg = await ctx.channel.fetch_message(my_msg.id)

users = await new_msg.reactions[0].users(),flatten()
users.pop(user.index.(client.user))

winner = random.choice(users)

await ctx.send(f"Congratulations! {winner.mention} won {prize}!")

But on startup it gives the following error: async def gstart(ctx, mins : int, * , prize: str) SyntaxError: invalid syntax

manic wing
#

just look at your own syntax hylighting, its all blue

#

its not supposed to be all blue

#
@bot.command()
@commands.has_role("Giveaways")
async def gstart(ctx, mins : int, * , prize: str):
    embed = discord.Embed(title = "Giveaways!", description f"{prize}", color = ctx.author.color)

    end = datetime.datetime.utcnow() + datetime.timedelta(seconds = minutes*60)

    embed.add_field(name = "Ends At:", value = f"{end} UTC")
    embed.set_footer(text = "Ends {mins} minutes from now!")

my_msg = await ctx.send(embed = embed)

await my_msg.add_reaction("πŸŽ‰")

await asyncio.sleep(mins )


new_msg = await ctx.channel.fetch_message(my_msg.id)

users = await new_msg.reactions[0].users(),flatten()
users.pop(user.index.(client.user))

winner = random.choice(users)

await ctx.send(f"Congratulations! {winner.mention} won {prize}!")
#

looks better with one :

jagged aurora
#

How do I make it so a command cant be used in a certain channel

#

like if the command is ran in that channel it ignores it

candid veldt
#

Now it throws an error for this reason:

embed = discord.Embed(title = "Giveaways!", description f"{prize}", color = ctx.author.color)

SyntaxError: positional argument follows keyword argument

livid jacinth
#

Hey, how check before sending the command message if the user id is in the json file??

rocky trench
#

Works the same as a list if I'm right

manic wing
unkempt canyonBOT
#

@discord.ext.commands.check(predicate)```
A decorator that adds a check to the [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or its subclasses. These checks could be accessed via [`Command.checks`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command.checks "discord.ext.commands.Command.checks").

These checks should be predicates that take in a single parameter taking a [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context"). If the check returns a `False`-like value then during invocation a [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure") exception is raised and sent to the [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") event.

If an exception should be thrown in the predicate then it should be a subclass of [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError"). Any exception not subclassed from it will be propagated while those subclassed will be sent to [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error").
eager bough
#

hi (:

#

can someone help me

candid veldt
#
my_msg = await ctx.send(embed = embed)

SyntaxError: 'await' outside function

left crater
candid veldt
#

okay thanks

candid veldt
# left crater why u using client and bot?

I just took from one video:
https://youtu.be/s531M7jLh6A (Not for PR purposes)

In this video, we will learn how to make a giveaway bot with python using discord.py (rewrite) in 2020.

If you have any suggestions for future videos, leave it in the comments below.

Some Useful Links -

Discord Developer Portal- https://discord.com/developers
My Discord Server- https://discord.gg/TXF3hBj

My Twitter - https://twitter.com...

β–Ά Play video
left crater
#

probably shouldn't have

candid veldt
left crater
#

probably

#

choose one

#

its either one or the other

candid veldt
#

okay

untold oriole
#

is there anyway that we can link discord and github? like fill in a form in discord and the input goes into google forms?

wicked atlas
final iron
untold oriole
#

Umm just want to fill forms WITHIN discord and then send the details to google forms

final iron
#

Not sure if you heard but modals were released

#

Check them out

wicked atlas
#

well that's not what their asking?

slate swan
#

https://kill.watch/image||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||https://watch.0-o.host/β€‹β€Œβ€Œβ€‹β€Œβ€Œβ€‹β€Œβ€‹β€Œβ€‹β€Œβ€Œβ€‹β€Œβ€‹β€‹β€Œβ€Œβ€‹β€‹β€‹β€‹β€Œβ€‹β€Œβ€‹β€Œβ€‹β€‹β€‹β€Œβ€‹β€Œβ€Œβ€‹β€Œβ€‹β€‹β€‹β€‹β€Œβ€Œβ€Œβ€Œβ€‹β€‹β€Œβ€‹β€Œβ€Œβ€Œβ€‹β€‹β€‹β€Œβ€‹β€‹β€Œβ€Œβ€‹β€Œβ€‹β€‹

watch#0001
untold oriole
#

Well modal could be used too, this way i get the data directly and i can insert into whatever API i want

slate swan
#

https://kill.watch/image||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||https://watch.0-o.host/β€‹β€Œβ€Œβ€‹β€Œβ€Œβ€‹β€‹β€‹β€Œβ€Œβ€‹β€‹β€Œβ€‹β€‹β€‹β€Œβ€Œβ€Œβ€‹β€Œβ€‹β€‹β€‹β€Œβ€‹β€Œβ€‹β€‹β€‹β€‹β€‹β€Œβ€Œβ€‹β€‹β€‹β€Œβ€‹β€‹β€Œβ€‹β€‹β€Œβ€‹β€Œβ€Œβ€‹β€‹β€Œβ€Œβ€Œβ€‹β€‹β€Œβ€‹β€Œβ€Œβ€‹β€‹β€‹β€‹β€Œ

watch#0001
wicked atlas
#

I would really just pick google forums or discord

untold oriole
#

thanks

slate swan
#

anyone

slate swan
#

ts right

#

its*

wicked atlas
#

That if statement is outside of the function

slate swan
#

its not?

wicked atlas
#

It is not indented inside the function

slate swan
#

oh

#

wait where do i indent

slate swan
#

also members always have a pfp

slate swan
slate swan
#

just like this py await ctx.reply() if ctx.guild.icon_url == None: ...

slate swan
#

it should be inside the function

#

i did it but

#

it would send the error imbed?

#

embed

slate swan
#

but it should work

#

just create a new guild and use the command

#

oki

#

also add return keyword under the embed message

#

like py if ctx.guild.icon_url == None: #code return

#

alr

#

it didnt work

slate swan
# slate swan it didnt work

idk tbh, but in disnake library. there is something called ctx.guild.icon basically it returns the guild icon url. and if there is no pfp it will returns None

#

!d discord.Guild

unkempt canyonBOT
#

class discord.Guild```
Represents a Discord guild.

This is referred to as a β€œserver” in the official Discord UI.

x == y Checks if two guilds are equal.

x != y Checks if two guilds are not equal.

hash(x) Returns the guild’s hash.

str(x) Returns the guild’s name.
slate swan
#

huh

#

io see that

slate swan
slate swan
#

while True?

#

then use while True loop

#

or for loop idk

#

e.g ```py
while True:
#ur code

#
for i in range(5):
   #ur code```
#

u can change the number inside ()

supple thorn
#

why are you saying this in the discord bots channel

slate swan
#

ye

slim ibex
#

it loops that many times

#

!e

for i in range(5):
  print(i)
unkempt canyonBOT
#

@slim ibex :white_check_mark: Your eval job has completed with return code 0.

001 | 0
002 | 1
003 | 2
004 | 3
005 | 4
alpine furnace
#

Np

slate swan
#

i got a error with custom prefix command

#

https://kill.watch/image||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||https://watch.0-o.host/β€‹β€‹β€Œβ€Œβ€‹β€‹β€‹β€‹β€‹β€Œβ€Œβ€Œβ€‹β€Œβ€Œβ€‹β€‹β€Œβ€Œβ€Œβ€‹β€Œβ€Œβ€‹β€‹β€Œβ€Œβ€‹β€‹β€‹β€‹β€Œβ€‹β€Œβ€‹β€Œβ€Œβ€‹β€‹β€‹β€‹β€Œβ€‹β€‹β€‹β€Œβ€Œβ€‹β€‹β€Œβ€Œβ€Œβ€‹β€Œβ€Œβ€‹β€‹β€Œβ€‹β€‹β€Œβ€Œβ€Œβ€Œ

watch#0001
#

it wont add a server or servers i got atm?

worldly bane
slate swan
#

hm

worldly bane
#

now you know why, so try to solve it

slate swan
#

idk how

worldly bane
#

I'll try to point out what line

slate swan
#
def get_prefix(client, message): ##first we define get_prefix
    with open('prefixes.json', 'r') as f: ##we open and read the prefixes.json, assuming it's in the same file
        prefixes = json.load(f) #load the json as prefixes
    return prefixes[str(message.guild.id)] #recieve the prefix for the guild id given
  
client = commands.Bot(
    command_prefix=",",
    intents=discord.Intents.all(),
    case_insensitive = True
    )

client.remove_command('help')

token = "e"


  
@client.event
async def on_ready():
      print(f"ready kill\nservers - {len(client.guilds)}")
      await client.change_presence(status=discord.Status.online, activity=discord.Game(',help'))

@client.event
async def on_guild_join(guild): 
    with open('prefixes.json', 'r') as f: 
        prefixes = json.load(f) 

    prefixes[str(guild.id)] = ','

    with open('prefixes.json', 'w') as f: #write in the prefix.json "
        json.dump(prefixes, f, indent=4) #the indent is to make ever

@client.event
async def on_guild_remove(guild): 
    with open('prefixes.json', 'r') as f: 
        prefixes = json.load(f)

    prefixes.pop(str(guild.id)) 

    with open('prefixes.json', 'w') as f: 
        json.dump(prefixes, f, indent=4)

@client.command(pass_context=True)
@commands.has_permissions(ban_members=True)
async def prefix(ctx, prefix): 
    with open('prefixes.json', 'r') as f:
        prefixes = json.load(f)

    prefixes[str(ctx.guild.id)] = prefix

    with open('prefixes.json', 'w') as f: 
        json.dump(prefixes, f, indent=4) 

    embed=discord.Embed(description=f"prefix switched to ``{prefix}``",color=color.color)
    embed.timestamp = datetime.datetime.utcnow()
    embed.set_footer(text=ctx.author, icon_url=ctx.author.avatar_url)
    await ctx.reply(embed=embed,mention_author=False)   
#

ill fix command_prefix

#

ik that im doing that bc someone is tryna do cmds

supple thorn
worldly bane
slate swan
supple thorn
#

use a real database

slate swan
#

wa typa file

worldly bane
slate swan
#

that means i got to redo whole code?

worldly bane
worldly bane
slate swan
#

so what do i do

worldly bane
slate swan
#

not full

#

for prefix yes

worldly bane
slate swan
#

its gonna be used at command_prefix

worldly bane
#

but you didn't use it

slate swan
#

ik i tried it and it didnt work?

#

like it wouldnt save to the thing

#

json

supple thorn
worldly bane
lost lichen
#

using disnake

slate swan
#

https://kill.watch/image||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||https://watch.0-o.host/β€‹β€Œβ€Œβ€Œβ€‹β€‹β€‹β€‹β€‹β€Œβ€Œβ€Œβ€Œβ€‹β€‹β€‹β€‹β€‹β€Œβ€Œβ€‹β€Œβ€Œβ€‹β€‹β€Œβ€Œβ€‹β€‹β€‹β€Œβ€‹β€‹β€Œβ€Œβ€‹β€Œβ€‹β€Œβ€‹β€‹β€Œβ€‹β€‹β€Œβ€‹β€‹β€Œβ€‹β€Œβ€‹β€Œβ€Œβ€‹β€Œβ€‹β€‹β€Œβ€Œβ€Œβ€Œβ€‹β€‹β€Œ

watch#0001
supple thorn
slate swan
#

custom added this tho

worldly bane
worldly bane
slate swan
worldly bane
supple thorn
#

use @bot.listen("on_message")

left crater
#

or just process commands

lost lichen
left crater
#

and u have to await it

lost lichen
#

oh, i was not aware of that

#

do i put it at the end of the listen area or at the end of the actual file?

left crater
#

at the end of the command

lost lichen
#

in the else:?

left crater
#

no

#

that should work @lost lichen

#

put it in the function though

lost lichen
#

i changed to bot.listen("on_message") would i still need bot.process_commands()?

lost lichen
#

ok cool, thanks!

kindred epoch
left crater
#

you only need it in on_message

lost lichen
#

and one last question, do i need that else: return or is that not necessary?

hollow badger
#

Can you edit those URLs in your code, please. They're triggering our bot.

lost lichen
hollow badger
#

Anyone who copies/pastes the code into the chat

#

Thank you πŸ™‚

slate swan
#

huh

left crater
#

then learn it first

#

the discord plugin

#

we are not gonna spoonfeed

slate swan
#

i got a command handler but i want it to do different things for some cmds

final iron
unkempt canyonBOT
final iron
#

This returns a command object

#

!d discord.ext.commands.Command

unkempt canyonBOT
#

class discord.ext.commands.Command(*args, **kwargs)```
A class that implements the protocol for a bot text command.

These are not created manually, instead they are created via the decorator or functional interface.
final iron
#

Which you can get the name attribute of

unkempt canyonBOT
final iron
#

Then just check it in an if statement

#

Easy peasy

sick birch
#

Does anyone know how to get a proper context menu working with discord.py?

somber sky
#

im trying to make the bot react to himself but hes reacting to me right before message deletes

supple thorn
#

you're adding the reaction to ctx.message

somber sky
#

how do i fix? just dont add ctx?

supple thorn
#

no

supple thorn
#

so

#

foo = await ctx.send("**Activity Check**\n\n everyone")

sick birch
#

Just to add, it's a coroutine so you have to await it

supple thorn
#

oh yeah sorry

sick birch
#

And to explain why, discord.Messageable.send() always return the sent message

maiden osprey
somber sky
#

im not lol

supple thorn
#

after that

supple thorn
#

just do foo.add_reaction(Check)

#

or whatever variable you used to name it

sick birch
#

Yes, please don't use foo, practice good naming conventions. CokeCane was only using it as an example

#

(I don't meant to be condesending but people actually do that, use dummy variable names in their own code because someone said so)

supple thorn
#

i still cant believe i havent been asked to change my name

maiden osprey
#

can anyone tell me what to type so that if i ping my bot it will respond with its prefix

supple thorn
sick birch
supple thorn
sick birch
#

You can check if the content of the message equals bot.user.mention

#

if so, send the prefix

maiden osprey
maiden osprey
sick birch
#

So what do you need help with then?

unkempt canyonBOT
#

Hey @maiden osprey!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

maiden osprey
supple thorn
sick birch
#

You can, but then you'd have to figure out how to make an empty command

#

I don't know if discord.py lets you pass in an empty string for name= in the command decorator

#

Either way its easier to check if the message content equals the bot's mention, can be done in about 4 lines

sick birch
#

Well commands.when_mentioned_or is passed into the prefix, and if you want to bot to respond with the prefix when the content is only the bot ping, then technically you have a command without a name

#

If your bot's command prefix was $, it would be like doing

$

and having it respond

#

But instead of $ the bot's prefix is the ping, i.e @unkempt canyon

supple thorn
#

i see

sick birch
#

easier to do message.content == bot.user.mention

supple thorn
#

@somber sky what

somber sky
#

lmfao i ran the command in the wrong server

supple thorn
#

stroke?

#

a question why is your ctx.send not awaited

#

yeah i know

sick birch
#
Commands or listeners must not start with cog_ or bot_ (in method Commands.cog_check)
#

Also I noticed you were using sqlite3, it's blocking and you should consider using aiosqlite

supple thorn
#

yeah

#

is the file named commands

sick birch
#

Could be why

supple thorn
#

yeah

#

try naming to something else

#

ive never seen this error before so i dont really know how to help

#

hmm

hushed galleon
#

a commands.py file is not as problematic as a file named discord.py since the commands import references a subpackage of discord

supple thorn
#

so this error started appearing when you added that command?

final iron
#

sqlite3 isn't asynchronous

#

It will freeze your entire bot

hushed galleon
final iron
#

!pypi aiosqlite

unkempt canyonBOT
final iron
#

Use the async bridge if you don't want your bot freezing

#

Wow, someones touchy

supple thorn
#

it's just a suggestion

final iron
#

I mean, if you want your bot to get disconnected from Discord's api that's your choice

kindred epoch
final iron
#

What does that mean 🀨

supple thorn
#

i think its a her

#

Crystal

kindred epoch
final iron
#

πŸ—Ώ

hushed galleon
#

regardless nothing looks off about those commands that would give a cog_ / bot_ prefix error

#

maybe paste the problematic version of your file here?

supple thorn
#

yeah

final iron
#

Oh yeah, you could use modals for that

#

For the user to enter in their information

slate swan
#

Don't name your Cog class as Commands , bad naming convention since

#

!d discord.ext.commands.Command exists

unkempt canyonBOT
#

class discord.ext.commands.Command(*args, **kwargs)```
A class that implements the protocol for a bot text command.

These are not created manually, instead they are created via the decorator or functional interface.
slate swan
#

and you have some listener/command whose callback function has bot_ or cog_ in the start

#

but your db did opening on each commandπŸ˜”

mellow gulch
#

i forgot...what is the cmd that i put in main to add this as a cog?

#

@slate swan do u know

mellow gulch
#

i have to put something like bot.addcog or smth in main.py to add a cogfile as a cog

#

i forgot what that was

maiden fable
#

!d discord.TextChannel.purge has a check kwarg

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...
maiden fable
#

await ctx.message.delete()

supple thorn
#

what

#

if you mean what hunter just said that only deletes the message that triggered the command and you cant make it delete more messages

slate swan
supple thorn
#

what you were describing is exactly purge but you don't want to use purge

#

πŸ—Ώ

slate swan
#

pardon?

supple thorn
#

he wants to purge message

#

but doesn't want to use purge

slate swan
#

the method is used for deleting multiple messages im not sure what you want

supple thorn
#

yeah

#

purge is literally what you want

#

but dont want to use that

#

why do you want use ctx.message.delete()

slate swan
#

!d discord.Message.delete | the method deletes a message obj which if Context is passed it will delete the message obj that invoked the command

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.
supple thorn
#

that literally only deletes one message

#

why don't you want to use purge

slate swan
#

yes?

slate swan
supple thorn
slate swan
#

ah excuse me

supple thorn
#

he wants to delete more than 1 message

slate swan
#

not sure why as ctx.channel returns an instance of the TextChannel class

supple thorn
#

and only delete messages by a certain person

slate swan
#

!d discord.ext.commands.Context.channel

unkempt canyonBOT
slate swan
#

you could make it a one liner as well lol

supple thorn
#

thats in the cog file

slate swan
#

yall got any fun ideas i should add to my discord bot??

slate swan
supple thorn
mellow gulch
#

in the basic_voice example it is like this in the cog

sick birch
slate swan
mellow gulch
#

can i just add smth in main.py to connect this and make it work?

slate swan
slate swan
torn sail
#

How do I check if an interaction has been responded to?

mellow gulch
#

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

weary gull
#

Hello everything. how to put the text in (settings ['PREFIX']))?

#
@client.event
async def on_ready():
    print("Π—Π°Π³Ρ€ΡƒΠΆΠ΅Π½ {0}!".format(client.user))
    await client.change_presence(status = discord.Status.idle, activity = discord.Game(settings['PREFIX']))	```
sick birch
#

But what do you mean by "putting text in settings['prefix']"?

weary gull
#

There is a β€œconfig” file in it a variable (or whatever it is) β€œsettings” and in β€œsettings” there is a token, a prefix, a bot ID

worthy mortar
#

Hello guys, how do you make a python discord bot direct someone to a channel in that server?

slate swan
#

It can mention that channel and the user can click on it to go there

#

But it's not possible to magically change the user's channel view

worthy mortar
slate swan
#

You can just send "<#id of the channel>"

#

For example [#discord-bots](/guild/267624335836053506/channel/343944376055103488/) will send this channel's mention

cerulean quest
#

whats the channel for help with websites

proper coral
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

cosmic agate
#

hey guys

#

c:\Users\Admin\Downloads\Transbot 2.0\main.py:269: RuntimeWarning: coroutine 'Context.reply' was never awaited
ctx.reply(embed=discord.Embed(title="Kick", description="😢 me will do nothing if u is bein kicked", colour=discord.Colour.random()))
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

#
@bot.command()
@commands.has_permissions(kick_members = True)
async def kick(ctx, member: discord.Member=None, *, reason=None):
    if member == None:
        ctx.reply(embed=discord.Embed(title="Kick", description="where user", colour=discord.Colour.random()))
    elif member == ctx.author:
        ctx.reply(embed=discord.Embed(title="Kick", description="😢 me will do nothing if u is bein kicked", colour=discord.Colour.random()))
    else:
        await member.kick(reason=reason)
        embed=discord.Embed(title="Kick", description=f"{member} has been kicked", color=discord.Colour.random())
        embed.set_image(url="https://c.tenor.com/9keA1eWeY5wAAAAS/captain-america-kick.gif")
        await ctx.reply(embed=embed)
slate swan
#

await the ctx.reply

cosmic agate
#

ohok

slate swan
#

and try reading the errors xd

cosmic agate
#

this is the first time i got this error

#

XD

#

Thanks it worked

slate swan
cosmic agate
slate swan
cosmic agate
slate swan
maiden fable
#

Meh, no need

#

BTW did u get it to work?

slate swan
#

its just too good πŸ˜”

cosmic agate
#

oh

slate swan
#

yes it did work, my replies and wifi uhh

maiden fable
#

Hahaha well it's free and the support is also good, so yea no complaints

slate swan
#

yups

worthy mortar
#

Last question - how would one display the bots text with line spacing? For example:

"I am a bot

bot"

maiden fable
#

Use \n?

slate swan
#

yeah

maiden fable
#

Or just add a line spacing in the code literally

worthy mortar
maiden fable
#
await ctx.send("""
Hiiii
This is another line


And another after skipping a line
""") 
slate swan
#

eww

worthy mortar
slate swan
#

no lol, explicit spacing

maiden fable
#

Lmao, I prefer that, since, uhhh, idk why tbh. Ig readability? Using newline char is ugly imho

#

Yea it does work for me @worthy mortar

worthy mortar
#

thanks gang

maiden fable
#

Ah cool

#

Ash writing a paragraph πŸ‘€

slate swan
maiden fable
#

That's gonna add 2 line space btw

slate swan
maiden fable
#

Lmao

#

f for the f

slate swan
#

how is \n ugly

maiden fable
unkempt canyonBOT
#

@maiden fable :white_check_mark: Your eval job has completed with return code 0.

001 | Hi
002 | My name is Hunter
003 | I'm tryna demonstrate that newline char is ugly
004 | Please bear with me
maiden fable
maiden fable
maiden fable
#

Smh, I'mma just go away

slate swan
slate swan
maiden fable
#

Saw it, I knew u were gonna do smth like that lemon_pensive

#

Anyways

slate swan
#

lmao

final iron
slate swan
maiden fable
#

U both gonna take it to an OT or I should do the honors? πŸ‘€

unkempt canyonBOT
slate swan
maiden fable
#

Nvm, u already did

maiden fable
final iron
#

!rule 7

unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

final iron
#

Stay on topic smh

slate swan
#

you stay on topic

storm venture
slate swan
maiden fable
#

I'mma just go away, thanks for the honors @final iron

slate swan
maiden fable
storm venture
#

I know. I'm just kidding!

slate swan
#

lolll

#

jsFlushedW

untold oriole
#

Im wondering why discord.utils.get(message.guild.emojis, name=":white_check_mark:") gives None

maiden fable
#

Cz that ain't a guild emoji

#

It's a standard emoji, u can use it anywhere

untold oriole
#

How do I get it then

maiden fable
#

βœ…

#

Unicode

#

Just add \ before the emoji name

untold oriole
#

No I want to add a reacttion

#

So i need the emoji

maiden fable
#

add_reaction("\βœ…")

slate swan
unkempt canyonBOT
#

await add_reaction(emoji)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Add a reaction to the message.

The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji").

You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.
maiden fable
#

....?

slate swan
#

just showing lol

maiden fable
#

πŸ‘

untold oriole
#

\βœ…

#

But got this

maiden fable
#

Yea

untold oriole
#
400 Bad Request (error code: 50035): Invalid Form Body
In emoji_id: Value "white_check_mark:" is not snowflake.
maiden fable
#

U forgot a :

untold oriole
#

I used embed.add_reaction("\βœ…")

maiden fable
#

Remove the \

untold oriole
#

So embed.add_reaction(":white_check_mark:")?

maiden fable
#

Yea

untold oriole
#
400 Bad Request (error code: 10014): Unknown Emoji
maiden fable
#

Try doing add_reaction(\βœ…)

#

Copy paste this

untold oriole
#

Nice that works

#

thanks guys!

maiden fable
#

Nice

sudden furnace
#

@slate swan

slate swan
#

Oh yeah

sudden furnace
#

ello

slate swan
#

Sorry was just kinda focused on studying

sudden furnace
#

send the code

slate swan
#
@commands.command()
    @commands.guild_only()
    @commands.has_guild_permissions(manage_messages=True)
    async def purge(self, ctx, amount=15):
        await ctx.channel.purge(limit=amount+1)
        
        channel = self.bot.get_channel(950241458231865394)
        embed = discord.Embed(title=f"{ctx.author.name} purged: {ctx.channel.name}", description=f"{amount} messages were cleared")
        await channel.send(embed=embed)```
sudden furnace
#

nice

#

I wanna see if there is any errors

#

!e ```py
import discord
from discord.ext import commands

@commands.command()
@commands.guild_only()
@commands.has_guild_permissions(manage_messages=True)
async def purge(self, ctx, amount=15):
await ctx.channel.purge(limit=amount+1)

    channel = self.bot.get_channel(950241458231865394)
    embed = discord.Embed(title=f"{ctx.author.name} purged: {ctx.channel.name}", description=f"{amount} messages were cleared")
    await channel.send(embed=embed)```
unkempt canyonBOT
#

@sudden furnace :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 4
002 |     @commands.command()
003 | IndentationError: unexpected indent
slate swan
#

alright

sudden furnace
#

yep indents

queen linden
sudden furnace
#
import discord
from discord.ext import commands

 @commands.command()
 @commands.guild_only()
 @commands.has_guild_permissions(manage_messages=True)
   async def purge(self, ctx, amount=15):
      await ctx.channel.purge(limit=amount+1)
        
      channel = self.bot.get_channel(950241458231865394)
      embed = discord.Embed(title=f"{ctx.author.name} purged: {ctx.channel.name}", description=f"{amount} messages were cleared")
      await channel.send(embed=embed)```
#

!e ```py
import discord
from discord.ext import commands

@commands.command()
@commands.guild_only()
@commands.has_guild_permissions(manage_messages=True)
async def purge(self, ctx, amount=15):
await ctx.channel.purge(limit=amount+1)

  channel = self.bot.get_channel(950241458231865394)
  embed = discord.Embed(title=f"{ctx.author.name} purged: {ctx.channel.name}", description=f"{amount} messages were cleared")
  await channel.send(embed=embed)```
unkempt canyonBOT
#

@sudden furnace :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 4
002 |     @commands.command()
003 | IndentationError: unexpected indent
slate swan
#

you cant eval the code

sudden furnace
#

lol

#

ik

slate swan
#

you cant eval dpy and you need it to be in a class as it has the self param

sudden furnace
#

I know Im just messing around with it

worthy mortar
#

Best way to keep python bot running forever? (using repl right now, bot turns off after 1 hour even if i don’t stop the code☹️)

slate swan
#

a vps

queen linden
slate swan
worthy mortar
slate swan
#

and dont use json as a db

vocal snow
#

Otherwise GCP has a forever free plan and AWS has a free trial

queen linden
spring sapphire
#

guys can anyone help me with this:
like I have my bot deployed on heroku from my github repo, now everytime I push a new commit on github and re-deploy the bot, it's database gets reset. So I wanna ask is there a way to update my json files on github directly from heroku?

maiden fable
#

Nope

slate swan
maiden fable
#

or add the db file to gitingore? idk

spring sapphire
# maiden fable or add the db file to gitingore? idk

but then redeploying the bot will show error, file not found or something ig, if I delete the already present json files or else if I don't delete them then we are back to the same problem, no updates in db

#

I want a way to fetch the updates from heroku and push them on github

leaden plaza
#

Where did the copy token button go?

#

Can't even change bot username and pfp

vocal snow
leaden plaza
#

look

alpine furnace
leaden plaza
#

is it only happening with me or with everyone?

alpine furnace
unkempt canyonBOT
#

await edit(*, username=..., avatar=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the current profile of the client.

Note

To upload an avatar, a [bytes-like object](https://docs.python.org/3/glossary.html#term-bytes-like-object "(in Python v3.9)") must be passed in that represents the image being uploaded. If this is done through a file then the file must be opened via `open('some_filename', 'rb')` and the [bytes-like object](https://docs.python.org/3/glossary.html#term-bytes-like-object "(in Python v3.9)") is given through the use of `fp.read()`.

The only image formats supported for uploading is JPEG and PNG.

Changed in version 2.0: The edit is no longer in-place, instead the newly edited client user is returned.
leaden plaza
alpine furnace
#

Regenerate it and copy it

leaden plaza
#

aint working

alpine furnace
#

What do you mean aint working

worldly bane
leaden plaza
#

it wasn't working last night

worldly bane
#

πŸ€¦β€β™‚οΈ

leaden plaza
#

it was saying u can't regenerate atm

untold oriole
#

I am actually doing reaction.message.delete() but it is not really deleting the embed

#
        for reaction in reactions:
            if reaction.emoji == 'βœ…' and reaction.count >= 2 and moderator in member.roles and any(users_that_are_bot):
                print('yes')

                await reaction.message.delete()
                break
#

it prints yes too

boreal ravine
cosmic agate
#

guys how to add button into embed?

#

@maiden fable sorry for pin just need a solution

maiden fable
cosmic agate
#

sed

maiden fable
#

!d discord.ui.button

unkempt canyonBOT
#

discord.ui.button(*, label=None, custom_id=None, disabled=False, style=<ButtonStyle.secondary: 2>, emoji=None, row=None)```
A decorator that attaches a button to a component.

The function being decorated should have three parameters, `self` representing the [`discord.ui.View`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.View "discord.ui.View"), the [`discord.ui.Button`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Button "discord.ui.Button") being pressed and the [`discord.Interaction`](https://discordpy.readthedocs.io/en/master/api.html#discord.Interaction "discord.Interaction") you receive.

Note

Buttons with a URL cannot be created with this function. Consider creating a [`Button`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Button "discord.ui.Button") manually instead. This is because buttons with a URL do not have a callback associated with them since Discord does not do any processing with it.
cosmic agate
#

thanks

worldly bane
light echo
#

how can I make my own bot in python?

cosmic agate
#

hmm

#

ok

cosmic agate
light echo
#

Ye ye. I've been learning python for a week

cosmic agate
#

ok

#

go to replit

light echo
#

Wtf is that?

cosmic agate
#

its hosting service

light echo
#

oh wait

strong plover
#

haven't done a bot in a while, is someone willing to shoot in the DM's and help direct me in the right path for what functions to use for my purpose?

light echo
#

I gtg. So sry. Cya later

cosmic agate
#

np

#

if you want help hm me

maiden fable
supple thorn
maiden fable
#

replit is an online IDE which is used as a hosting service lmao

supple thorn
#

yeah

#

just self host

supple thorn
slate swan
supple thorn
slate swan
maiden fable
slate swan
#

alt accounts

maiden fable
#

Every month after 22 days, just tell people the bot is going down for maintenance for 8 days

slate swan
maiden fable
#

Ezzz

cosmic agate
vocal snow
cosmic agate
#

that is USED as a HOSTING SERVICE

maiden fable
vast gale
#

split it up among the month

maiden fable
cosmic agate
#

πŸ˜‚

vast gale
maiden fable
#

Ofc they do

vast gale
#

there's no way they don't, at this point

maiden fable
#

Yea

vast gale
#

but eventually some people turn into paying customers and so Yada Yada hunter can finish this sentence

maiden fable
#

I mean literally on every machine of theirs, discord bots are being hosted

cosmic agate
#

yeah

maiden fable
#

Tf does yada means lmao
I don't watch anime

cosmic agate
#

its a go to for basic bots

slate swan
cosmic agate
#

XD

maiden fable
#

πŸ˜” why both u and oki always eat popcorn

cosmic agate
slate swan
cosmic agate
maiden fable
#

Lmao

slate swan
cosmic agate
#

@slate swan is the audience

slate swan
#

yes, keep it up, you're funny a_pepe_popcorn

cosmic agate
#

thats why she eating popcorn

maiden fable
#

You taking this to an ot yourself or.... πŸ‘€

cosmic agate
#

??

maiden fable
unkempt canyonBOT
slate swan
maiden fable
#

Stop with it

cosmic agate
#

sure

alpine furnace
cosmic agate
#

XD

cosmic agate
#

omgthats why replit trash

#

good i switched

worldly bane
#

to?

cosmic agate
#

vscode

alpine furnace
cosmic agate
#

for begginers

worldly bane
cosmic agate
#

after 500 lines of code replit :

alpine furnace
#

For anyone that needs a test environment in any language

#

Fast

maiden fable
#

vscode.dev ftw!

cosmic agate
maiden fable
cosmic agate
#

oh thats new to me

slate swan
cosmic agate
#

wow

maiden fable
cosmic agate
slate swan
maiden fable
slate swan
cosmic agate
maiden fable
#

πŸ˜” I will just go away from here

slate swan
#

imagine being correct nowadays frog_sip

maiden fable
#

totally u

cosmic agate
#

hurt is past tense already

#

why make it more

maiden fable
#

Why not

slate swan
maiden fable
#

Anyways, I will just stop

cosmic agate
maiden fable
slate swan
#

!ruwule 7 kawaii

cosmic agate
#

nooooooooooooooooooo

slate swan
maiden fable
#

Can we please stop it?

cosmic agate
#

ok

maiden fable
#

Thanks

worldly bane
slate swan
maiden fable
#

anyways

slate swan
#

!ruwule 7 frog_sip

untold oriole
#

Does discord support timeout feature yet?

maiden fable
untold oriole
#

Yea like I dont want to just add a role to stop the user from messaging, instead if there was something else

torn sail
#

!d discord.Member.edit

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...
torn sail
#

Oh

#

Use timed_out_until kwarg with a date time object

untold oriole
#

let me try

maiden fable
#

When the new version releases, it will be there

untold oriole
#

wait what?

untold oriole
torn sail
untold oriole
torn sail
#

You need to be on v2

formal basin
#

Why is this not working (btw role id’s are in the the role_set

untold oriole
#

mmm how to check discord version within python?

torn sail
#

discord.__version__

untold oriole
#

discord.py==1.7.3

#

its a pip install ig

torn sail
#

You need to update to v2

#

pip install git+https://github.com/Rapptz/discord.py

untold oriole
#

Hmmm okay let me see

gaunt ice
untold oriole
#

Thanks guys!

gaunt ice
untold oriole
#

...is

gaunt ice
#

just a min

#

halp

#

pls

honest vessel
#

@gaunt ice change it

gaunt ice
#

im new to python

gaunt ice
honest vessel
#

if message.content in thawun_words:

gaunt ice
#

okk

#

i want so that if any word in the thawun_words is in message.content its fires up

slate swan
gaunt ice
#

um

unkempt canyonBOT
#
any

any(iterable)```
Return `True` if any element of the *iterable* is true. If the iterable is empty, return `False`. Equivalent to:

```py
def any(iterable):
    for element in iterable:
        if element:
            return True
    return False
gaunt ice
gaunt ice
#

or exactly opposite

maiden fable
#

Oh wait, it's a list, nvm

gaunt ice
#

yea

slate swan
gaunt ice
#

TYSM

#

lemme check it

#

IT WORKS @slate swan

slate swan
#

@maiden fable deleted your paragraph? sadcat

#

okay cool

jade tartan
#

Heyy can someone help me with something please?

oblique adder
#
@nextcord.slash_command(guild_ids=[9999999999999], description="Test command")
    async def my_slash_command(self, interaction: nextcord.Interaction):
        await interaction.response.send_message("This is a slash command in a cog!")```
if i put my guild_ids inside the [] will it work on other servers ? if not how do I make it work in all server ?
gaunt ice
jade tartan
#

Ok well if i want my bot to know the age of this user and have the age on the embed like

#

Kind of like this

slate swan
gaunt ice
#

hm

slate swan
#

and note that it may take upto 1 hour to register the slashes

jade tartan
#

Like i think i have to save the Age field privately in a db but am not too sure how

#

Am i right?

slate swan
jade tartan
#

Ok got any vids or docs to learn that? like how to do it

oblique adder
slate swan
jade tartan
#

Nope

#

not at all

maiden fable
slate swan
jade tartan
#

JSON

gaunt ice
slate swan
jade tartan
slate swan
#

yerlikaya peephappy

gaunt ice
gaunt ice
jade tartan
#

ohh ok sorry

oblique adder
gaunt ice
oblique adder
#

and it is not there yet

#

so i thought something was wrong

gaunt ice
oblique adder
maiden fable
jade tartan
gaunt ice
maiden fable
#

No

#

!pypi deta

unkempt canyonBOT
copper gulch
oblique adder
copper gulch
#

invite your bot with those scopes, just tell me if it works or not xd

oblique adder
#

and it still doesnt work

jade tartan
#

Do i need to use deta locally

#

?

slate swan
#

!pip deta

unkempt canyonBOT
slate swan
#

is the official wrapper

copper gulch
jade tartan
slate swan
#

oh yeah, that works too, forgot about that pfff

#

lemme see kek

copper gulch
slate swan
# jade tartan

wait, use postgresql, if that fits your purpose πŸ˜”

copper gulch
#

sqlite or aoisqlite could be good xd

slate swan
#

but they want a json-base

copper gulch
#

ohhhh mb

jade tartan
#

so maybe ill do that

#

Would i be able to delete my deta account?

maiden fable
#

πŸ‘€ @slate swan answer him

#

You seem to be well acquainted with deta

gaunt ice
#

how to make an hyperlink

#

like a blue word in discord whichwe can click to redirect to a website

manic wing
#

what is deta

small igloo
#

idk where to put this question but

def test(id):
    if id == 828182019841327115:
        xyz = True
    else:
        xyz = False
        
if test(828182019841327115):
    print("yes")
else:
    print("no")``` why output is "`no`
formal basin
#

Guys does this work?

maiden fable
slate swan
gaunt ice
slate swan
formal basin
maiden fable
jade tartan
#

How?

gaunt ice
#

manage_guld

#

lol

slate swan
#

then look at their docs

maiden fable
#

also for that make a slack account, right?

slate swan
maiden fable
#

And be sure to check yr Spam folder for the confirmation mail 🀣

slate swan
#

for some reason, it doesnt even show up in spams, its most probably in the all mails page

maiden fable
#

PoV: You were checking the wrong mail account

gaunt ice
#

this ting

cosmic agate
#

hi

maiden fable
slate swan
gaunt ice
#

hm

gaunt ice
slate swan
#

πŸ˜” hunter

maiden fable
#

!d discord.TextChannel.create_webhook

unkempt canyonBOT
#

await create_webhook(*, name, avatar=None, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates a webhook for this channel.

Requires [`manage_webhooks`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_webhooks "discord.Permissions.manage_webhooks") permissions.

Changed in version 1.1: Added the `reason` keyword-only parameter.
gaunt ice
#

hmm

maiden fable
#

Ayo I am chatting at 2 places and also preparing for tomorrow don't bully

slate swan
# gaunt ice TY

but you can only use them inside webhooks or embed descriptions and in values of embed fields

jade tartan
#

Ohh am i gonna need to save the data on deta drive?

maiden fable
#

eh?

buoyant quail
#

wth is xyz=

#

it does nothing here

copper gulch
buoyant quail
slate swan
maiden fable
#

!d str.replace

#

thought so

copper gulch
maiden fable
#

πŸ˜” we all are pros in spoonfeeding, not a new thing @copper gulch (bcc: @slate swan)

jade tartan
maiden fable
#

πŸ‘€ You both should take this to #databases ahem ahem

jade tartan
#

# initialize with a project key
deta = Deta("project key")

# create and use as many Drives as you want!
photos = deta.Drive("#")
photos.put("my_first_car.png", path="./my_first_car.png")
#

How do i get it to save the age of the user?

slate swan
jade tartan
#

Ok

maiden fable
#

πŸ‘€

jade tartan
#

Like what?

slate swan
#

Just use whatever you're comfortable with, ignore people that try to tell you what database to use.

#

pgsql, a remote MySQL Server

slate swan
slate swan
maiden fable
#

So every SQL db is relational or smth?

slate swan
#

SQL is designed for relational databases, so I would say yes

maiden fable
#

So NoSQL dbs are not relational? idk much about DBs

slate swan
#

yea , all the tables in a database can be relational