#discord-bots

1 messages · Page 1052 of 1

slate swan
#
@client.command()
async def gcreate(ctx, mins: int, *, prize):

  await ctx.send("Giveaway!")

  embed = discord.Embed(title="New Giveaway")
  embed.add_field(name = "Prize:", value = f"{prize}")
  end = datetime.utcnow() + datetime.timedelta(seconds=mins*60)
  embed.add_field(name = "Ends At", value = f"{end}UTC")
  embed.set_footer(text=f"1 Winner | Ends {mins} min(s) from now!")

  my_msg = await ctx.send(embed=embed)

  await my_msg.add_reaction(":tada_cyan:")

  await asyncio.sleep(mins*60)

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

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

  winner = random.choice(users)

  await ctx.send(f"{winner.mention}")

  embed2 = discord.Embed(title="Winner!", description=f"{winner.mention}")
  embed2.set_thumbnail(url=winner.avatar_url)
  embed2.add_field(name = "Prize", value=f"{prize}")
  embed2.set_footer(text="Giveaway Ended!")

  server = ctx.guild.name

  await ctx.send(embed = embed2)
  await winner.send(f"You Won a giveaway in {server} \n Prize: {prize}")

8th line

neat wasp
#

you've imported timedelta, so you can call timedelta directly, instead of datetime.timedelta

slate swan
#

Possible to remove the date and numbers after 05:14:49?

slate swan
neat wasp
#

you could control the formatting by replacing {end} with {end.strftime('%H:%M:%S')}

torn sail
slate swan
#

The error I sent

#

Not on command invoke

slate swan
slate swan
stray carbon
#
await cursor.execute('SELECT channel FROM fc WHERE guild = ?', (ctx.guild.id,))
                    data2 = await cursor.fetchone()
                    await cursor.execute('SELECT logchannel FROM fc WHERE guild = ?', (ctx.guild.id,))
                    data3 = await cursor.fetchone()
                    if data2 and data3:
                        if data2[0] != None:
                            await ctx.send(data2[0])
                            await ctx.send(data3[0])
                            if data3[0] != None:
                                await ctx.reply(f'Enabled freeloader mode for this guild.', mention_author=False)
                                await cursor.execute('INSERT INTO fc (status, guild) VALUES (?, ?)', ('on', ctx.guild.id,))
                            else:
                                await ctx.send('Please set a log channel and monitor channel before enabling freeloader mode.')
                        else:
                            await ctx.send('Please set a log channel and monitor channel before enabling freeloader mode.')
 
                    else:
                        await ctx.send('Please set a log channel and monitor channel before enabling freeloader mode.')

```no traceback and not sending anything
#

command is failing silently

slate swan
slate swan
#

They didn't explain it

hollow zealot
#

how do I make it so bots cant respond in a specific channel? I tried a lot of things. but nothing seems to work
Here is my code

if any(word in msg for word in Bannedword):
    if message.channel == "📝➤logs":
      return
    else:
      await message.delete()
      await message.author.send(f"<@{message.author.id}> hey watch your language! :Bonk:")```
hollow zealot
#

try*

slate swan
#
@client.command()
async def gcreate(ctx, mins: int, *, prize):

  await ctx.send("Giveaway!")

  end = datetime.utcnow() + timedelta(seconds=mins*60)
  embed = discord.Embed(title=f"{prize}", description=f"React With :tada_cyan: to enter \nEnds: <t:{end.timestamp():.0f}:R> \n Hosted By: {ctx.author.mention}", color = discord.Color.random())
  embed.set_footer(text=f"1 Winner | Ends {mins} min(s) from now!")

  my_msg = await ctx.send(embed=embed)

  reaction = await my_msg.add_reaction(":tada_cyan:")

  await asyncio.sleep(mins*60)

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

  users = [user async for user in reaction.users()]
  users.pop(users.index(client.user))

  winner = random.choice(users)

  await ctx.send(f"{winner.mention}")

  embed2 = discord.Embed(title="Winner!", description=f"{winner.mention}")
  embed2.set_thumbnail(url=winner.avatar_url)
  embed2.add_field(name = "Prize", value=f"{prize}")
  embed2.set_footer(text="Giveaway Ended!")

  server = ctx.guild.name

  await ctx.send(embed = embed2)
  await winner.send(f"You Won a giveaway in {server} \n Prize: {prize}")

error: AttributeError: 'NoneType' has no attribute 'users'\

hollow zealot
slate swan
#

Lines 209 in wrapped

#

But I do think it’s in 13th line

#

Aka where I’m trying to get one user out of the reactions

#

You can just use users.remove(client.user)

stone beacon
#

hennnce thhe nonnne tyype error

#

Keyboard is goig mad

#

wth

#

!d discord.Message.reactions

unkempt canyonBOT
stone beacon
#

is whaht yyou'd wat

slate swan
maiden fable
#

That is a big issue, but yea they have a reason for not telling the reason

slate swan
#

again, that will never work.

slate swan
slate swan
slate swan
#

I went to the docs
But there are events

#

For msg reaction

placid skiff
#

Why using events? Message object has a reactions parameter

#

!d discord.Message.reactions

unkempt canyonBOT
placid skiff
#

This will return a list of reaction object so after that doing some checks will be easy

slate swan
slate swan
placid skiff
#

... Bro it is a Message parameter, that means that you need a message object to use that D_D

robust fulcrum
#

Guys i am getting error anyone here know how to fix it

slate swan
#

average replit error

slate swan
placid skiff
slate swan
heavy folio
slate swan
#

Hi, I want to know how to press the button on the embed

#

How to make a check in a txt file?

slate swan
heavy folio
slate swan
heavy folio
#

In my bot's help command, is it possible for non positional args which have a None default to not display None
E.g. cmdname <arg1> [arg2=None] [arg3=abc]
I do not want None to be shown for arg2

