#discord-bots

1 messages Β· Page 654 of 1

velvet tinsel
#

IPAYFORWINRAR

#

❀️

vernal zealot
#

Help translate the command

velvet tinsel
#

Wtf

boreal ravine
#

omg krypton

slate swan
boreal ravine
#

why do you have emojis

#

about yourself pithink

velvet tinsel
#

I MISS YOU

slate swan
#

mm k

#

Pretty much off-topic isn't it?

velvet tinsel
#

Goddamnyou winrar if you say !ot

boreal ravine
#

!ot

unkempt canyonBOT
boreal ravine
#

bruh

#

πŸ˜” ✊

velvet tinsel
#

πŸ”ͺ

#

anyways

#

how are you Kayle

slate swan
#

!ot

unkempt canyonBOT
velvet tinsel
#

screw you

#

someone ask a goddamn question

#

it's not that hard

sullen shoal
#

how to make a discord bot

velvet tinsel
#

wait
Myxi why are you asking that question

sullen shoal
#

can you link a tutorial

slate swan
#

Wonder why πŸ˜‚

velvet tinsel
#

The official video for β€œNever Gonna Give You Up” by Rick Astley

β€œNever Gonna Give You Up” was a global smash on its release in July 1987, topping the charts in 25 countries including Rick’s native UK and the US Billboard Hot 100. It also won the Brit Award for Best single in 1988. Stock Aitken and Waterman wrote and produced the track which w...

β–Ά Play video
#

this one

sullen shoal
#

thanks

velvet tinsel
#

thankd 😭

boreal ravine
velvet tinsel
unkempt canyonBOT
boreal ravine
#

i-

slate swan
#

soo i am trying to make a function which sends random 1 image out of 140 since github only accepts 100 i add 100 image in 1 folder and 40 in 2nd so i made dis but its only sending image from folder 1 not 2nd

number = random.randint(1, 99)
    wow = random.randint(100, 140)

    f = discord.File("./vote_rewards/reward "+ str(number)+".jpeg", filename="vote_rewards.jpeg", spoiler=False)
    g = discord.File("./vote_rewards2/reward "+ str(wow)+".jpeg", filename="vote_rewards2.jpeg", spoiler=False)
    embed = discord.Embed(title="Konichiwa Goushinjin-sama", description="**Arigcato Gosaimushta For Voting, Here Is Your Reward**", color=0xcf24ff)
    embed.set_image(url="attachment://vote_rewards.jpeg" or "attachment://vote_rewards2.jpeg")
    choices = (f,g)
    random.choice(choices)
    user = await bot.fetch_user(message.content)
    print(f.fp)
    await user.send(file=f, embed=embed)
velvet tinsel
#

FINALLY

#

goodbye

slate swan
upbeat otter
slate swan
#

If there is it'll return a Member | User object

slate swan
upbeat otter
slate swan
#

I didn't say anything wrong

#

Also changing it from a tuple to a list won't do anything

#

They're both iterables

#

How do I check a member's role with the bot? (ping me)

maiden fable
#

!d discord.Member.roles ?

unkempt canyonBOT
#

property roles: List[Role]```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [β€˜@everyone](mailto:'%40everyone)’ role.

These roles are sorted by their position in the role hierarchy.
slate swan
#

It will show everyrole

#

I want to show the main role

#

that they have

#

for example
?role @slate swan it should show Owner

maiden fable
#

!d discord.Member.top_role

unkempt canyonBOT
#

property top_role: Role```
Returns the member’s highest role.

This is useful for figuring where a member stands in the role hierarchy chain.
maiden fable
#

This?

slate swan
#

Yes

maiden fable
#

Ah cool!

slate swan
#

urgh

maiden fable
#

!d discord.Member.top_role *

unkempt canyonBOT
#

property top_role: Role```
Returns the member’s highest role.

This is useful for figuring where a member stands in the role hierarchy chain.
slate swan
#

@maiden fable <property object at 0x0000026DD31FCA40>

#

I get that

hidden stump
#

hey im trying to use sqlite and i think something doesnt work. The bot tells me the table im trying to open doesnt exist

slate swan
#

nvm nvm, it works

velvet tinsel
hidden stump
#

like is there any line of code that can check if anythings on there or something

maiden fable
#

Do u have SQLite DB Browser?

hidden stump
#

yeh

maiden fable
#

Try using that

hidden stump
#

yeah i mean theres a table but the bot doesnt see it for some reason

#

yeah i even deleted the DB and made it again and still doesnt see it, am I connecting to the wrong db or what

maiden fable
hidden stump
#

im dumb what is a query

maiden fable
#

The SQL string

#

SELECT * FROM DB WHERE

hidden stump
#

my brain lagged

#

that would show the tables right?

#

wait no thats the

#

okay step by step tell me what to do lmao

maiden fable
#

Haha it's fine

#

Okay so, u do something like c.execute, right?

hidden stump
#

yes

maiden fable
#

So the string inside it

hidden stump
maiden fable
#

Which resembles this SELECT * FROM DB

#

Yea

#

That's a query

hidden stump
#

okay cool

maiden fable
#

And rocks is the DB Name?

hidden stump
#

table?

maiden fable
#

Be sure since names are case sensitive iirc

maiden fable
slate swan
#

it had to

maiden fable
#

But since it's just author id, I don't think there's a problem, is it?

slate swan
#

yes

maiden fable
#

???

slate swan
#

it's not about what's in the variable

maiden fable
#

Then?

hidden stump
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: OperationalError: no such table: rocks well idk bro

slate swan
#

noidea

maiden fable
slate swan
hidden stump
#

yes its all lowercase

maiden fable
#

Can ya show me in the SQLite Browser?

slate swan
hidden stump
#

wait a sec

slate swan
#

Can someone help I’m tryna make bot and is {member.guild} ok? And it’s not working

slate swan
#

Ok

#

@bot.command(aliases = ['is {member} ok?'])
async def ball(ctx): #can't really put numbers in the command name so we have 8ball as an alias instead
import random
ballresponses = ['Yes', 'No']
z = random.choice(ballresponses) #choose yes or no, randomly

hidden stump
#

okay now like everything broke lmao

lament mesa
slate swan
#

{guild.member}?

slate swan
lament mesa
hidden stump
lament mesa
slate swan
#

Ok

hidden stump
#
db = sqlite3.connect("main.sqlite")
    cur = db.cursor()
    cur.execute("""
    CREATE TABLE IF NOT EXISTS rocks(
    user_id TEXT,
    mined INT
    """)
    db.commit()``` I get like incomplete input error lol
#

in the cur.execute

#

also its discord made it like this its all in one line

slate swan
hidden stump
#

oooohhhh

slate swan
#

and to create a table IF NOT EXSIST isnt needed

hidden stump
#

i create it when the bot starts

#

so i dont want to crate a lot of them

slate swan
#

just

c.execute("""CREATE TABLE wala( 
          hm text
          """))
db.commit()```
slate swan
#

okay so whats the next problem?

paper sierra
#

Can someone in pm help me with fixing music bot so it plays soundcloud links?

hidden stump
#

oh also the DB is being created in the wrong folder

#

i expect it to create in the folder with the bot, it creates in the folder where the bot folder is

hidden stump
#

i have a python folder, and in the folder i have the bot folder

slate swan
#

the file will be created where the code file it

hidden stump
#

when i run the bot

#

it creates in the python folder

slate swan
slate swan
hidden stump
#

the whole bot is in the folder

slate swan
hidden stump
#

in the bot folder, and its in the python folder

slate swan
hidden stump
#

isnt it gonna create a new one

slate swan
hidden stump
#

let me say it as simple as I can

boreal ravine
#

!d disnake.ext.commands.Bot.user_command

unkempt canyonBOT
#

@user_command(*args, **kwargs)```
A shortcut decorator that invokes [`user_command()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.user_command "disnake.ext.commands.user_command") and adds it to the internal command list.
hidden stump
#

I have a python folder with python stuff in it
I have a bot folder where im currently working, the bot folder is inside of the python folder

when i run the .py file that is inside of the BOT folder, the DB is made in the python folder

slate swan
#

of the folders and the codes near the CREATE TABLE

dusk dust
#

how can I write lines on json file using dpy?

slate swan
hidden stump
#

MiningRPG is the bot folder, main.sqlite on the bottom is the DB made in the wrong folder

dusk dust
spark kite
#

My bot is sending 10 links to the 10 images it was supposed to send but only 5 of them are embedded. Is this because it's a bot account or is there something I need to code?

slate swan
#
with open("hm.json" "r") as f: 
  f.dump(variable)```
hidden stump
slate swan
slate swan
#

first make the read code also

obsidian ledge
#

can someone help me w/ this

boreal ravine
#

!indets

unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

spark kite
#

My bot is sending 10 links to the 10 images it was supposed to send but only 5 of them are embedded. Is this because it's a bot account or is there something I need to code?

boreal ravine
slate swan
dusk dust
slate swan
#

How to change pages instead of reply on buttons click

hidden stump
#

whatt

slate swan
slate swan
#

Change pages when buttons click not reply

#

by default sqlite makes the database in the path where the script is
so check the codes there must be a code where its defined a file path

boreal ravine
slate swan
#

if its not than make a file path in the script itself

slate swan
slate swan
boreal ravine
slate swan
boreal ravine
slate swan
slate swan
#

there is a discord server for the buttons

slate swan
boreal ravine
slate swan
#

if you want they have a channel with recent questions you might find there

slate swan
boreal ravine
#

bruh, no misleading

slate swan
#
import discord
from discord.ext import commands
from discord_buttons_plugin import *
import os

client = commands.Bot(command_prefix=commands.when_mentioned_or(">"))
buttons = ButtonsClient(client)

@client.event
async def on_ready():
	print(f"Logged in as {client.user.name}")

@client.command()
async def invite(ctx):
	embed = discord.Embed(title=f"Invite {client.user.name}", color=0xff0000, description=f"Wanna invite {client.user.name}, then [click here](https://discord.com/api/oauth2/authorize?client_id={client.user.id}&permissions=8&scope=bot)")
	await buttons.send(
		content = None,
		embed = embed,
		channel = ctx.channel.id,
		components = [
			ActionRow([
				Button(
					style = ButtonType().Link,
					label = "Invite",
					url = f"https://discord.com/api/oauth2/authorize?client_id={client.user.id}&permissions=8&scope=bot"
				)
			])
		]
	)


@buttons.click
async def hibutton(ctx):
	await ctx.reply(f"Hi {ctx.member.name}")

@buttons.click
async def clickbutton(ctx):
	await ctx.reply(f"{ctx.member.name} has clicked the button.")

@buttons.click
async def danger(ctx):
	await ctx.reply(f"{ctx.member}, told'ya not to click!")

@buttons.click
async def lol(ctx):
	await ctx.reply("lol")

@client.command()
async def hi(ctx):
	await buttons.send(
		content="Hey there",
		channel = ctx.channel.id,
		components = [
			ActionRow([
				Button(

					style = ButtonType().Primary,
					label = "Hi",
					custom_id = "hibutton",

				),

				Button(
					style = ButtonType().Success,
					label = "Click",
					custom_id = "clickbutton"

				),
				Button(
					style = ButtonType().Danger,
					label = "Don't click",
					custom_id = "danger",
				),
				Button(
					style = ButtonType().Secondary,
					label = "Hello",
					custom_id = "lol",
				)
			])
		]
	)

client.run(os.getenv("token"))
#

@slate swan give linj

slate swan
boreal ravine
spark kite
slate swan
slate swan
spark kite
boreal ravine
spark kite
#

this is the code where it sends

slate swan
boreal ravine
boreal ravine
spark kite
#

my bot sends everything but the last 5 links just dont embed

boreal ravine
#

!d discord.ui.Button <= yes man

unkempt canyonBOT
#

class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.

New in version 2.0.
slate swan
#

since dpy wasnt having buttons people made discord_components the creator of buttons himself said

boreal ravine
#

in the master branch aka 2.0

slate swan
#

i just used discord_components

quaint epoch
#

guys i have a a question

slate swan
quaint epoch
#

do Member objects have a Member.is_bot attribute?

hidden stump
quaint epoch
#

to check if the member is a bot

boreal ravine
slate swan
boreal ravine
#

!d discord.Member.bot <= returns a bool

unkempt canyonBOT
#

property bot```
Equivalent to [`User.bot`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.bot "discord.User.bot")
quaint epoch
#

so i could just use discord.Member.is_bot?

slate swan
boreal ravine
slate swan
slate swan
boreal ravine
slate swan
quaint epoch
#

does discord.Guild.get_member_named return a Member object?

boreal ravine
boreal ravine
slate swan
hidden stump
#

oh wait so i use db = sqlite3.connect("path/to/db.sqlite") ?

boreal ravine
quaint epoch
boreal ravine
boreal ravine
#

!d discord.Guild.get_member_named

unkempt canyonBOT
#

get_member_named(name, /)```
Returns the first member found that matches the name provided.

The name can have an optional discriminator argument, e.g. β€œJake#0001” or β€œJake” will both do the lookup. However the former will give a more precise result. Note that the discriminator must have all 4 digits for this to work.

If a nickname is passed, then it is looked up via the nickname. Note however, that a nickname + discriminator combo will not lookup the nickname but rather the username + discriminator combo due to nickname + discriminator not being unique.

If no member is found, `None` is returned.
boreal ravine
#

oh my bad then

hidden stump
#

will ./db.sqlite do the job?

boreal ravine
hidden stump
#

cuz its in the current folder

slate swan
boreal ravine
slate swan
#

Ok

slate swan
#

idk cuz usually it makes db in the script folder by default your scenario is diff

proven osprey
#

what i should do if i want to have buttons in one row?

hidden stump
#

it doesnt work

slate swan
spark kite
#

My bot is sending 10 links to the 10 images it was supposed to send but only 5 of them are embedded. Is this because it's a bot account or is there something I need to code?

hidden stump
#

whyy doesnt it woooork

spark kite
#

The other five links that it sends work they just don't embed so you just see the link

hidden stump
#

AYO it made the folder

#

it works

#

i did it

proven osprey
#

there are not nearby

spark kite
#

My bot's about me does not show up for some reason. I have no idea why. I set the about me in the appilications page in the discord dev portral

dusk dust
#

i wanted to make a json like this:

{
  email: <email typed by user>
  password: <password typed by user>
}
``` and make the bot write the information into `alternatives_account.json`. how can i do it?
slate swan
#

i really suggest a database

#

why use json to store those type of stuff

#

and hash the passwords

dusk dust
slate swan
#

dont

#

test it with json, whats the point

velvet tinsel
#

Hi Euclid

slate swan
#

its like learning how to ride a bike when you're planning to drive a car

#

hey !

velvet tinsel
#

πŸ™‚

dusk dust
#

yes but i want to learn read json file....

velvet tinsel
#

😦

slate swan
#

read the docs , not those tho

spark kite
#

My bot about me is not showing up

#

I don't know why I put the about me on the discord developer portal and it was working fine before

velvet tinsel
#

?

#

have you saved changes?

spark kite
#

Yes

#

I tried refreshing discord too and it doesn't work

velvet tinsel
#

?

#

Well that’s weird

spark kite
#

Yeah and before I never even changed about me I just suddenly realized it was gone

velvet tinsel
#

I guess you cant

#

Like profile pictures

spark kite
#

I thought it might be because the bot says it's playing a game but other bots do that and it still shows their about me

velvet tinsel
#

And names

spark kite
#

My profile picture and name stayed

#

I just don't know why the about me didn't

#

It just started working a few minutes later

#

I have no idea what happened

slate swan
# sullen shoal can you link a tutorial

Learn how to code a Discord bot using Python and host it for free in the cloud using Repl.it.
🚨Note: At 16:43, Replit now has a new method for environment variables. Check the docs: https://docs.replit.com/programming-ide/storing-sensitive-information-environment-variables

Along the way, you will learn to use Repl.it's built-in database and cr...

β–Ά Play video
slate swan
#

If you make a var that has the same name as a object it just makes a var right?

slate swan
slate swan
#

Β―_(ツ)_/Β―

opal skiff
#

How do i define a link for a button with nextcord?

velvet tinsel
#

hi @slate swan

#

hi winrar

#

hi Myxi

#

πŸ˜„

#

I have no friends

#

😦

slate swan
velvet tinsel
#

Okimii

#

can you be my friend

slate swan
#

Sure

velvet tinsel
#

yay

#

my first friend

#

and I need help

maiden fable
velvet tinsel
#

...

#

YOU HAVE AKUMA???

#

BIG MAN AKUMA??

slate swan
velvet tinsel
#

BIRTHDAY BOI AKUMA????

maiden fable
#

Idk who's that ngl

velvet tinsel
#

HE MY

#

other frien

#

😦

#

also
i have problemo

maiden fable
#

With?

slate swan
#

Who doesnt have akuma?

velvet tinsel
maiden fable
#

then

velvet tinsel
#

I asked in python general

#

no need to say !ot

#
user = await bot.get_user(493451846543998977)
if user == 493451846543998977:
  await ctx.send("!ot")

I think this works

maiden fable
#

No

#

user is a discord.User object not an int lmfao

slate swan
velvet tinsel
#

ok

slate swan
#

Yeah

velvet tinsel
#
if hunting_the_hunter:
  await ctx.send("!ot")
rare saddle
#

How to fix this error

slate swan
slate swan
velvet tinsel
#

no

#

you forgot to put True

#
hunting_the_hunter = True
if hunting_the_hunter:
  await ctx.send("!ot")
slate swan
#

Now it would work

velvet tinsel
#

!e

hunting_the_hunter = True
if hunting_the_hunter:
  print("!ot")
unkempt canyonBOT
#

@velvet tinsel :white_check_mark: Your eval job has completed with return code 0.

!ot
velvet tinsel
#

see
it works πŸ™‚

slate swan
#

Ik that lmao

velvet tinsel
#

!e

hunting_words = ["!ot", "thats off topic", "getting a bit off topic", "hello"]
for word in hunting_words:
  print(word)
unkempt canyonBOT
#

@velvet tinsel :white_check_mark: Your eval job has completed with return code 0.

001 | !ot
002 | thats off topic
003 | getting a bit off topic
004 | hello
velvet tinsel
#

there

slate swan
#

No need for the for loop

#

You can just use the .join() method

maiden fable
#

!ot

unkempt canyonBOT
velvet tinsel
#

!e

for hunting in "hunting the hunter":
  print(hunting)
unkempt canyonBOT
maiden fable
#

And yea this has become way too OT

slate swan
#

Yeah

velvet tinsel
#

no

#

there should be a #hunting-the-hunting-the-hunter channel

slate swan
#

Your bored lmfao

velvet tinsel
#

i am bored

slate swan
#

I know that

velvet tinsel
#

I have an error

#

and I'm still researching it

slate swan
#

Is it related with dpy and discordbots?

velvet tinsel
#

no

#

that's why I'm not asking

#

because hunting_the_hunter is True

slate swan
velvet tinsel
#

it's still True

#

and okimii is True

#

and fun is False

#

but pandabweer is True, so beer is True πŸ˜„

stiff nexus
#

when i persistent a view i cant have interaction_check??

cloud dawn
velvet tinsel
#

Someone ask another question

#

Or else hunting the Hunter will hunt you

maiden fable
#

Can u calm down now?

velvet tinsel
#

No

#

Unless someone asks a question

stiff nexus
velvet tinsel
#

Show the f code

maiden fable
#

yea show the code

maiden fable
stiff nexus
#

'bot' object has no attribute 'author'

velvet tinsel
#

I was being sarcastic

velvet tinsel
#

Not the error

maiden fable
stiff nexus
maiden fable
velvet tinsel
#

||ok||

stiff nexus
#
class trash(discord.ui.View):
    def __init__(self, ctx):
        super().__init__(timeout=None)
        self.ctx = ctx
        #self.bot = ctx.bot

    async def interaction_check(self, interaction: discord.Interaction) -> bool:
        if interaction.user.id != self.ctx.author.id:
            await interaction.response.send_message(
                embed=discord.Embed(description=f"{utily.error} Sorry, you can't use this! This interaction belongs to {self.ctx.author.mention}.",color=0x00c8ff), ephemeral=True)
            return False
        return True
          
    async def on_error(self, error: Exception, item: discord.ui.Item, interaction: discord.Interaction) -> None:
        if interaction.response.is_done():
            await interaction.followup.send(f'{utily.error} An unknown error occurred, sorry\n**Error:** {error}', ephemeral=True)
        else:
            await interaction.response.send_message(f'{utily.error} An unknown error occurred, sorry\n**Error:** {error}', ephemeral=True)
        
        raise error

    @discord.ui.button(style=discord.ButtonStyle.green, emoji="πŸ—‘οΈ")
    async def stop_pages(self, button: discord.ui.Button, interaction: discord.Interaction):
        await interaction.response.defer()
        await interaction.delete_original_message()
        self.stop()
#

also idk why raise error wont work

#

like its not printing the error

#

@maiden fable u helping right?

maiden fable
#

and what is ctx

#

yea bruv

stiff nexus
#

this thing works all good

velvet tinsel
#

Me no like big code

#

On mobile

slate swan
maiden fable
#

well the error is from self.ctx.author

stiff nexus
#

but when i persistent. and restart the bot and use the buttons i get that error

velvet tinsel
#

bot has no attribute author?

maiden fable
stiff nexus
#

Context bruh

maiden fable
#

from where

stiff nexus
#

i dont get it

velvet tinsel
#

Also to make it look nicer instead of #self.bot do # self.bot

#

With a space in between

maiden fable
#

Like from where do u get the Context object

stiff nexus
#

def __init__(self, ctx):

maiden fable
velvet tinsel
#

Oh

stiff nexus
#

pep 8 ?

velvet tinsel
#

Maybe not

maiden fable
slate swan
#

!pep8

unkempt canyonBOT
#

PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.

More information:
β€’ PEP 8 document
β€’ Our PEP 8 song! :notes:

maiden fable
#

!pep 8

unkempt canyonBOT
#
**PEP 8 - Style Guide for Python Code**
Status

Active

Created

05-Jul-2001

Type

Process

velvet tinsel
#

πŸ’€

maiden fable
#

there (:

stiff nexus
slate swan
#

!d is for dpy commands bruh pep8 isnt something related to it

velvet tinsel
maiden fable
unkempt canyonBOT
#
**PEP 8 - Style Guide for Python Code**
Status

Active

Created

05-Jul-2001

Type

Process

velvet tinsel
#

Ah ok

slate swan
maiden fable
stiff nexus
#

where?

velvet tinsel
#

!src d

unkempt canyonBOT
#
Command: docs

Look up documentation for Python symbols.

Source Code
velvet tinsel
maiden fable
velvet tinsel
#

Not only for dpy

slate swan
#

Ok buddypithink

velvet tinsel
#

I’m not a buddy

#

I’m DownloadPython

#

Wtf is buddy

maiden fable
#

friend

velvet tinsel
#

Ok

#

Thank

#

Also

#

You’re wrong Hunter

#

Your bio is wrong

#

Your about me dict didn’t end with }

#

So it will return with an error

stiff nexus
#

@maiden fable i cant use ctx

maiden fable
#

DUDE ITS A DISCORD ISSUE AND ALSO AN OT TALK PLEASE STOP

#

ok sorry its already night and I just lost my mind. sorry again

stiff nexus
#

coz there is no ctx in on_ready

velvet tinsel
#

Calm down bruv

#

😭

stiff nexus
#

now how do i get the author without ctx?

maiden fable
#

!d discord.ext.commands.Bot.add_view

unkempt canyonBOT
#

add_view(view, *, message_id=None)```
Registers a [`View`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.View "discord.ui.View") for persistent listening.

This method should be used for when a view is comprised of components that last longer than the lifecycle of the program.

New in version 2.0.
stiff nexus
stiff nexus
velvet tinsel
#

Do you have an event?

#

Like an on_message?

stiff nexus
#

i do

velvet tinsel
#

then do message.author

stark lintel
#

I really need help with this question, sorry for it being poorly worded. If you need more info just ping me, but its tricky to explain. I won't be available until about 5PM est, but until then any help is appreciated https://stackoverflow.com/questions/70236405/add-buttons-with-responses-to-an-embed-discord-py

boreal ravine
#

just send the embed

#

and the view? whats hard lol

#
await ctx.send(embed=embed, view=view())
stark lintel
#

i need to summarize the issue real quick before i go, but basically, it is a repeating task that is called upon twice a day. the embed is in a function i called "main()", it will send the buttons no problem, but when I try to actually get a response, it says this interaction failed. anyways, gtg now, bye!!!

sullen shoal
slate swan
sullen shoal
cloud dawn
boreal ravine
slate swan
boreal ravine
#

view kwarg takes a class lol

sullen shoal
#

you can but whats the point of having no callback

boreal ravine
#

nvm

#

python color on mobile and pc is different for some reason

slate swan
boreal ravine
#

its just an instance of it

slate swan
#

Welp never knew it can take a class

boreal ravine
#

cool

slate swan
#

Lmao

boreal ravine
slate swan
boreal ravine
#

or the kwarg

slate swan
#

yeah but what does it contian ?

boreal ravine
slate swan
#

and what does it do in the first place

boreal ravine
#

the kwarg or the value

slate swan
#

the view=view()

boreal ravine
slate swan
#

example ?

boreal ravine
slate swan
#

yeah mind showing how they can be used

#

or linking me some 2.0 docs

boreal ravine
unkempt canyonBOT
#

class discord.ui.View(*, timeout=180.0)```
Represents a UI view.

This object must be inherited to create a UI within Discord.

New in version 2.0.
slate swan
#

oh okay

#

thanks !

boreal ravine
#

πŸ‘

opal skiff
#

how do i add a link to a link buttonstyle button using nextcord?

slate swan
#

url kwarg

slate swan
#

hey i need a help with my music system or somethin like that

#

cuz when i type z+play and url for the song the bot dosent play it the bot just join the voice channler and the bot is sillent

hidden stump
#
@commands.command()
    @commands.cooldown(1,2,commands.BucketType.member)
    async def buy(self,ctx,*,item):
        db = sqlite3.connect("./MiningRPG/main.mysql")
        cur = db.cursor()
        cur.execute(f"SELECT coins,current_pick FROM rocks WHERE user_id = '{ctx.message.author.id}'")
        result = cur.fetchone()
        if result is None:
            sql = ("INSERT INTO rocks(user_id,mined,curren_pick,coins) VALUES(?,?,?,?)")
            var = (ctx.message.author.id,0,"Wooden Pickaxe",0)
            cur.execute(sql,var)
            db.commit()
        cur.execute(f"SELECT coins,current_pick FROM rocks WHERE user_id = '{ctx.message.author.id}'")
        result = cur.fetchone()
        if item.lower() == "stone pickaxe":
            if result[1].lower() == item.lower():
                await ctx.send("You already own this item!")
            elif result[1].lower() == "iron pickaxe" or result[1].lower() == "ruby pickaxe":
                await ctx.send("You already own a better pickaxe!")
            elif result[0] < 20:
                await ctx.send("You can't afford that!")
            else:
                current_pick = result[1]
                coins = result[0]
                sql = (f"UPDATE rocks SET coins = ?, current_pick = ? WHERE user_id = '{ctx.message.author.id}'")
                var = (coins - 20, current_pick = "Stone Pickaxe")
                await ctx.send("You have bought an **Stone Pickaxe** for 20 coins!")``` are there any unclosed brackets?
#

it gives me an error and I cant find any

crimson tendon
#

how do I delete a message sent by the bot with discord-py-slash-commands ?

plain prairie
#

can you tell me i saw a bot named poke-name it sends msg whenever other bot msgs and tells name it's a verified bot
i wanna make bot like that too that auto replies , when someone sends particular img like some bot sends a image of Pikachu so my bot says name of this Pokemon is pikachu it's done using some kind of image code

#

It's like a bot replying to other bot's msg (img) knowing what's in that img

hidden stump
#

some1 help me where tf is a open bracket

#

that isnt closed

slate swan
#

sure, show code @hidden stump

slate swan
unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
slate swan
#

Sorry but we can't help for these type of questions.

hidden stump
#

im gonna send the whole thing bruh

#

wait pastebin

trim meadow
#

Hello, does anyone know how can i have an invisible character on my embedded message?

hidden stump
#

the errors are in var = ()

#

the ones where you update

slate swan
#

You can't put current_pick = "Iron Pickaxe"

#

Remove the current_pick = part

opal skiff
#

how do i make multiple asynchronus while True in the on_ready function?

sullen shoal
#

?

slate swan
unkempt canyonBOT
#

asyncio.create_task(coro, *, name=None)```
Wrap the *coro* [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine) into a [`Task`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task "asyncio.Task") and schedule its execution. Return the Task object.

If *name* is not `None`, it is set as the name of the task using [`Task.set_name()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task.set_name "asyncio.Task.set_name").