slate swan
slate swan
heavy folio
unkempt canyonBOT
#
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`.
If the content is set to `None` (the default), then the `embed` parameter must
be provided...
slate swan
#

unless you're using something stupid like discord_components

heavy folio
slate swan
#

!d discord.Attachment.read

unkempt canyonBOT
#

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

Retrieves the content of this attachment as a [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "(in Python v3.10)") object.

New in version 1.1.
slate swan
#

what library are you using warden?

slate swan
slate swan
#

!d open

unkempt canyonBOT
#

open(file, mode='r', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None)```
Open *file* and return a corresponding [file object](https://docs.python.org/3/glossary.html#term-file-object). If the file cannot be opened, an [`OSError`](https://docs.python.org/3/library/exceptions.html#OSError "OSError") is raised. See [Reading and Writing Files](https://docs.python.org/3/tutorial/inputoutput.html#tut-files) for more examples of how to use this function.

*file* is a [path-like object](https://docs.python.org/3/glossary.html#term-path-like-object) giving the pathname (absolute or relative to the current working directory) of the file to be opened or an integer file descriptor of the file to be wrapped. (If a file descriptor is given, it is closed when the returned I/O object is closed unless *closefd* is set to `False`.)
slate swan
#
with open("filename") as file:
   content = file.read()
slate swan
#

content would be all the text inside that file

slate swan
heavy folio
#

Read the docs lol

slate swan
#

Lol

slate swan
heavy folio
loud junco
loud junco
#

=.= whats wrong with people's eyes nowadays

quaint epoch
loud junco
loud junco
quaint epoch
slate swan
#

Why my bot not check if there is an ID in a text file?

@bot.command(aliases = ["rtp"])
async def rtp(ctx):
    with open('id.txt', 'r+') as f:
        if ctx.author.id in f:
            await ctx.send("Already have")
            return
        else:
            f.write(f"{ctx.author.id}\n")
            f.close()
    await ctx.send("I coped your id")
loud junco
#

why aliases

slate swan
#

ctx.author.id returns an int while all the content in a file is a string

#

which fails the logic

#

I love js for this reason tbh

loud junco
#

it nvr tells where the error is

slate swan
slate swan
loud junco
slate swan
#

!e

test_val = 1
comp_val = "1"

print(test_val == comp_val)
unkempt canyonBOT
#

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

False
slate swan
#

^

placid skiff
#

yeah python is not javascript D_D

placid skiff
#

!e

val = 1
val2 = "1"
print(not(val == val2))
unkempt canyonBOT
#

@placid skiff :white_check_mark: Your eval job has completed with return code 0.

True
quaint epoch
loud junco
#

not() is trying to become john cena

placid skiff
#

Don't contradict me ash D_D

slate swan
#

!e

__ = 1
_ = 1
print(print(__ == _))
unkempt canyonBOT
#

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

001 | True
002 | None
slate swan
#

^

#

why did I have two prints....

placid skiff
#

LOL

#

btw i answered only to hydro cuz he said that I can't compare an int to a string if I want the output to be True

loud junco
#

why is my bot doing double output

#

💀

potent spear
#

because you most likely have 2 instances running

slate swan
#

or you used process_commands in a listener "maybe"

loud junco
#

btw

#

how do i stop running in shell

potent spear
#

ctrl +c

loud junco
#

ok

heavy shard
#

Ctrl + C

pliant gulch
unkempt canyonBOT
#

@pliant gulch :white_check_mark: Your eval job has completed with return code 0.

True
heavy shard
pliant gulch
#

Memory sorcery

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 Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, 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.

placid skiff
heavy shard
#

neat

pliant gulch
hollow zealot
#

how do you create an event the triggers when player join? i tried alot of things but nothing seems to work
my code

@client.event
async def on_member_join(member):
  await member.send('Private message')```
pliant gulch
#

Changing only the repr would require me to do all this extra bullshit to edit the dict of the class

#

Which is just a headache

slate swan
hollow zealot
hollow zealot
slate swan
#

yea, read what it says

hollow zealot
#

ok thks

hollow zealot
slate swan
#

yea~

hollow zealot
#

cause it creates error

slate swan
#

what error

hollow zealot
loud junco
#

is there switch case module?

loud junco
slate swan
#

you never imported discord

magic forge
#

huh there's this server k

hollow zealot
loud junco
#

how do u import it
show it

potent spear
loud junco
#

lol

hollow zealot
potent spear
hollow zealot
loud junco
heavy shard
hollow zealot
#

i have 2 discord var now

potent spear
loud junco
loud junco
#

remove the intents first
u wont be using it for now

magic forge
#

someone help a bit

hollow zealot
loud junco
magic forge
#
import discord
import os
import nextcord
import bot

client = discord.Client(intents=nextcord.Intents.all())


@bot.listen()
async def on_guild_join(guild):
    for x in guild.text_channels:
        print(x.name)
        if x.name == "general":
            await x.send('Hello! Thank you for inviting me to your server.')
            await x.send('It is an honor to meet you here.')
            await x.send('My name is Sakura.')
            await x.send('I am a bot used to run a game called Cardknights.')
            await x.send('My default prefix is s!')
            await x.send('Type s!help for more information!')


client.run(os.getenv('TOKEN'))
potent spear
#

any good IDE can autocomplete them

magic forge
#

But it does not work in the sense that it doesn't type anything.

loud junco
#

!eval
print('''
do
it
like
this
''')

unkempt canyonBOT
#

@loud junco :white_check_mark: Your eval job has completed with return code 0.

001 | 
002 | do
003 | it
004 | like
005 | this
loud junco
#

@magic forge

magic forge
#

?

slate swan
hollow zealot
#

i imported discord but she said add from discord.ext import commands or the bot idk /=/

loud junco
loud junco
#

spain without s

#

why is it invalid syntax

#

i have arg defined dont worry

#

!d match

unkempt canyonBOT
#

8.6. The match statement

New in version 3.10.

The match statement is used for pattern matching. Syntax:


match_stmt   ::=  'match' subject_expr ":" NEWLINE INDENT case_block+ DEDENT
subject_expr ::=  star_named_expression "," star_named_expressions?
                  | named_expression
case_block   ::=  'case' patterns [guard] ":" block
```...
loud junco
#

apa ni

slate swan
#

replit wont support it :p, it was added in 3.10

loud junco
#

oo

slate swan
#

replit uses 3.8.x

loud junco
#

so i cant use switch case?

slate swan
#

nope

loud junco
#

so i need to use if elif?

potent spear
loud junco
#

it has more than 30 elif there

potent spear
#

still pretty readable

loud junco
#

its going to take years to output

potent spear
#

unless it's like one value, then I'd use a dict

#

show me 2 cases/ elifs at least

magic forge
#

potent spear
slate swan
#

why do you have 30 if s and elif s though

loud junco
loud junco
potent spear
#

at least show us

loud junco
#

i have like 30+ recipes

potent spear
#

most likely, this can be shortened

loud junco
#

!paste alright

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
potent spear
#

bruh, you're in desperate need of a database

slate swan
#

^

loud junco
#

:/

#

u sponsor me vps then i use

#

😉

potent spear
#

has nothing to do with it

slate swan
#

how is that related to a vps

loud junco
#

its replit

slate swan
#

sqlite3 is a local db you can use

loud junco
#

just forget about it

slate swan
#

replit can save it too

potent spear
#

then how are you even currently hosting your bot?

#

don't suggest replit lol

loud junco
slate swan
#

or if you really want a free database, https://railway.app offers some free dbs

Railway

Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.

loud junco
#

alright thanks for that

potent spear
heavy shard
#

all your database are belong to us

potent spear
#

at least, for his use case

loud junco
#

which one do i choose

potent spear
#

in your case? postgres

slate swan
#

which one do you want to learn~

loud junco
#

im not in database
for me they are just

||microsoft excel but better||

slate swan
potent spear
#

you're a bit too much steps ahead
you don't even know SQL yet and here you are, trying to set up a db

loud junco
#

i know sql

potent spear
#

that's... good

slate swan
loud junco
#

the SELECT * FROM blah

magic forge
slate swan
potent spear
#

I'd just use aiosqlite or asyncpg (both are async wrappers of existing databases)

loud junco
#

so what do u suggest me

slate swan
#

indeed, as someone who just started with sql i'd use sqlite3/ aiosqlite

loud junco
#

i just want to call the variable name and it will come out
i dont want SELECT these SELECT that

potent spear
#

every db ever

loud junco
#

i legit found this

potent spear
#

try aiosqlite, then you won't have to fuck with connection online

loud junco
heavy shard
#

wrap your SELECT in function and forget about it

paper sluice
loud junco
#

so i dont need to make it online?

slate swan
# loud junco

thats for bot hosting, but it has an ephemeral file system

loud junco
slate swan
paper sluice
slate swan
#

let users remember that

loud junco
#

u can save data in data

loud junco
paper sluice
loud junco
#

if u save data in a data then its a data

loud junco
loud junco
#

so it will still work even though i have my pc closed right?

magic forge
#
import nextcord
from nextcord.ext import commands

bot = commands.Bot(command_prefix="s!",intents=nextcord.Intents.all())

@client.event
async def on_guild_join(guild):
  for x in guild.text_channels:
        print(x.name)
        if x.name == "general":
            await x.send('Hello! Thank you for inviting me to your server.')
            await x.send('It is an honor to meet you here.')
            await x.send('My name is Sakura.')
            await x.send('I am a bot used to run a game called Cardknights.')
            await x.send('My default prefix is s!')
            await x.send('Type s!help for more information!')


bot.run(os.getenv('TOKEN'))

Why does this not work?

loud junco
#

alright thanks thanks

slate swan
loud junco
potent spear
magic forge
loud junco
#

i told him lol

potent spear
#

just add new lines

slate swan
# loud junco

you dont need to create that db like that, its for online ones.

magic forge
#

…? i don't understand

slate swan
#

!pip aiosqlite pip install this first

unkempt canyonBOT
magic forge
#

kk

potent spear
# loud junco

just look at the documentation of aiosqlite, you're too dependent on whatever that stinky website is you're using

loud junco
#

ok

#

its called sql for asynco io?

potent spear
#

wdym?

slate swan
#

aiosqlite is the async bridge for sqlite yeah

loud junco
#

aiosqlite stands for sql for asynco io?

potent spear
#

nope

#

aio stand for async
sqlite is the db

placid skiff
#

it stands for asyncio sqlite D_D

loud junco
#

but i cant find it =.=

#

i mean in the search bar

#

is it just sql :/

potent spear
#

where tf are you even looking for the documentation?

loud junco
#

im looking at it
and doesnt understand anything written

potent spear
#

send me the link, let's check

slate swan
potent spear
loud junco
loud junco
slate swan
#

ofcourse, there is a single doc site.

loud junco
#

It replicates the standard sqlite3 module, but with async versions of all the standard connection and cursor methods, plus context managers for automatically closing connections and cursors:

#

what does this mean

#

its just sqlite3 but with extension?

potent spear
#

to not confuse you, yes

#

doesn't really matter what it is, all you have to know is that it's the database you'll want to use

#

so FIRST learn how to connect to it etc
OUTSIDE of your dpy project, since you don't want to restart your bot every half a second

loud junco
#

someone told me

#

is it true?

potent spear
#

what's the context?

loud junco
potent spear
#

ah, seems like replit is a shitty host then

loud junco
#

:/

#

so i cant use it?

potent spear
#

what other dbs does replit suggest / have?

loud junco
potent spear
#

I think isn't really what I'm looking for

loud junco
#

ok

digital mason
#

Hello everyone

loud junco
#

hi

digital mason
#

Are you looking to host your bot on repl.it if I'm not wrong

digital mason
#

Yes

loud junco
#

not at all 🤣

#

im trying to use a different db

digital mason
#

For a discord bot ?

loud junco
#

ya

#

in replit

digital mason
#

I use tinydb, json based database

#

Works perfectly for my needs

loud junco
#

its pretty bad tbh if ur bot grows

loud junco
digital mason
#

You know it too ?

#

TinyDb ?

loud junco
#

db[blah] = 123
u mean this?

heavy folio
#

replit db is like json 💀

raw oriole
#

hey

flint isle
#

Good morning... I'm needing help locating the hybrid command onside discord.py 2.0 so I can mod it to work inside disnake

slate swan
#

you mean the source of hybrid command implementation?

#

mixing it with disnake is a very wrong idea because it will mess up the internals of those 2 libraries.

flint isle
#

I'm wanting to work on attempting to assist in adding hybrid commands to disnakes library. I am trying to look how it works

pliant gulch
#

If you are even unable to find the hybrid commands location inside of discord.py's codebase, I highly recommend you practice a bit more before trying to contribute to disnake

flint isle
#

Well lol I'm trying to locate the 2.0 codebase.

pliant gulch
slate swan
#

you would have to rebase the complete disnake library if you want to use it.

flint isle
#

Thank you. I will look inside but who knows how far I'll get lol.

vocal plover
#

You'll probably also want to discuss with the maintainers of disnake about implementing stuff like that :P

unkempt canyonBOT
#

discord/ext/commands/hybrid.py lines 58 to 62

from discord.app_commands.commands import (
    Check as AppCommandCheck,
    AutocompleteCallback,
    ChoiceT,
)```
slate swan
#

its completely dependent over the discord.py's implementation

flint isle
#

Yeah I'll open a discussion in the disnake repo. Way more complicated than I thought lmao

#

I'm trying to think of a way to create a hybrid command manually. ¯\_(ツ)_/¯

cloud dawn
#

I think hybrid commands wasn't a really a good idea and they could've spend a lot of the time making it towards a better design of app_commands in general.

vocal plover
#

Personally, I feel that Disnake shouldn't have native hybrid commands, they're too restrictive and create a complex mess internally

pliant gulch
#

A better idea would be to have some sort of migration method imo

flint isle
slate swan
#

whats the point of "hybrid" commands when both app commands and prefix commands have different usage, a slash command is based upon an interaction whereas prefix commands use messages to function

pliant gulch
vocal plover
#

wouldnt really work

potent spear
#

tbh, I see no use in both prefix and slash
you should just migrate to slash

cloud dawn
potent spear
#

just add a notification that the bot migrated to slash commands...

cloud dawn
#

Danny even said to use message commands to sync the slash commands.

pliant gulch
vocal plover
# vocal plover wouldnt really work

You'd need to actually parse and understand the code (which is impossible for computers currently) since you'd need to follow the rules of interactions like replying within 3s

flint isle
pliant gulch
#

With the native commands extension you already do signature parsing

#

You just need to repeat that process during migration with some changes

vocal plover
#

How do you make {arbitrary user code} interaction compliant

cloud dawn
pliant gulch
#

Replace the context with some Interaction context that has the same methods, etc?

flint isle
pliant gulch
#

But they don't have all the same stuff so that is true

#

But if not for most, you could probably switch the names etc

cloud dawn
#

I think dpy should have either completely seperate slash and message commands or choose between the 2.

flint isle
#

Wait how do I set my bots about me

vocal plover
#

in the developer portal

cloud dawn
slate swan
flint isle
#

Omg thx lol thought there was an api command

robust fulcrum
cloud dawn
#

Neither of them are "ide's".

robust fulcrum
flint isle
robust fulcrum
#

I am on Android mobile

heavy folio
flint isle
#

Termux for terminal and I use pydroid3 as an "ide"

robust fulcrum
#

None of them can make our bot online like replit make for atleast 1 hour

flint isle
#

You need to get a vps...

cloud dawn
#

vps+ samsung DEX is literally like having a portable pc.

flint isle
robust fulcrum
#

But we need money for hosting

#

💰

cloud dawn
flint isle
#

Oh. Then I'll install it lol since I'm on samsung

#

Lmao forgot I did testing

robust fulcrum
slate swan
#

vps -> virtual private server

flint isle
robust fulcrum
#

But where do I host my bot
We need money 💰

flint isle
cloud dawn
#

You need a samsung 8 or higher tough.

flint isle
#

I have a Samsung a42 5g

robust fulcrum
#

@cloud dawn where do I host bot
We need money for hosting

cloud dawn
flint isle
#

Damn that sucks

robust fulcrum
#

Hmm do you pay money?

cloud dawn
cloud dawn
robust fulcrum
flint isle
cloud dawn
robust fulcrum
#

My parents don't allow me to use money on internet

flint isle
#

Oof

#

I'm king of my own bank accounts

cloud dawn
#

dex looking sleek

slate swan
#

used pip install discord.py in terminal when i use import discord it says MissingImport if i do pip install discord.py again it says requirement already satifsfyed

gloomy shale
gloomy shale
#

lol

slate swan
cloud dawn
#

What IDE you are using and where you inputting the command can help a lot.

slate swan
#

can I view discord channels with the help of it's id?

#

wdym by "view"

#

getting the channel object?

slate swan
slate swan
#

so I wanna make such bot such that it specifically send message to that channel

#

!d discord.Client.get_channel

unkempt canyonBOT
#

get_channel(id, /)```
Returns a channel or thread with the given ID.

Changed in version 2.0: `id` parameter is now positional-only.
slate swan
quaint epoch
slate swan
#

!e ```py
def function(arg, /):
pass

function(arg = 1)

unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 4, in <module>
003 | TypeError: function() got some positional-only arguments passed as keyword arguments: 'arg'
slate swan
#

like this ^

storm quail
#

Can someone help me with instabot?

slate swan
#

What is this supposed to mean?```py
Traceback (most recent call last):
File "/home/runner/Demajs/venv/lib/python3.8/site-packages/discord/cog.py", line 711, in _load_from_module_spec
spec.loader.exec_module(lib) # type: ignore
File "<frozen importlib._bootstrap_external>", line 843, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/runner/Demajs/cogs/staff.py", line 19, in <module>
class StaffCog(commands.Cog):
File "/home/runner/Demajs/cogs/staff.py", line 35, in StaffCog
async def apps(self, ctx, application: discord.Option(str, "Choose an application...", choices = get_options()), action: discord.Option(
File "/home/runner/Demajs/venv/lib/python3.8/site-packages/discord/commands/options.py", line 157, in init
self.choices: List[OptionChoice] = [
TypeError: 'coroutine' object is not iterable

slate swan
#
async def get_options():
        choices = []
        for i in db["applications"]:
            choices.append(discord.OptionChoice(i))
        return choices
slate swan
slate swan
flint isle
#

Umm how do I define arguments?

slate swan
maiden fable
flint isle
#

You two are on the same brain wavelength lol

slate swan
slate swan
flint isle
#

Oops I worded that poorly. I meant how do I put a description on an argument

slate swan
flint isle
#

Yes

slate swan
#

what library again?

flint isle
#

Disnake

slate swan
#

!d disnake.Option

unkempt canyonBOT
#

class disnake.Option```
Represents a slash command option.
flint isle
#

Umm how do i put that in the code lol

slate swan
#

no wait this is the old way ( it still works ), lemme find the new one

#

@flint isle you need to add docs to the command function

flint isle
#

Ok thanks

muted dagger
#

sarth is speedrunning these questions

slate swan
#

pithink yus

slate swan
#

But it’s still the same

slate swan
#

see what options show up there

#

Sarth ^

slate swan
#

Nope

#

Wait then how come it says requirement already satisfied

slate swan
slate swan
#

why the heck do people install python from windows store

slate swan
#

Is it possible that I can delete my whole python folder and install again

slate swan
slate swan
slate swan
slate swan
#

I downloaded from there lemme download again maybe I’ve installed 2 of em

#

that may be the issue

#

Yea just wait I’ll let you know when I’m done

slate swan
pure crypt
#

how can i make that the member whi use the command have to mention a different member?

slate swan
#

a command argument

pure crypt
#

yes but wich

slate swan
#

thats upto you~

regal pulsar
#

hello

slate swan
#

any command argument with discord.Member typehint works

#

hi anya

slate swan
slate swan
slate swan
regal pulsar
slate swan
maiden fable
#

It u manually delete the Python folder, u won't be able to reinstall Python via setup

quaint epoch
#

hehe, never did this with any other programs before

maiden fable
#

Well, I did this with VSCode and now I can't reinstall VSC via setup or update it

quaint epoch
#

i mean, i did have an antivirus "avg" installed on my computer, forgot the password to it, so i tried to delete the folder w/ python. i don't remember if it worked, but it was gone the next time i opened it

slate swan
#

see if its properly installed python -V in cmd prompt

#

Uh
How is python there in my search bar-

dull terrace
#

how do i stop discord giving me this error

#

happens with both my bots using different libraries

slate swan
# slate swan

did you click on add to path while installing python?

slate swan
#

its on the path the setup said

#

you need to do that

maiden fable
slate swan
maiden fable
#

Okay so I know how to fix it

slate swan
#

yes pls

maiden fable
#

Run the setup of that Python version and click on the Repair button

slate swan
#

done

#

its loading rn

dull terrace
slate swan
#

Olie, could you send the complete traceback>

dull terrace
#

that is the complete traceback?

#

that's why i have no idea what's causing it, doesn't point to any of my code

slate swan
slate swan
slate swan
dull terrace
#

that was the whole traceback

slate swan
#

never seen this error before, this might not be related to the library you are using

placid skiff
#

it's an aiohttps exception

slate swan
dull terrace
#

this is the traceback that happens on my other bot:

File "C:\Python\Python39\lib\site-packages\aiohttp\web_protocol.py", 
line 314, 
in data_received messages, 
upgraded, 
tail = self._request_parser.feed_data(data) File "aiohttp\_http_parser.pyx", 
line 546, 
in aiohttp._http_parser.HttpParser.feed_data aiohttp.http_exceptions.BadStatusLine: 400, 
message="Bad status line 'invalid HTTP method'"```
#

also 400

placid skiff
slate swan
#

no module named pip found

#

wonder how it thinks im importing pip

#

@slate swan ^

slate swan
slate swan
#

Heyy can someone help me with something?

slate swan
#

I write up the "bot.run('token')" and it's sending an error message

#

I googled this and it didn't said anything

heavy shard
#

you literally passed 'token'?

slate swan
#

I wrote my t0k3n from the bot and in the end, a friend of mine always writes "bot.run('token') so I did it as well

slate swan
#

oh yea you have it installed

#

now run that command

slate swan
#

even the time i installed it the terminal said "setuptools, pip"

slate swan
#

yes yes

#

ran that command?

#

yes

#

installing the script thingy

spring flax
#

for a modmail bot, how would I work on an edit command to edit the message sent by staff and edit the message for the user in DM's?

slate swan
#

says i dont have git

slate swan
#

check the image i snet

slate swan
#

sent*

#

python file?

#

then where?

sick birch
#

When you’re installing there’s a little check box that says “Add to Path” or something along those lines

slate swan
#

mmh wait

sick birch
#

If you’ve that checked it makes much easier

#

windows is a massive pain in the arse with this stuff

#

You can but again massive pain

#

Windows tries to hide that stuff from you for some reason

#

Gotta click through 20 prompts to get there

#

Windows calls them env variables, on Linux its path

slate swan
#

went through the setup didnt find "add to path": option

heavy shard
#

on Linux it's environment variable too, called PATH

sick birch
#

You’re sure? It’s on the bottom left

stray carbon
#

how to get guild in on_member_removed?

slate swan
#

on member leave

stray carbon
#

im using nextcord

sick birch
#

Ah yeah environment variables are more of a generic name

slate swan
slate swan
heavy shard
#

@slate swan can you run py in GIT cmd?

#

you could install using git clone and pip .

#
git clone https://github.com/Rapptz/discord.py
cd discord.py
py -m pip install -U .
slate swan
#

I do not

slate swan
#

Used the command in terminal

#

Still no errors

#

Lemme check the version

heavy shard
#

it should be installed now

slate swan
#

Yup it is

heavy shard
#

\o/

slate swan
#

But why is import discord saying missing imports

slate swan
heavy shard
#

git is not on the system PATH

slate swan
#

huh

slate swan
vocal snow
slate swan
slate swan
heavy shard
#

it was used in "Git CMD" which opens terminal in git directory

slate swan
slate swan
#

I see

#

does it install the lib successfully?

#

Yup python library is installed

sick birch
#

this is a certified windows classic

slate swan
sick birch
#

It’s be worth actually checking your path to see if gits on there

slate swan
robust fulcrum
#

Can anyone tell me a good ide for coding a discord bot in python pls

sick birch
#

Don’t ask me… don’t use windows

#

be warned it’s a bit hard to find

heady sluice
#

you're wrong for that

sick birch
#

A quick google would get you to the right place

robust fulcrum
#

Can anyone tell me a good ide for coding a discord bot in python pls

heady sluice
#

??

robust fulcrum
#

I need a good ide for Android

sick birch
#

There is no “good IDE” it’s personal preference

heady sluice
#

oh android

sick birch
#

oh android

heady sluice
#

lol

sick birch
#

crap

robust fulcrum
#

Cause windows have good ones

slate swan
robust fulcrum
#

Like vs code

sick birch
#

Don’t know if android supports ides? I would guess it does

heady sluice
#

replit

robust fulcrum
#

Pydroud is bad

slate swan
#

droud

robust fulcrum
#

Replit is dead

#

It's like lagging

heady sluice
#

replit is an S tier host

slate swan
#

then why use a mobile phone......

sick birch
#

Getting a laptop of desktop is going to serve you well in the long run

slate swan
#

replit is good, just not good for hosting (good for hosting static websites [html, css])

robust fulcrum
#

But for now i need for mobile

slate swan
#

why does nobody use iOS 😔

robust fulcrum
#

I have ipad

sick birch
#

iOS or IOS

#

Because there is a difference

heady sluice
#

you mean apple?

robust fulcrum
#

Ye

sick birch
#

IOS is Cisco’s operating system for their routers and switches

slate swan
#

dunno, never heard of that

slate swan
heady sluice
regal pulsar
heady sluice
heady sluice
maiden fable
regal pulsar
maiden fable
regal pulsar
#

visual studio code is just a text editor

regal pulsar
heady sluice
regal pulsar
#

hmm

slate swan
maiden fable
slate swan
#

the people who developed it.

#

hm yeah

regal pulsar
heady sluice
slate swan
#

text editor or what?

slate swan
#

read the 1st paragraph

sick birch
#

Vscode has always been on the fence about being an IDE vs an editor

maiden fable
heady sluice
#

but it may also be built into an integrated development environment

slate swan
#

calling vscode an IDE is same as "replit is the best host"

heady sluice
#

no

maiden fable
regal pulsar
slate swan
#

yasss, lessgo

regal pulsar
#

;/

heady sluice
#

slay

slate swan
#

exactly.

heady sluice
slate swan
#

its just way more feature-rich to be referred as an editor, thats it.

slate swan
#

idm whatever you want to call it, not something i developed.

sick birch
#

Is it really worth arguing over what you call it

slate swan
#

^

sick birch
#

It’s a tool to help you get something done regardless of what you call it

heavy shard
#

lets not put labels on poor VSC

regal pulsar
#

im not going to call a screwdriver an ide

slate swan
#

um if you really wanna discuss move to #editors-ides . this is not the place

#

Btw how can I run my bot 24/7 on vsc?*

regal pulsar
slate swan
#

Ignore my damn autocorrect

sick birch
#

I don’t care if you call a screwdriver an IDE as long as you fix my car and be on your way

regal pulsar
#

or a personal server

slate swan
slate swan
sick birch
#

it’s about what you do with it

heady sluice
#

there's a thread for host subject

regal pulsar
sick birch
regal pulsar
#

or buy hosting

regal pulsar
slate swan
sick birch
#

A CC is almost a necessity

slate swan
#

um "on vsc"

sick birch
#

Ah

#

In that case you have no choice but to leave your computer on 24/7

lime vector
# sick birch On a VPS

In this video I showed you guys how to code and host a Discord bot on a PetroSky VPS, please show me suppoet by the given links below and don't forget to like, subscribe and share this video took a lot of time to put together.

CONNECT WITH ME:
➥ Website [💻]: https://mustafaxd.ml
➥ Twitter [🐦]: https://twitter.com/Mustafa10341531
➥ Discord [💬]: ...

▶ Play video
sick birch
#

I mean it’s really not all that complex to need a full video on it

lime vector
#

its a 2 mins video dude

#

it just tells which vps to buy and how to code and host a discord bot on that vps

#

In this video I showed you guys how to get rid of this annoying error which comes in Pycord so make sure to watch the video till the end and don't forget to like, subscribe and share!

CONNECT WITH ME:
➥ Website [💻]: https://mustafaxd.ml
➥ Twitter [🐦]: https://twitter.com/Mustafa10341531
➥ Discord [💬]: https://discord.gg/BgjvDWkmmy

SUPPORT ME:
...

▶ Play video
sick birch
#

hmmm not a big fan of these tutorials

lime vector
#

i know how much rage this error causes

slate swan
#

just dont use pycord~

lime vector
#

when there is no exact answer

lime vector
slate swan
#

discord.Bot is a thing only in pycord, for others its commands.Bot

lime vector
sick birch
slate swan
slate swan
#

!d discord.ext.commands.Bot all forks and og dpy has it already

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") and as a result
anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") you can do with
this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality
to manage commands...
lime vector
slate swan
#

still, useless.

sick birch
#

It is a breaking change but a quick question here solves it for most people

#

Or reading the documentation

slate swan
heady sluice
#

or not having both dpy and pycord installed

sick birch
#

Do you need both?

placid skiff
#

i laugh a bit

sick birch
#

Pycord is kind of funky

lime vector
heady sluice
placid skiff
#

all those people now have to change all their client bot istance

sick birch
#

Yeah with their weird name spacing

lime vector
slate swan
# placid skiff i laugh a bit

yea, what they did is ,
discord.Bot is a subclass of discord.Client
and then they re-subclass commands.Bot from discord.Bot

lime vector
#

that solution is already mentioned in 100 of stackoverflow answers

#

but do no works out for everyon

heady sluice
#

but why do you need stackoverflow for this

#

isn't it logical

sick birch
#

Probably the worst source for discord bots

#

Actually nvm that’s probably YouTube tutorials

#

Stackoverflow is a runner up

heady sluice
sick birch
#

Yeah since discord bot libraries change really fast

slate swan
#

yep

heady sluice
#

vcoklftre

sick birch
#

What do you mean?

#

Like a website for our bots?

heady sluice
#

a person

#

got like 24

sick birch
#

Ah yeah I have one of those

sick birch
#

They thought you meant a bot tutorial

heady sluice
#

oh bot dashboard

half gale
#

Why am I getting discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions when trying to add roles to a member even though the bot has admin perms?

sick birch
#

But yeah, I have a web dashboard to manage my bot

#

Though I wrote mine using Next.js

slate swan
sick birch
#

If it’s static content use flask

half gale
sick birch
#

It’s not public yet, I’m still working on it

#

Currently working on the part where you can manage infractions for users :)

#

It interacts with the backend using Prisma

slate swan
#

is that a moderation kind of bot Robin? O.o

sick birch
#

Nah just general purpose

#

Don’t have a domain and it’s not hosted unfortunately

#

Soon hopefully!

#

It’s been a fantastic learning opportunity

#

what do you mean?

placid skiff
#

he told to you that it is not hosted xD

heady sluice
#

how

placid skiff
#

bruh to share it to you he should share the whole project D_D

slate swan
#

he cant share it to someone remotely without sharing the complete src

sick birch
#

It is open source iirc

slate swan
#

😂 iirc

sick birch
#

You’ll find it on my GitHub page

#

Somewhere…. lost in my hundreds of random repos

placid skiff
#

lol

slate swan
#

t bot dash?

sick birch
#

Yeah I believe that’s it

#

Hopefully it can be used as a learning opportunity

#

I try my best to follow best practices :)

solar pelican
#

Help me RuntimeError('Event loop is closed') RuntimeError: Event loop is closed My code ```#Импорт

import discord
from discord.ext import commands
from config import settings

#Настройки

bot = commands.Bot(command_prefix = settings["prefix"])

#Запуск

@bot.event
async def on_ready():
print("NERV")

#Запуск
bot.run(settings["token"])```

sick birch
#

I still have a lot of changes I haven’t committed lmao

sick birch
#

Usually that error happens because your token is invalid

#

Can’t be sure without seeing the full traceback though

solar pelican
sick birch
#

“Improper token has been passed”

solar pelican
#

thanks

#

💗

slate swan
#

it's funny how after a while your brain just filters out exceptions lol

scarlet sorrel
#

how would i write a simple thing to print out all the guilds the bot is in? does not have to be command

rare saddle
#

Please tell me how to fix the error?

scarlet sorrel
sick birch
#

!d discord.Client.guilds

unkempt canyonBOT
scarlet sorrel
slate swan
#

Missing access

rare saddle
#

For some reason, the bot cannot redefine the channel for the user

slate swan
#

um

sick birch
#

Make sure you invited the bot with the right permissions

scarlet sorrel
rare saddle
slate swan
#

Ye

#

Missing access error happens when bot cannot get anything but it exists

rare saddle
slate swan
lyric apex
#

Hello

#

How to fix this

slate swan
#

ro is None

lyric apex
#

It isn't i saw in the db

slate swan
#

its the error saying that, not me

#

!e None[0] # ur error

unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 | <string>:1: SyntaxWarning: 'NoneType' object is not subscriptable; perhaps you missed a comma?
002 | Traceback (most recent call last):
003 |   File "<string>", line 1, in <module>
004 | TypeError: 'NoneType' object is not subscriptable
slate swan
#

Possible to run a bot on a laptop/pc when it’s off? Without vps

slate swan
#

nope~

#

Sad

lyric apex
slate swan
#

dk, cant assume without seeing your code

#

you make the value literal to something scriptable

lyric apex
#

This Is My Event

lyric apex
rare saddle
#

How to make the bot add itself to the category rights?

slate swan
#

!d sqlite3.Cursor.fetchone

unkempt canyonBOT
#

fetchone()```
Fetches the next row of a query result set, returning a single sequence, or [`None`](https://docs.python.org/3/library/constants.html#None "None") when no more data is available.
slate swan
#

ro may be None

lyric apex
slate swan
#

gg

keen mural
#

How would i create a cmd that lists everyone who has a role

sick birch
unkempt canyonBOT
keen mural
#

Or does it say it there

sick birch
#

Just loop through

keen mural
placid skiff
#

bruh

#

!e

my_list=[1,2,3,4,5,]
for _ in my_list:
  print(_)
unkempt canyonBOT
#

@placid skiff :white_check_mark: Your eval job has completed with return code 0.

001 | 1
002 | 2
003 | 3
004 | 4
005 | 5
scarlet sorrel
#

how do you see the content of a message the current message is replying to?

placid skiff
#

uh duh?

sick birch
scarlet sorrel
#

no i mean message.content or whatever

#

i have the object

sick birch
#

Which object?

scarlet sorrel
#

message

sick birch
#

then use message.content? Unless I’m misunderstanding

scarlet sorrel
#

no i want to see the content of the message the current message is replying to

placid skiff
#

!d discord.Message.reference I think he is looking for this

unkempt canyonBOT
#

The message that this message references. This is only applicable to messages of
type MessageType.pins_add, crossposted messages created by a
followed channel integration, or message replies.

New in version 1.5.

sick birch
#

That

#

But still, redundant

#

To reply to a message in the first place you already have the original message object

scarlet sorrel
#

im not trying to reply to a message

#

i have the message

sick birch
#

How did you get the message?

scarlet sorrel
#

bruh

sick birch
#

Returned from .reply()?

scarlet sorrel
#

no

#

@client.event async def on_message(message):

sick birch
#

I see

#

So someone else’s message reply

scarlet sorrel
#

yes

#

aka the current message

sick birch
#

That makes more sense. I thought you wanted to get the reply to a message your bot sent

#

My bad then, use .reference

scarlet sorrel
#

cool

#

.refernce.content ?

placid skiff
#

i was right so xD

sick birch
#

Yes

scarlet sorrel
placid skiff
#

Nope, message.reference is a MessageReference object

#

!d discord.MessageReference

sick birch
#

Ah

unkempt canyonBOT
#

class discord.MessageReference(*, message_id, channel_id, guild_id=None, fail_if_not_exists=True)```
Represents a reference to a [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message").

New in version 1.5.

Changed in version 1.6: This class can now be constructed by users.
sick birch
#

Thought it’d return a message

scarlet sorrel
#

so i cant get content?

placid skiff
#

yup but you will have to get the message from the id

scarlet sorrel
#

how do i do that

sick birch
#

you can try message.reference.resolved.content

placid skiff
#

yup that would do

sick birch
#

But it could just as well fail

placid skiff
#

nope i used that once lol

#

Things comes back slowly

scarlet sorrel
#

hahaha

#

same

#

but mostly they never come back for me

placid skiff
#

well i used that to get the member of a message from a reference but since as reference.resolved returns a message object you will be able to get the content

#

!d discord.MessageReference.resolved

unkempt canyonBOT
#

The message that this reference resolved to. If this is None
then the original message was not fetched either due to the Discord API
not attempting to resolve it or it not being available at the time of creation.
If the message was resolved at a prior point but has since been deleted then
this will be of type DeletedReferencedMessage.

Currently, this is mainly the replied to message when a user replies to a message...

karmic axle
#

Is there a list of features for the discord python bot regarding moderation and user management? Some kind of overview? I feel a little overwhelmed by so many features.

potent spear
noble kestrel
#

When creating an application, If I don't "add bot" would my application be invisible so it doesn't show as a user?

hexed pagoda
#

hello, i am new to python and discord bots, im currently tryig to build a basic bot that has reply,blockwords and music...
however i installed ffmpeg, i store the exe file in local C:\ffmpeg and i added it to my path
(i could show my whole code if its needed, it is not that long yet..bc i dont find the problem in it)
the error i got is : "local variable 'voice_client' referenced before assignment"
so i assume i skipped smt ?! perhabs 😫

slate swan
#

!e

def a():
    print(a)
    a = 1
a()
unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 4, in <module>
003 |   File "<string>", line 2, in a
004 | UnboundLocalError: local variable 'a' referenced before assignment
slate swan
#

see how its referenced before its assignment hence making it undefined

hexed pagoda
#

yep i can understand your example , i just dont see where and what should i put in in my problem :c

slate swan
#

you define it before it would be referenced?

potent spear
karmic axle
hexed pagoda
#

yes i rather show smt cus i really dont see it 😄

potent spear
slate swan
#

basic moderation endpoints are timeout, ban, unban and kick

#

if thats what youre looking for

hexed pagoda
#

so before the line 48 i didnt type any voice_client

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.

potent spear
#

don't use screenshots

hexed pagoda
#

@client.event
async def on_message(msg):
if msg.content.startswith("?play"):

try:
  voice_client = await msg.author.voice.channel.connect()
  voice_client[voice_client.guild.id] = voice_client 
  
except:
  print("error")     


try:
  url = msg.content.split()[1]

  loop = asyncio.get_event_loop()
  data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=False))

  song = data['url']
  player = discord.FFmpegPCMAudio(song, **ffmpeg_options)

  voice_client[msg.guild.id].play(player)
  
except Exception as err:
  print(err)
potent spear
#

so we'll need to see 2 things in your shared link
the code and the error traceback

#

alright, so the main "problem" here is that you're using the on_message event as some kind of command system
you should check out what commands are in the docs

hexed pagoda
#

🧐 the bot has ?play command and if user past the command and after the url it shows on the channel but the bot doesnt plays it
you mean its only bc i use on_message?

potent spear
#

you should check out how commands work, Alex

#

your implementation isn't optimal

#

doing what you're doing would result in a HUGE on_message function whenever you're adding a command

#

I really hope you're not learning discord py from a YT tutorial

formal basin
#

This isn’t working

lavish zephyr
#

Hello guys, how do i pass a parameter in this code? py if msg.content.startswith("*test <randomNumber>"): for x in <randomNumber>: doSomething

potent spear
hexed pagoda
formal basin