The task is executed in the loop returned by [`get_running_loop()`](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_running_loop "asyncio.get_running_loop"), [`RuntimeError`](https://docs.python.org/3/library/exceptions.html#RuntimeError "RuntimeError") is raised if there is no running loop in current thread.

This function has been **added in Python 3.7**. Prior to Python 3.7, the low-level [`asyncio.ensure_future()`](https://docs.python.org/3/library/asyncio-future.html#asyncio.ensure_future "asyncio.ensure_future") function can be used instead...
opal skiff
#

ty

sullen shoal
#

!d random.choice

unkempt canyonBOT
#

random.choice(seq)```
Return a random element from the non-empty sequence *seq*. If *seq* is empty, raises [`IndexError`](https://docs.python.org/3/library/exceptions.html#IndexError "IndexError").
hidden stump
sullen shoal
#

then?

slate swan
#

Why do you need it

#

If it's for the SQL query, then just remove current_pick =

#

And keep the string only

sullen shoal
#

!e

d = dict(key="value")
print(d["key"])```
unkempt canyonBOT
#

@sullen shoal :white_check_mark: Your eval job has completed with return code 0.

value
hidden stump
#

oh wait right

slate swan
#

Just like here

sql = ("INSERT INTO rocks(user_id,mined,curren_pick,coins) VALUES(?,?,?,?)")
var = (str(ctx.message.author.id),0,"Wooden Pickaxe",0)
#

You didn't put any x=, which is correct

proven aurora
#

how do I get everyone who is in a voice chat in a server

sullen shoal
#

!d discord.VoiceChannel.members

unkempt canyonBOT
proven aurora
#

no everyone

hidden stump
proven aurora
#

not in one voice chat

slate swan
#

Loop though all the voice channels then

proven aurora
#

every vc

slate swan
#

!d discord.Guild.channels

unkempt canyonBOT
slate swan
#

Loop through that

#

Check if the channel is of type VoiceChannel

#

Then get the len of the members attribute

#

And sum them all

proven aurora
#
for channel in ctx.guild.channels:
  if channel == instance(discord.VoiceChannel):
#

then what

sullen shoal
#

!d isinstance

unkempt canyonBOT
#

isinstance(object, classinfo)```
Return `True` if the *object* argument is an instance of the *classinfo* argument, or of a (direct, indirect, or [virtual](https://docs.python.org/3/glossary.html#term-abstract-base-class)) subclass thereof. If *object* is not an object of the given type, the function always returns `False`. If *classinfo* is a tuple of type objects (or recursively, other such tuples) or a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union) of multiple types, return `True` if *object* is an instance of any of the types. If *classinfo* is not a type or tuple of types and such tuples, a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") exception is raised.

Changed in version 3.10: *classinfo* can be a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union).
proven aurora
#

ooz

slate swan
#

Then use len(channel.members)

#

And add that to a sum variable

sullen shoal
#

also it can be a one liner

proven aurora
#

i am making a move all command

#

well trying

#
        for member in ctx.guild.members:
            if member in ctx.guild.voice.channels.members:
                  print(member)```
proven aurora
#

but its not workingggggg

sullen shoal
#

how did ctx.guild.voice.channels.members: join the code

proven aurora
#

i uh

#

great question

sullen shoal
#

for member in ctx.guild.members:
why is that there

#

wtf is that snippet

slate swan
# slate swan ugh

Bots streaming/downloading music from music providers such as YouTube or Spotify are breaching their terms of service, and therefore breaks the #rules 5.

proven aurora
#

haven't used dpy in a while

slate swan
#

if client.user in message.mentions:

tacit token
#

hello friends

slate swan
sullen shoal
#

client.user is discord.User

#

mentions returns Member

slate swan
#

hm

tacit token
#

how can i link images from pages with discord.py? eg to send an image from the bot to a page. Can anyone help me?

sullen shoal
unkempt canyonBOT
#

property me: discord.member.Member```
Similar to [`Client.user`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.user "discord.Client.user") except an instance of [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member"). This is essentially used to get the member version of yourself.
proven aurora
#

i uh still need help

slate swan
#

well if str(message.content) == "<@idhere>":
not working either

proven aurora
#

wait

#

figured it out\

slate swan
#

how do I check if bot was mentioned

slate swan
sullen shoal
slate swan
sullen shoal
#

Β―_(ツ)_/Β―

slate swan
#

Doesn't matter

#

We won't help you for questions regarding music bots that stream from YouTube or other services

#

You need to do your own research on why it doesn't work

tacit token
tacit token
#

i use >random and my bot send random photo from this web

sullen shoal
#

make an api that could be used to add pictures to your webapp

#

Β―_(ツ)_/Β―

tacit token
#

ty

sullen shoal
tacit token
#

yeah

sullen shoal
#

it returns the image directly so it should work by just putting the url in an embed image

proven aurora
sullen shoal
proven aurora
#
    async def moveall(self, ctx):
        mainVC = ctx.author.voice.channel
        for channel in ctx.guild.channels:
            if channel == isinstance(discord.VoiceChannel, WHAT DO I WRITE HERE):
                for member in channel:
                    print(f"Moved {member.name} to {mainVC.name}")
                    #await member.move_to(mainVC)```
sullen shoal
#

:/

#

!d isinstance

unkempt canyonBOT
#

isinstance(object, classinfo)```
Return `True` if the *object* argument is an instance of the *classinfo* argument, or of a (direct, indirect, or [virtual](https://docs.python.org/3/glossary.html#term-abstract-base-class)) subclass thereof. If *object* is not an object of the given type, the function always returns `False`. If *classinfo* is a tuple of type objects (or recursively, other such tuples) or a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union) of multiple types, return `True` if *object* is an instance of any of the types. If *classinfo* is not a type or tuple of types and such tuples, a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") exception is raised.

Changed in version 3.10: *classinfo* can be a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union).
sullen shoal
#

please make a little effort by reading it

slate swan
#
if isinstance(channel, discord.VoiceChannel):
#

Clearly says first argument is the object

proven aurora
slate swan
#

Second is the class you want to check

proven aurora
#

i just didnt understand it

slate swan
#

Pretty self explaining

proven aurora
#

my first time with isinstance()

plain prairie
tacit token
#

just wait

plain prairie
#

hm?

sullen shoal
proven aurora
#

i did something wrongggg

deft hill
#

What do I need to import for errors? (Missing permissions)

sullen shoal
#

thats the value. not the key

plain prairie
modern fiber
#

Anybody wanna help me on creating a "Advertising" bot. It's not a public but instead a bot that would work in a server that would be used for advertising bots and more. Hm?

deft hill
#
@kick.error
async def kick_error(error, ctx):
    print('Kick Error Command Called')
    print(error)
    if isinstance(error, MissingPermissions):
       await ctx.send(":x: You don't have permission to do that!")

@ban.error
async def ban_error(error, ctx):
    print('Ban Error Command Called')
    print(error)
    if isinstance(error, MissingPermissions):
       await ctx.send(":x: You don't have permission to do that!")

@clear.error
async def clear_error(error, ctx):
    print('Purge Error Command Called')
    print(error)
    if isinstance(error, MissingPermissions):
       await ctx.send(":x: You don't have permission to do that!")

These send the error print then something like "MissingPermissions" is not defined

sullen shoal
sullen shoal
#

code

proven aurora
#
    @commands.command()
    async def moveall(self, ctx):
        mainVC = ctx.author.voice.channel
        for channel in ctx.guild.channels:
            if isinstance(channel, discord.VoiceChannel):
                for member in channel:
                    #print(f"Moved {member.name} to {mainVC}")
                    await member.move_to(mainVC)````
WHAT IS WRONG.
sullen shoal
plain prairie
sullen shoal
#

again, thats the value not the key.

plain prairie
#

@sullen shoal where does it says I'm not allowed to make a responding bot?

#

umm

sullen shoal
plain prairie
#

i don't understand tbh it's a verified bot named PokΓ©-Name

sullen shoal
#

so what, go check their TOS

plain prairie
#

I just wanna create same like that

plain prairie
sullen shoal
#

what are trying to get

sullen shoal
#

youre making a selfbot of

plain prairie
plain prairie
sullen shoal
sullen shoal
slate swan
#

how do I make the prefix @botname

plain prairie
#

even if they did I just wanna learn how to make it

slate swan
#

Self botting breaches Discord terms of service, therefore breaks #rules 5. As simple as that.

sullen shoal
#

then learn yourself. many bots like poketwo are against this and that the developer can be in serious trouble for doing shit like that (pokename's dev)

plain prairie
#

;-;

plain prairie
sullen shoal
#

thats discord who verified it. not the owners of the pokemon bots

plain prairie
#

his bot is in 1.6k servers

sullen shoal
plain prairie
#

what a pain

#

a bot in 1.6 servers and verified by discord also breaks tos of discord

slate swan
#

No, it's not a self bot.

plain prairie
#

Yep

slate swan
#

It breaches the terms of service of the other bot

#

That's it.

plain prairie
slate swan
#

Here we won't help you in making such as bot

plain prairie
#

ohk

slate swan
#

Do your own research or find another server, which I doubt you will find one where people help

plain prairie
sullen shoal
#

looks like its time to ping the mods

plain prairie
#

sure if staff says then it's totally fine

#

ping them

proven aurora
#

HELP.

final iron
#

@plain prairieBottom line is you're developing something to auto reply to an event to get items whenever this pokemon bot sends an image

#

That is most likely against the bots tos

plain prairie
#

hm

plain prairie
#

discord checks when they verify a bot right

#

what it does who made and all

final iron
#

Its not against discord tos, its against the bots terms of service

#

Therefore we're not allowed to help but the bot can still get verified

plain prairie
#

ok so that aside you can help me with that code we get from an img stuff it really makes my head hurt

final iron
#

No. That would break rule 5

plain prairie
polar ice
#

        support_buttons = [[Button(custom_id='administrator'),Button(custom_id='community')]]
        support_buttons[0][1].disabled = True
        await interaction.edit_origin(components=support_buttons)

Hey im trying to disable a button after its been clicked, not sure if im doing it right here? Im getting no errors but it also isnt working

plain prairie
#

but I'm fool enough that i can't find it it's too long and I don't understand coding that well

plain prairie
#

processing*

final iron
plain prairie
#

ah

#

why did I tell in the first place

plain prairie
plain prairie
#

pain

final iron
#

Follow this servers tos. Its just that simple

plain prairie
#

or dm

final iron
#

No

plain prairie
#

ah

slate swan
#

how do I make the bot reply to messages

slate swan
crimson tendon
#

How can I check who clicked on a component with discord-py-slash-command ?

manic wing
unkempt canyonBOT
#

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

A shortcut method to [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") to reply to the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message").

New in version 1.6.
slate swan
#
@commands.command()
    async def pay(self, ctx, member: discord.Member = None, amount: int = None):
        def check(message:str):
            return message.author == ctx.author and message.channel == ctx.channel
        if not member:
            await ctx.send("You must specify a member to pay.")
            return

        await ctx.send("How much would you like to pay?")
        message = await bot.wait_for('message', check=check)

        if not member:
            await ctx.send("You must specify a member to pay.")
            return
        recipient = member
        sender = ctx.author

        users = await get_bal()
        
        if users[str(sender.id)]["balance"] < abs(int(message.content)):
            await ctx.send("You don't have enough money.")
            return
        else:
            users[str(recipient.id)]["balance"] += abs(int(message.content))

            with open ("balance.json", "w") as f:
                json.dump(users, f)
            
            sender = ctx.author
            users = await get_bal()

            users[str(sender.id)]["balance"] -= abs(int(message.content))

            with open ("balance.json", "w") as f:
                json.dump(users, f)
            
            await ctx.send(f"You have successfully paid {recipient.mention} ${(abs(message.content))}.")```

this command stops working after you tell it how much money you want to pay. anyone know why?
manic wing
#

!d discord.Embed.colour || embed = discord.Embed(colour=#ffff)

unkempt canyonBOT
#

The colour code of the embed. Aliased to color as well. This can be set during initialisation.

slate swan
#

no errors btw^

manic wing
#

you have a whack error handler. len(limit) is erroring because you can't use len on an int.

quartz badger
#

I have a problem with the same command (with different code, but it is also the clear command)

from discord.ext import commands

class Clear(commands.Cog):
    """Apaga mensagens"""

    def __init__(self, bot):
        self.bot = bot

    @commands.command(name = "clear")
    @commands.has_permissions(manage_messages = True)
    async def clear(ctx , amount=2):
        await ctx.channel.purge(limit=amount)

def setup(bot):
        bot.add_cog(Clear(bot))```

But then it gives this error:
hidden stump
#

hey thats more of a DB question, but

        cur.execute(f"SELECT current_pick FROM rocks WHERE user_id = '{ctx.message.author.id}'")
        result = cur.fetchone()
        pickaxe = result[0]
        cur.execute(f"SELECT {pickaxe.lower()} FROM tools")
        result = cur.fetchone()
        pickaxe_power = result[0]
        cur.execute(f"SELECT {ore.lower()} FROM ores")
        result = cur.fetchone()
        ore_power = result[0]``` what is "pickaxe"? when i try to use it later it says theres no column "wooden", and the value should be "Wooden Pickaxe" if i understand correctly
manic wing
#

when in a class you use self as an argument

manic wing
quartz badger
tawdry perch
#

And I assume pickaxe is a variable that holds a string value

slate swan
quartz badger
#

ty

tawdry perch
#

If I have made a group command called edit. It has a @edit.command() called message. Can I make a subcommand for that message? Like group for alrd group command

slate swan
#

Yes it can be color or colour really doesnt matter

quartz badger
#

Now I have another problem: when the person has permission to delete, it works fine. It deletes the messages without saying anything (which is supposed to happen). But when the person doesn't have permission, it says that the command doesn't exist, instead of saying that the person doesn't have permission to use it. How do I fix it?

Code where it shows the errors to the person:

from discord.ext import commands
from discord.ext.commands.errors import CommandNotFound, MissingRequiredArgument, MissingPermissions

class Manager(commands.Cog):

    def __init__(self, bot):
        self.bot = bot
    
    # <- Detetar alguma coisa numa mensagem e apagar a mesma ->
    @commands.Cog.listener() 
    async def on_message(self,message): 
        
        id = message.author.id 
        
        if message.author == self.bot.user: # Evita um loop infinito
            return 

        if "discord.gg" in message.content: 
            await message.channel.send(f"<@{str(id)}>, will we stop sending links from other servers? That is not allowed here!") 
            await message.delete()

    # <- Mostrar mensagem de erro ->
    @commands.Cog.listener()
    async def on_command_error(self, ctx, error):
        
        if isinstance(error, MissingRequiredArgument):
            await ctx.send("Please send all arguments. Type `.help` for the parameters of each command.")

        elif(error, CommandNotFound):
            await ctx.send("This command does not exist! Type `.help` to see all commands.")

        elif(error, MissingPermissions):
            await ctx.send("You don't have permission to use this command.")

        else:
            raise error

def setup(bot):
        bot.add_cog(Manager(bot)) ```
slate swan
#

await reply(content=None, embed=embed)

#

when my bot gets added, how would it send a message to the person who added it?

#

no like what event is it? like on_bot_add or something?

slate swan
# manic wing a) `print(error)` in your global error handler b) `if len(str(limit))`
async def purge(ctx, limit:int):
    if len(str(limit)) >= 1501:
        em = discord.Embed(title=f"",description=f"![Notice](https://cdn.discordapp.com/emojis/910942889125752853.webp?size=128 "Notice") - Maximum purge count: `1500`", color=clr)
        await ctx.send(embed=em)
        return
    else:
        await ctx.channel.purge(limit=limit + 1)
        await ctx.send('Successfully Cleared `{}` Messages'.format(limit)) ```
slate swan
#

client

#

yea but what do i do

#

yeah thats what i mean sorry, what do i put under async def .....()

#

no for when someone adds your bot

#
async def purge(ctx, limit:int):
    if len(str(limit)) >= 1501:
        em = discord.Embed(title=f"",description=f"![Notice](https://cdn.discordapp.com/emojis/910942889125752853.webp?size=128 "Notice") - Maximum purge count: `1500`", color=clr)
        await ctx.send(embed=em)
        return
    else:
        await ctx.channel.purge(limit=limit + 1)
        await ctx.send('Successfully Cleared `{}` Messages'.format(limit)) ```anyone know why this happens
slate swan
#

when someone adds your bot it sends the person who added a dm

slate swan
manic wing
slate swan
#

so if limit...

manic wing
#

if limit >=

slate swan
#

discord.Embed(colour=00FF00) doesn't show color

#

am I using a wrong module lol

#

embed = discord.Embed(colour=00FF00)
embed.add_field(name="Version", value=version)
embed.add_field(name="Author", value=author)
embed.add_field(name="Prefix", value=prefix)
await reply(content=None, embed=embed)

#

sends normal message

#

normal embed

#

not reply and not colored

quartz badger
#

caeden

placid skiff
#

guys what was the argument to pass in command decorator to say that the command accept arguments? pass_context or pass_content?

manic wing
manic wing
#

!d discord.Colour.green || or this

unkempt canyonBOT
#

classmethod green()```
A factory method that returns a [`Colour`](https://discordpy.readthedocs.io/en/master/api.html#discord.Colour "discord.Colour") with a value of `0x2ecc71`.
placid skiff
placid skiff
slate swan
#

how to get the 1st channel withj

            for channel in guild.text_channels:```
manic wing
slate swan
manic wing
slate swan
manic wing
unkempt canyonBOT
#

random.choice(seq)```
Return a random element from the non-empty sequence *seq*. If *seq* is empty, raises [`IndexError`](https://docs.python.org/3/library/exceptions.html#IndexError "IndexError").
slate swan
#

alright, quick question-

My bot is sort of like a game, where you can own companies and make money from them or whatever, and I have it so the "work" command has a cooldown on it.
I was wondering if there is a way to get the value of how many companies the user owns, then change how many time a user can run the command in the time period based on how many companies they own, if that makes sense.
I'll make an example of how the amount of companies are found.

#this gets the amount of companies
await open_inv(ctx.author) #this is defined in a different bit of code that creates an inventory in a json file for each user
user = ctx.author
users = await get_inv(ctx.author) #this is also defined in a different bit of code which gets the information from the json file
companies = users[str(user.id)]["Companies"]

#this is how i would want to change the amount of times the command can be ran
@commands.cooldown(companies, 390, commands.BucketType.User)```

is it possible to do something like this? (If anything I said made sense πŸ’€)
tawdry perch
#

Why does this not edit role permissions? It sends a message and everything but it does not work as it should, it's supposed to lockdown a server ```py
@defcon.command(aliases=["lockdown", "activate", "lock"])
async def shutdown(self, ctx):
role = ctx.guild.get_role(self.default)
permissions = role.permissions

    permissions.update(send_messages=False,add_reactions=False,send_messages_in_threads=False,connect=False)
    await role.edit(reason="shutdown", permissions=permissions)
    await ctx.send(f"Server shut down.")
#

self.default is a role ID of member role

slate swan
#

how do you get the message that did the command?

slate swan
#

mythic lol why you here ?

slate swan
tawdry perch
#

...?

slate swan
severe oriole
#

we don't do that here

slate swan
#

how do you get the message that did the command?

#

how do I make a list of words which it checks if the message has

tawdry perch
slate swan
#

so ctx.message?

#

how do I make this work

if ["word1", "word2", "word3"] in message.content.lower():

#

so it would check if the message has any of those

#

if message.content.lower() in ["word1", "word2", "word3"]:

wont work cuz it would only check if the message is that word

sleek ore
#

emojis['Vermelho']?

#

Idk, maybe I'm missing something

#

As variable then, emoj = emojis['vermelho']

#

Emoj because I'm scared name collision error

slate swan
#

how do I make this work

if ["word1", "word2", "word3"] in message.content.lower():

so it would check if the message has any of those

if message.content.lower() in ["word1", "word2", "word3"]:

wont work cuz it would only check if the message is that word

cloud dawn
#

So check if any word is inside of a sentence?

slate swan
#

yes

sleek ore
#

Do if 3 times I guess

slate swan
#

but it needs to be a list

sleek ore
#

Or use this

cloud dawn
#
if any([x for x in message.content.lower().split() if x in ["word1", "word2"]])
sleek ore
#
def exist(check, word):
for test in check:
    if test in word:
        return True
return False

exist(["a", "b", "c"], "atest")
slate swan
slate swan
#

saved me a lot of time and space

quaint epoch
#

does anyone know how to get a channel object if you have the id?

slate swan
#

file.write(f"{current_time} : {message.author.mention} : {message.content} : {message.channel}\n")

#

overwrites the last line everytime

slate swan
#

doesn't start new line

quaint epoch
quaint epoch
#

or use a context manager, because i did the same thing as you to log messges

#

like the exact fricking thing some how :/

slate swan
quaint epoch
slate swan
#

In fact, it's literally the reason why the message intent is becoming privileged

slate swan
#

Well, one of the main reasons

quaint epoch
#

guess i gotta remove that now

slate swan
slate swan
slate swan
#

if the bots are logging messages on their own database, discord only requires that the messages are encrypted and don't last more than 30 days.

slate swan
#

now if it's just a temporary value, and it stops existing as soon as i.e, the process is shut down. it's perfectly fine.

#

or if it fits the above criteria,

#

that is why i said "not exactly"

#

Oh alr

slate swan
#

well there's real uses for such a thing

#

Yeah ik like moderation

#

like "sniping" deleted and edited messages

#

But just logging them for no reason is againsts tos

slate swan
quaint epoch
slate swan
#

uh so

slate swan
# slate swan Seen it but whats that exactly?

whenever a message is deleted or it's content is changed by the original author, these bots will temporarily store the original content to display it to the mods if necessary later on.

slate swan
#

anyone know how to keep last line and add data to new line in file.write

slate swan
#

ah yes

#

although if you're planning long term storage, please switch to a database instead.

#

how do I loop thru all channels and check if they are a specific channel

placid skiff
#

Guys to make my bot don't eat specified command error with the on_command_error event i just need to use the listener instead of the event right?

slate swan
#

what do I loop thru

#

aka change the channels to

placid skiff
#

!d discord.Guild.channels

unkempt canyonBOT
slate swan
#

AttributeError: module 'discord.guild' has no attribute 'channels'

placid skiff
#

the discord.guild is just the class of a Guild, you need the guild object where the channels are

#

you can retrieve it by the context if it is used in a command, else you need some other way to convert a Guild by it's ID

cloud dawn
faint echo
placid skiff
#

Guys i have a task loop in a Cog but it won't run. Here is the code:

class MainLoop(Cog):
    def __init__(self, bot):
        self.bot = bot

    @loop(seconds=2)
    async def check_news(self):
        data = db.records("SELECT * FROM oPNEWS", None)
        print(data)

It should print something every two seconds but it doesn't

faint echo
#
from discord.ext import tasks, commands

class MyCog(commands.Cog):
    def __init__(self):
        self.index = 0
        self.printer.start()

    def cog_unload(self):
        self.printer.cancel()

    @tasks.loop(seconds=5.0)
    async def printer(self):
        print(self.index)
        self.index += 1

On this discord.py documentation example you can clearly see that self.printer.start() starts the task.
I don't see that on your cog.

placid skiff
#

Lol maybe i need to sleep...

pliant gulch
#

db.records is a blocking call right?

#

And the loop runs every 2 seconds

#

Meaning the bot would freeze up for X amount of time per 2 seconds during its lifetime

#

Not ideal

placid skiff
#

Yeah it is only a test, i don't wont to wait half an hour every time i need to test xD

polar ice
#

Can anyone reccomend a afordable half decent VPS just to host my discord bot on?

stark lintel
#

i just bought a vps the other day for my bot, it works beautifully

#

speaking of that...I need someone to help me again...

#

this is what it looks like so far...

polar ice
#

@stark lintel Whats wrong with your bot?

stark lintel
#
async def survey():
    embed = discord.Embed(color = 0x800020)
    embed.title = "Survey!"
    embed.description = "Click a button below to submit an anonymous survey!"
    #embed.set_thumbnail(url=pic1)
    embed.timestamp=datetime.datetime.utcnow()
    embed.set_footer(text=f'AHSweather v{_version_} \u200b')
    bcc = client.get_channel(886307415518240768)#general
    buttons = [create_button(style=ButtonStyle.green, label="I liked it", custom_id='3'), create_button(style=ButtonStyle.grey, label="I'm neutral"), create_button(style=ButtonStyle.red, label="I did not like it")]
    action_row = create_actionrow(*buttons)
    bcc2 = await bcc.send(embed=embed, components=[action_row])
    
@client.event
async def on_component(ctx: ComponentContext):
    # you may want to filter or change behaviour based on custom_id or message
    await ctx.edit_origin(content="You pressed a button!")    

@client.event
async def on_ready():
    await client.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name='your AHS weather!'))
    print(f'Connected to bot: {client.user.name}')
    print(f'Bot ID: {client.user.id}')

    warnings.simplefilter('ignore')
    
    scheduler = AsyncIOScheduler()
    scheduler.add_job(main, CronTrigger(hour = 3, minute = 30, second = 0))
    scheduler.add_job(survey, CronTrigger(hour = 15, minute = 35, second = 0))#3, 30, 10
    scheduler.add_job(main, CronTrigger(hour = 18, minute = 0, second = 0))
    scheduler.add_job(survey, CronTrigger(hour = 18, minute = 0, second = 0))
    scheduler.start()

    print("")
    print(f"v{_version_} SYSTEM READY {time.strftime('%H:%M:%S, %m-%d-%Y')}...")

client.run(TOKEN)
#

this is the code giving me issues

#

my buttons dont function

#

and im not sure why

stark lintel
#

oh, like what imports?

placid skiff
#
@loop(seconds=15.0)
    async def check_news(self):
        data = db.records_no_values("SELECT * FROM oPNEWS")
        if data is not None:
            for guild, channel, address in data:
                if channel is not None:
                    guild: Guild = self.bot.get_guild(guild)
                    channel: TextChannel = self.bot.get_channel(channel) # 901956294775275541
                    html_page = requests.get('https://www.outplayed.it').content
                    doc = BeautifulSoup(html_page, "html.parser")
                    
                    latest = doc.find_all(attrs="td-module-thumb")
                    latest_news = latest[0].parent.find("a")
                    if address is None or (address != latest_news['href']):
                        logo = doc.find_all(attrs="td-logo")
                        link_logo = logo[0].parent.find("img")
                        await channel.send(f"{link_logo['src']}")
                        await channel.send(f"***\"La redazione di Outplayed ha pubblicato un nuovo articolo, "
                                           f"link in descrizione\"***\n\n"
                                           f"{latest_news['href']}")
                        db.execute("UPDATE oPNEWS SET OldNews = ? WHERE GuildID IS ?", latest_news['href'], guild.id)
        return

Why the get_guild and get_channel returns me None? i checked and the IDs are correct

slate swan
stark lintel
#

tbh, im not sure, just whatever is in the discord button docs

slate swan
stark lintel
#

f

slate swan
stark lintel
#

when it says ctx: ComponentContext, am i supposed to change that value?

steep drift
slate swan
slate swan
#

Wdym by not saving

steep drift
slate swan
#

Ah my bad dont really know what it is

#

Dont think its a db

stark lintel
#

so okimii you have no idea about my bot issue?

slate swan
#

Nah never used pickle i only use dbs

steep drift
#

Its really good

slate swan
steep drift
#

Β―_(ツ)_/Β―

slate swan
#

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

#

Digital ocean is good cheap and secure and i think its in america for all the american users

spark kite
#

My bot is sending 10 links to the 10 images it was supposed to send but only 5 of them are embedded. Is this because it's a bot account or is there something I need to code?

visual island
placid skiff
#

yeah i noticed, i made it so it skips the first loop

ripe willow
#

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

ripe willow
#

'''py

#
print('Hello world!')
#
# Lire le fichier
fichier = open("log.txt", 'r')
contenu_du_fichier = fichier.readline()
print(contenu_du_fichier)
# clicks
clicks = contenu_du_fichier
worldly bane
icy pecan
#

I have a discord bot in which I am trying to send a message over 4000 characters over dm. How do I instead sent this message as a text file

worldly bane
#
await ctx.send(file=discord.File(r'readme.txt'))
icy pecan
#

ty

stark lintel
#

ok, so i changed my code a little hoping it would work

#

and it still wont work...

#
async def survey():
    embed = discord.Embed(color = 0x800020)
    embed.title = "Survey!"
    embed.description = "Click a button below to submit an anonymous survey!"
    #embed.set_thumbnail(url=pic1)
    embed.timestamp=datetime.datetime.utcnow()
    embed.set_footer(text=f'AHSweather v{_version_} \u200b')
    bcc = client.get_channel(886307415518240768)#general
    #buttons = [create_button(style=ButtonStyle.green, label="I liked it", custom_id='3'), create_button(style=ButtonStyle.grey, label="I'm neutral"), create_button(style=ButtonStyle.red, label="I did not like it")]
    await bcc.send(embed=embed, components=[
                Button(style=ButtonStyle.red, label="Click")
            ]
        )

    interaction = await client.wait_for("button_click", check=lambda i: i.component.label.startswith("Click"))
    await interaction.respond(content="Button Clicked!")

    print("done")
slate swan
slate swan
steep drift
#

then I would use that

#

@polar ice

slate swan
polar ice
#

@steep drift hello?

steep drift
steep drift
slate swan
#

Not really bad and is kinda overkill for a bot with 100 or less guilds

polar ice
#

Ideally id like a cheap windows one. Be much easier for me to use. never really used linux