#discord-bots

1 messages · Page 6 of 1

slate swan
#

what's your code...

silk fulcrum
#

client = discord.Client for sure

thorn grove
slate swan
#
PS C:\Users\Administrator\Desktop\Elongated Musket> & C:/Users/Administrator/AppData/Local/Programs/Python/Python310/python.exe "c:/Users/Administrator/Desktop/Elongated Musket/main.py"
Traceback (most recent call last):
  File "c:\Users\Administrator\Desktop\Elongated Musket\main.py", line 1, in <module>
    import discord
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\__init__.py", line 25, in <module>
    from .client import Client
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 53, in <module>
    from .webhook import Webhook
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\__init__.py", line 12, in <module>
    from .async_ import *
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\async_.py", line 52, in <module>
    from ..channel import PartialMessageable
ImportError: cannot import name 'PartialMessageable' from 'discord.channel' (C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\channel.py)

@slate swan I have no clue why

thorn grove
slate swan
thorn grove
silk fulcrum
#

it's discord.Client

slate swan
slate swan
thorn grove
slate swan
#

Now I get this

PS C:\Users\Administrator\Desktop\Elongated Musket> & C:/Users/Administrator/AppData/Local/Programs/Python/Python310/python.exe "c:/Users/Administrator/Desktop/Elongated Musket/main.py"
Traceback (most recent call last):
  File "c:\Users\Administrator\Desktop\Elongated Musket\main.py", line 2, in <module>
    from discord.ext import commands
ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)
thorn grove
#

sed

slate swan
#

this all worked when I tried running it on my PC, but on a vps it's not..

slate swan
thorn grove
#

the same lol

silk fulcrum
#

@thorn grove for you the solution that clearly will work is to merge two of your on_message events into one

slate swan
hardy yoke
#

obligatory "use a venv for instsallations"

silk fulcrum
thorn grove
#

oh nvm

slate swan
#

disappointing😔

thorn grove
#

theres a mispell

slate swan
thorn grove
slate swan
#

epic

silk fulcrum
#

wow

slate swan
#

@slate swan it's because I have discord.ext and discord.py installed locally

silk fulcrum
#

i guess... wtf is ctx.respond?

slate swan
silk fulcrum
#

oh sorry

thorn grove
#

oh lol one command only works

#

only this works

austere vale
#

when someone deletes an image or an embed, how can i grab the image link and embed contents and send it inside an embed? for my audit log

silk fulcrum
silk fulcrum
#

you can only pass one function into one event

#

what you did is not available

thorn grove
#

use only msg?

silk fulcrum
#

yes

thorn grove
#

okay

#

still the same lol

silk fulcrum
#

you should do frompy def func(m): boom(m) def func2(m1): beep(m1) def func3(m2): baap(m2) to

def func(m):
  boom(m)
  beep(m)
  baap(m)```
#

make it one function

thorn grove
#

yeah

#

its still the same

silk fulcrum
#

im pretty sure you just changed the argument to msg in every func

silk fulcrum
thorn grove
#

oops wait

#

wrong one

silk fulcrum
#

okay

thorn grove
thorn grove
#

whats wrong lol

silk fulcrum
#

there are multiple functions

#

you need only one

glad cradle
#

why do you need so many on_message

silk fulcrum
#

just remove second and third async def

silk fulcrum
thorn grove
#

okay

zealous carbon
#

I'm looking for a way to execute a function inside cog which prints something. Like a for loop for example. Just need an example

thorn grove
#

works now

#

thanks @silk fulcrum

austere vale
#
  @commands.Cog.listener()
  async def on_message_delete(self, message):
    if not message.author.bot:
      embed=nextcord.Embed(title="Message delete", description= f"Deleted by {message.author.mention} in {message.channel.mention}",color=0xfd9fa1, timestamp=datetime.datetime.utcnow())
      fields=[("Content",message.content,False)]
      for name, value, inline in fields:
        embed.add_field(name=name,value=value,inline=inline)
      for attachments in message:
        file = await message.attachments[0].to_file()
        file.filename = 'image.png'
        embed.set_image(url='attachment://image.png')
        await self.bot.get_channel(933978399280599080).send( embed=embed)        
      await self.bot.get_channel(933978399280599080).send( embed=embed)

could someone help me? im trying to have my bot send deleted images to a log channel

silk fulcrum
zealous carbon
#
class Economy(commands.Cog):
    ...

    async def withdraw_money(self, member, money):
        # implementation here
        ...

    async def deposit_money(self, member, money):
        # implementation here
        ...

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

    def coinflip(self):
        return random.randint(0, 1)

    @commands.command()
    async def gamble(self, ctx, money: int):
        """Gambles some money."""
        economy = self.bot.get_cog('Economy')
        if economy is not None:
            await economy.withdraw_money(ctx.author, money)
            if self.coinflip() == 1:
                await economy.deposit_money(ctx.author, money * 1.5)
silk fulcrum
zealous carbon
#

For example in there I want that coinflip function to be called like it prints ("hello")

#

Post_init

#

Missing just syntax

#

Apparently this is wrong

silk fulcrum
#

im missing an idea

#

why not just do print('hello') inside init?

#

why function?

zealous carbon
#

Yea the example is just bad lemme explain further

#

I'm about to get a value from database and store it inside a variable, and this needs to execute somewhere in code but it might need a for loop

#

Not sure if I can put for loops inside init can I

silk fulcrum
#

why not?

#

that's just a regular function

zealous carbon
#

How about a while?

silk fulcrum
#

why not?

zealous carbon
#

If it ok then nothing lol thought it somehow gives tons of load

glad cradle
#

if it is not infinite

thorn grove
#

how to get the value of message

#

lol

slate swan
silk fulcrum
zealous carbon
thorn grove
glad cradle
slate swan
#

^^

glad cradle
silk fulcrum
zealous carbon
silk fulcrum
zealous carbon
#

My prob is like own kind

silk fulcrum
zealous carbon
#

The database has a time value set like 13:00:00

#

I have a loop in other cog which check the time each second from File atm

slate swan
#

Anyone know how to have discord.ext and discord.py installed without them clashing?

zealous carbon
#

The solution could be like check the database each minute, if the time set has changed there

silk fulcrum
zealous carbon
zealous carbon
#

Is it possible to do multiple tasks in same cog?

silk fulcrum
#

why not?

zealous carbon
#

Maybe it's the code I use

silk fulcrum
#

neck that someone

#

or me

slate swan
zealous carbon
#
@tasks.loop(seconds=1)
    async def called_once_a_day(self):
        self.target_channel = self.bot.get_channel(self.discordchannelid)
        x = datetime.datetime.utcnow()
        y = (x.strftime("%H:%M:%S"))
        
        z = open("postingtime.txt", "r").read()
        if y == z.strip():
           randness = collection.aggregate([{'$sample': {'size': 1 }}])
           async for result in randness:
                            print("Requested random post from database:", result["motd"])
                            embed = discord.Embed(description=f"```yaml\nMessage of the day:\n{result['motd']}\n```", color=discord.Color.blue())
                            await self.target_channel.send(embed=embed)
                       
    @called_once_a_day.before_loop
    async def before(self):
        await self.bot.wait_until_ready()
        print("Finished waiting")```
#

The yaml there is just decorating the embed

glad cradle
vocal snow
thorn grove
#

how can i make a embed instead of message

slate swan
slate swan
zealous carbon
#

There isn't any. Doublechecking this spaghetti might actaully work

#

But ok thanks for this

silk fulcrum
unkempt canyonBOT
#

class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") for you.

Changed in version 2.0: `Embed.Empty` has been removed in favour of `None`.
thorn grove
#

oh

vocal snow
thorn grove
glad cradle
unkempt canyonBOT
#

set_image(*, url)```
Sets the image for the embed content.

This function returns the class instance to allow for fluent-style chaining.
glad cradle
#

there are multiple methods

vocal snow
silk fulcrum
#

i sent discord.Embed, there is everything

slate swan
vocal snow
#

Use venvs then

#

Poetry is nice for dependency management in general

glad cradle
slate swan
thorn grove
vocal snow
unkempt canyonBOT
#
I don't think so.

No documentation found for the requested symbol.

vocal snow
#

!!

slate swan
vocal snow
#

Check out it's documentation there'll be a guide

glad cradle
#

where the second embed it's the name of your variable that is storing your discord.Embed object

jade fulcrum
#

anyone know why this happens

vivid gate
#

guys do anyone know how can i fix this ?

jade fulcrum
#

i defined the varibles above

zealous carbon
#

How is the line 7 in taht file

glad cradle
#

also that's not related with discord.py or discord Bots

thorn grove
#

doesn't work

glad cradle
#

!d discord.Embed

unkempt canyonBOT
#

class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") for you.

Changed in version 2.0: `Embed.Empty` has been removed in favour of `None`.
glad cradle
#
embed = discord.Embed(title=...,....)
slate swan
#
embed = discord.Embed(title="Embed title field", description="Embed description field")
await msg.channel.send(embed=embed)

@thorn grove

thorn grove
#

oh

vivid gate
#

guys do anyone know how can i fix this ?
i already installed it but i dont know whats the problem.

thorn grove
slate swan
thorn grove
slate swan
#

ahhhh i have a love hate relationship with cogs

thorn grove
slate swan
slate swan
thorn grove
#

okay

slate swan
#

just import from discord alone, and import tasks on a new line

vivid gate
#

ow ok

#

let me try

slate swan
thorn grove
#

Bot not workint

vivid gate
thorn grove
fleet oxide
#

like does it ignore commadns?

thorn grove
slate swan
thorn grove
#

doesnt work

fleet oxide
#

do you have bot.run with the api key and all

vivid gate
thorn grove
slate swan
thorn grove
#

it works, but when i put the code no work

vocal snow
#

from discord.ext

fleet oxide
thorn grove
#

but when i put it it doenst now

fleet oxide
#

okay

#

at the end of get messages you need to have

#

await bot.process_commands(message)

vocal snow
#

You have to respond within 3 seconds of receiving an interaction

thorn grove
fleet oxide
#

so that it knows to run the message through all the commands

#

put it at the end and dont return or anything

#

that return may be throwing it off

thorn grove
#

okay

fleet oxide
#

when you use on_message you are overwriting the default that already runs the message through the commands

#

so you need to do it yourself with that line i sent

thorn grove
#

my bot still offline

#

wait

vivid gate
#

guys do anyone know how can i fix this ?
i already installed it but i dont know whats the problem.

slate swan
#

!resources

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

vocal snow
#

!d discord.InteractionResponse

unkempt canyonBOT
#

class discord.InteractionResponse```
Represents a Discord interaction response.

This type can be accessed through [`Interaction.response`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction.response "discord.Interaction.response").

New in version 2.0.
slate swan
vivid gate
slate swan
fleet oxide
#

what is that code above line 10?

vivid gate
vocal snow
slate swan
thorn grove
#

array of texts

vivid gate
fleet oxide
slate swan
thorn grove
fleet oxide
#

is "msg" defined

#

up there

vivid gate
slate swan
fleet oxide
#

msg is only defined in get_messages

vivid gate
fleet oxide
#

you need to put it in there

slate swan
vivid gate
#

ok wait

thorn grove
fleet oxide
#

thats why

#

okay you need to

slate swan
slate swan
glad cradle
fleet oxide
#

okay i get it

thorn grove
fleet oxide
#

msg.author is dependent on the message

thorn grove
fleet oxide
#

and you dont have it unless it is in get_messages

vivid gate
slate swan
fleet oxide
#

you need to put the part where you define the embed before the line that sends the embed

vivid gate
fleet oxide
#

after the check that its a bad word

slate swan
thorn grove
fleet oxide
#

yes but you need to put it RIGHT BEFORE

#

like the exact line before it

#

msg is only defined every time someone sends a message, right?

#

and you need the message to define whats in the embed properly

#

(to get the person who send the message)

thorn grove
#

okay

fleet oxide
#

no other issues i see

thorn grove
#

tysm!

slate swan
#

havent used d.py in a while, will this work or na?

thorn grove
#

i like this community, so great

thorn grove
fleet oxide
#

amazing

#

come back if you have any other issues

thorn grove
#

check if the role is moderator etc.

#

or owner

fleet oxide
#

or if you mean like you in specific like a user

slate swan
#
@client.command()
@commands.is_owner()
async def do_stuff
fleet oxide
#

i think he means like just the owner of the bot

#

not like the server

slate swan
#

this only works for the owner of the bot

thorn grove
#

if its a mod or owner role then:

if "Moderator" not in str(msg.author.roles) and(other stuff) \\do stuff here

fleet oxide
#

it seemed like the owner of the server is what i though

slate swan
fleet oxide
#

ah

#

well either way you can go if str(ctx.author) == "botowner68#3834":

#

and you can switch out the discord user for whoever

slate swan
#

nah lol

thorn grove
#

@fleet oxide how to change the color of the embed(the side)

slate swan
thorn grove
#

okay

slate swan
#

ye here

fleet oxide
#

that

#

this is basically everything on embeds if you need

slate swan
#

by default its transparent i think

latent anchor
#

im making a timeout cmd but it doesnt work anyone know how to fix it?

@commands.command()
  async def timeout(self,ctx, member : discord.Member,*, time: datetime,reason:None):
    for i in range(time):
      await member.timeout(time)
      await ctx.send (f'{member.mention} has been timeouted for {time},Reason = {reason}')
slate swan
#

lemme send the code

fleet oxide
#

well its 3:30 it seems like a good time to go to bed

swift pumice
#

bruh?

slate swan
#

@latent anchor

async def timeout_user(*, user_id: int, guild_id: int, until):
    headers = {"Authorization": f"Bot {client.http.token}"}
    url = f"https://discord.com/api/v9/guilds/{guild_id}/members/{user_id}"
    timeout = (datetime.datetime.utcnow() + datetime.timedelta(minutes=until)).isoformat()
    json = {'communication_disabled_until': timeout}
    async with client.session.patch(url, json=json, headers=headers) as session:
        if session.status in range(200, 299):
           return True
        return False

then

@client.command()
@commands.has_permissions(kick_members=True)
async def timeout(ctx: commands.Context, member: discord.Member, until: int):
    handshake = await timeout_user(user_id=member.id, guild_id=ctx.guild.id, until=until)
    if handshake:
         return await ctx.send(f"Successfully timed out user for {until} minutes.")
    await ctx.send("Something went wrong")

unless the jewpi is updated

latent anchor
slate swan
#

worked for me

latent anchor
#

ty ima try it

slate swan
thorn grove
#

doenst work tho

#

it says syntax error(pointing at equal sign)

fleet oxide
#

you need to put a color object

#

not just a hex

thorn grove
#

i now see ir

fleet oxide
thorn grove
#

i forgor to put close parenthesis in description

fleet oxide
#

this has embed things in it but i really gotta sleep

thorn grove
#

okay thanks for your help

latent anchor
#

@slate swan it didnt work and no error comes out

slate swan
latent anchor
#

yes

slate swan
#

have u tried timing out a normal user

latent anchor
#

yes

slate swan
#

hm

latent anchor
#

hm

tough lance
#

Hi

latent anchor
#

i changed sometime and it showed something went wrong

#

what does handshake means in the code

slate swan
#

yes i want to work for discord, thank you

slate swan
#

@latent anchor are u using cogs and self?

latent anchor
#

not cogs

slate swan
#

weird

#

is the async def above the command?

and is it async def alone,

tough lance
latent anchor
odd mango
#

ImportError: cannot import name 'ui' from 'discord' (/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/init.py)

#

what to do

slate swan
slate swan
odd mango
latent anchor
slate swan
slate swan
tough lance
unkempt canyonBOT
#

Hey @latent anchor!

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

latent anchor
#

uh

unkempt canyonBOT
#

Hey @latent anchor!

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

tough lance
latent anchor
slate swan
#

think u need to import json

odd mango
#

i am using 2.0 already

latent anchor
tough lance
#

Did you do this before?

slate swan
tough lance
odd mango
latent anchor
slate swan
#

@latent anchor ah so at the top where u define ur bot make it look like this kinda

warnings.filterwarnings("ignore", category=DeprecationWarning)
intents = discord.Intents().all()
client = commands.Bot(command_prefix="whatever", intents=intents, case_insensitive=True)
client.session = aiohttp.ClientSession()
shrewd apex
vale wing
#

asyncio.sleep(100000) is kinda funny

#

!d discord.ext.tasks.loop use this (examples are on top of doc page)

unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
vale wing
#

Also you can put these into one dict of type dict[author_id, Message object]

#

"Examples are on top of doc page"

#

You make a function

#

How can you await function definition

#

Did you even check the examples

#

It's a decorator

fresh ferry
#

him having this problem and i dont know what i should do :/

vale wing
fresh ferry
#

oh the discord hosting site it wont allow me to run my own commands through their console

#

i tried doing pip install discord.py through my source but that didnt work

vale wing
#

What site

fresh ferry
#

pebblehosting

vale wing
#

What does it provide

#

Why not just get a VPS

fresh ferry
vale wing
#

You can get a VPS for 3$/mo

#

And it will still be decent to run a discord bot

fresh ferry
vale wing
#

Different ones

#

Galaxygate offers a decent VPS with almost unlimited bandwidth for 3$/mo and I once used it myself, was enough to run like 4 bots in parallel

fresh ferry
#

do they offer mySQL?

vale wing
#

They offer you a literal server with full access to it, you can install whatever you want to it

#

And mysql installation is done in 3 commands from what I just googled

slate swan
#

I like the look of that pebblehosting, there dedicated hosting is pretty cheap! 🤣😂 I can say most small cloud hosting does the same price as pebble host there usually started around 3$, I use digital ocean for my bot.

grim hill
#

Hello, yesterday my discord module was working fine but now it seems like it is gone or something like it isn't there anymore because now it says import error

#

i did not change anything

grim hill
#

vscode

vale wing
#

Check the python interpreter setting in bottom right corner

grim hill
#

someone pointed out it could be a version thing

vale wing
#

And tell me if you do have venv folder somewhere in your project

grim hill
vale wing
#

I recommend downloading normal python

grim hill
#

i don't

vale wing
#

Make sure to delete windows store version before you install one from python site

grim hill
#

i seem to be able to select a different version on that button, i have selected the 3.9 one and that one seems to work

vale wing
#

Is it windows store too

grim hill
#

yeah,

vale wing
#

Personally I don't recommend it, sometimes there are bugs

#

That get solved by installing normal python

grim hill
#

i am mostly just using it for a quick thing i generally don't really use python a lot so i don't mind

#

I am just making a small extra thing for an existing bot

vale wing
#

Ok

swift pumice
knotty agate
#

How can i download a users profile picture in discord.py?

vocal snow
unkempt canyonBOT
#

property avatar```
Returns an [`Asset`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Asset "discord.Asset") for the avatar the user has.

If the user does not have a traditional avatar, `None` is returned. If you want the avatar that a user has displayed, consider [`display_avatar`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User.display_avatar "discord.User.display_avatar").
vocal snow
#

Asset has a save method

knotty agate
#

Thx

craggy cloak
#

Why is my embed so wide?

rain olive
craggy cloak
rain olive
#

there's nothing you can do about it

#

other than complain to discord

slate swan
timid briar
#

guys you kn a solu for this ??

rain olive
timid briar
rain olive
#

i dont know what ur code is

slate swan
timid briar
#

thx

timid briar
#

ah i was wrong with id server thx

#

what about this

terse coyote
#

can i do custom buttons in my bot's profile?

slate swan
# timid briar what about this

You need to show the full error at the bottom as well if you want effective help, not cut out the most important part.

fresh ferry
#

im at a lose, this worked months ago and now its not

frail carbon
#

how do i get the channel object from just the channel id since i have a task loop to change a specific channel name, the code attached doesnt work properly and returns a none object

frigid relic
#

Should I need to learn complete python to build a DC bot or just start by watching videos "How to build DC bot.." @trail flower

cold sonnet
#

1st

#

do yourself the favor to learn

quaint scaffold
grim hill
#

Hello, i want to check if a message exists when my cog is in the initialize function
I would like to use this to make sure to unlock a channel if it is gone
I know the channel id and message id

swift pumice
#

.d bot.guild

thorn grove
#

is it possible to link a .py file to another .py file?

robust fulcrum
#

How can we make slash command sync fast in servers?

slate swan
#

Discord needs some time to sync the commands to all the guilds, which iirc is max ~3 hours

slate swan
slate swan
# timid briar

An option's name you set for the command isn't valid or at least not allowed to be set as option's name by discord

slate swan
gray scroll
#

async def addMember(interaction, member: discord.member, role:str):
await interaction(member), interaction(role)
Addmember = addMember(wks, member, role)

#

im trying to do double user inputs but cant seem to get it right

#

ive debugged for the google sheets part already it checked out just porting to discord is a problem

slate swan
# gray scroll

why would you do interaction(member) and interaction(role) in the first place

gray scroll
#

im not sure whats the correct one

#

tried finding documentation but they werent the ones im looking for

#

so i just tried the most logical inpuit

shrewd apex
#

hello Ashley

slate swan
# gray scroll im not sure whats the correct one

that's not how you use that ASakashrug
you should remove that line and have the correct typehints, which are - member: discord.Member, role: discord.Role
so that, member gets converted to a Member object (converted by discord.py internally)
and role gets converted to a Role object (converted by discord.py internally)

slate swan
gray scroll
#

oh so just replace the interaction(member) with interaction(discord.Member)?

#

and same as role?

thorn grove
slate swan
shrewd apex
#

also isn't in await member.add_roles()?

slate swan
#

and removing means removing the line, not modifying it

shrewd apex
#

why call resursive

gray scroll
#

oh im not adding roles to discord itself

#

im trying to add it into a google sheet

#

like a user input role as member/staff

thorn grove
shrewd apex
#

it doesn't change the fact u are calling the same function in the function with no checks?

gray scroll
slate swan
#

I agree, asher should elaborate about the type of checks (I understand it though)

shrewd apex
# thorn grove anyone?

just copy paste all the code in that py file and place it in ur directory simplest way

gray scroll
#

im sorry i just started dabbling in this a few days ago so i dont understand some stuff still

shrewd apex
#

u know what's a recursive function?

gray scroll
#

not really

shrewd apex
#

so can u tell me why are u calling addMember in the addMember function what are u expecting to happen

gray scroll
#

i read it a bit is it something that calls upon another function after an input in a function

thorn grove
gray scroll
slate swan
# thorn grove anyone?
#file.py
def multiply(num1: int, num2: int):
  return num1*num2

#main.py
from file import multiply

s = multiply(1, 2)
print(s) #---> 2

the condition is that file.py is in the same dir as main.py

ancient jolt
#

i keep getting this error "Ignoring exception in command None: discord.ext.commands.errors.CommandNotFound: Command "info" is not found" however I'm able to use the command without issues, ill post my code in a pastebin (https://pastebin.com/9CJc3aKm). I'm able to use all the commands without issues I just get this error for all the commands I use.

gray scroll
shrewd apex
thorn grove
#

okay thanks

novel prairie
#

@bot.command()
@commands.is_owner()
async def say(ctx, *, message):
if (message.content.includes('@'))
return message.channel.send("You do not have permission");
embed=discord.Embed (title= message)
await ctx.message.delete()
await ctx.send(embed=embed)

#

File "main.py", line 100
if (message.content.includes('@'))
^
SyntaxError: invalid syntax

novel prairie
slate swan
#

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

shrewd apex
#
@bot.command()
@commands.is_owner()
async def say(ctx, *, message):
   if '@' in message:
      return await message.channel.send("You do not have permission")
   embed=discord.Embed(title='IDK', description=message)
   await ctx.message.delete()
   await ctx.send(embed=embed)
gray scroll
#

asher is there any way to do double user input for a bot command?

#

i cant seem to find any documentation online for it

slate swan
novel prairie
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'content'

#

lmao

#

um is someone there?

slate swan
#

yes.

#

show code

novel prairie
#

oke wait

slate swan
#

you probably did message = "some_str" then trying to do message.content

novel prairie
#
@commands.is_owner()
async def say(ctx, *, message):
   if '@' in message.content():
      return await message.channel.send("You do not have permission")
   embed=discord.Embed (title= message)
   await ctx.message.delete()
   await ctx.send(embed=embed)```
#
@bot.command()
@commands.is_owner()
async def say(ctx, *, message):
   if '@' in message.content():
      return await message.channel.send("You do not have permission")
   embed=discord.Embed (title= message)
   await ctx.message.delete()
   await ctx.send(embed=embed)```
slate swan
novel prairie
#

so how do i fix this?

slate swan
novel prairie
#

i remove the ()

#

?

slate swan
#

I think you can see that by yourself too

#

no offence

novel prairie
#

i did but it says this

#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'channel'

slate swan
#

do u guys know how to make a backup of a server?

slate swan
novel prairie
#

oke

glacial jungle
#

Can any one help me how can I add a role with a bot in python

thorn grove
#

how to add buttons in my message? some tuts are outdated

shrewd apex
glacial jungle
# thorn grove how to add buttons in my message? some tuts are outdated

If you want Discord Button Roles in your discord server be sure to watch this video! Since Discord introduced buttons to the platform, more and more users have started to use them. They are a replacement from the old reaction roles and it gives an cleaner more modern look to your discord server. In this video you will learn how you can add some ...

▶ Play video
thorn grove
shrewd apex
# thorn grove how to add buttons in my message? some tuts are outdated
@bot.command()
async def test(ctx):
  view = View(timeout=60)
  button = discord.Button(label="press me")
  async def callback(interaction):
    await interaction.response.send_message(f'{interaction.user} pressed me')
  button.callback = callback
  view.add_item(button)
  await ctx.send('test', view=view)
thorn grove
glacial jungle
thorn grove
#

this is such a great community

glacial jungle
#

Can any one help me

shrewd apex
unkempt canyonBOT
#

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

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
glacial jungle
#

How can I make the bot add a role

#

Thx

#

But how do I setup it

#

Am working on a nuke bot that's why

slate swan
#

..? #bot-commands

glacial jungle
swift pumice
shrewd apex
#

lmfao

swift pumice
#

<@&831776746206265384>

blissful lagoon
unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

blissful lagoon
#

we're not going to help you with that project

slate swan
#

scofflaw fast af 😔

glacial jungle
#

Sorry I didn't know

slate swan
shrewd apex
#

i mean like lmfao if u hadnt said nuke i was gonna send the code

novel prairie
slate swan
glacial jungle
#

Am new in python

slate swan
#

wha?-

slate swan
novel prairie
glacial jungle
#

R.i.p bro

slate swan
#

if “@“ in msg.content ig?

novel prairie
#
@bot.command()
@commands.is_owner()
async def say(ctx, *, message):
   if '@' in message:
      return await ctx.send("You do not have permission")
   embed=discord.Embed (title= message)
   await ctx.message.delete()
   await ctx.send(embed=embed)```
#

thats the code

shrewd apex
#

ctx.reply smh

novel prairie
#

bruh in the message that says you do not have permission

slate swan
#

then dew it there shrug dont act so dumb no offence

novel prairie
#

idk how

#

like i said im new in dev

slate swan
#

Are you the owner of the bot?

#

Remove the if “@“ in message:

#

And tell what you are trying to do

novel prairie
novel prairie
novel prairie
slate swan
#

Remove if “@“ in message:

novel prairie
#

ok

#

i did

#

know what im doing>

#

?*

cloud dawn
unkempt canyonBOT
#

A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.

Warning

The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.

novel prairie
#

thanks for the help tho

cloud dawn
#

This returns a list of people that got mentioned inside the message.

dull terrace
novel prairie
#

thanks

bronze lark
#

i need help . i trying to make reaction roles but i have syntax error

@bot.event
async def on_raw_reaction_add(payload):
  if message_id == 1001813362189021286:
    guild_id = payload.guild_id
    guild = discord.ulits.find(lambada g : g.id == guild_id, client.guilds)

    if payload.emoji.name == 'statue_of_liberty':
      print('Test')

but this

    guild = discord.ulits.find(lambada g : g.id == guild_id, client.guilds)
                                       ^
SyntaxError: invalid syntax
paper sluice
#

its lambda

hot cobalt
#

And utils not ulits

glacial jungle
#

What's the problem

bronze lark
slate swan
glacial jungle
#

Idk

#

Am new to python can u help me

slate swan
#

Give commands.Bot a variable

cloud dawn
#

Client isn't defined plus no decorator on foo

glacial jungle
#

Bro idk what u sayin

cloud dawn
#

bot=true is depricated

slate swan
glacial jungle
#

So what should I do

slate swan
#

Give a variable to commands.Bot

glacial jungle
#

I swear to my good I don't know what to do

unkempt canyonBOT
#

Hey @glacial jungle! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me

Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!

slate swan
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

slate swan
#

Use this ^ @glacial jungle

glacial jungle
#

Kk

slate swan
#

And remove your bot’s token from it

bronze lark
# hot cobalt And utils not ulits

thx but now when i put reaction nothing happen

@bot.event
async def on_raw_reaction_add(payload):
  message_id = payload.message_id
  if message_id == 1001813362189021286:
    guild_id = payload.guild_id
    guild = discord.utils.find(lambda g : g.id == guild_id, bot.guilds)

    if payload.emoji.name == 'statue_of_liberty':
      print('Test')
bronze lark
#

yeah

slate swan
#

Give commands.Bot a variable

#

bot = commands.Bot. . .

#

And use bot.run(token)

bronze lark
#

bro i have it

slate swan
#

And there’s no decorator before foo as pandabweer said

slate swan
bronze lark
#

oh

#

im sory

slate swan
#

UwU pepeShy

novel prairie
#

no

bronze lark
slate swan
#

Ashley’s here

#
from discord.ext import commands
import discord

bot = commands.Bot(command_prefix="uwu", intents=discord.Intents.default())

bot.run("token")

pepe_exit

novel prairie
#

"uwu" 💀

bronze lark
#

xd

slate swan
#

Pandabweer be typing an essay

novel prairie
#

not here 💀

bronze lark
#

The UwU bot
uwuhelp - show this message

slate swan
slate swan
slate swan
#

Oh nvm

glacial jungle
slate swan
glacial jungle
#

Am stupid ik ik

bronze lark
#

b r u h

glacial jungle
#

Am not good at python am a newbie

bronze lark
novel prairie
glacial jungle
#

I don't want u to know my shit

#

Wait

novel prairie
#

use this

#
token=("your bot token")
bot.run(token)```
slate swan
#

Pandabweer lemon_thinking

bronze lark
#

and you must put it up

slate swan
bronze lark
#

btw

slate swan
#

Imagine defining a bot without prefix 💀

glacial jungle
glacial jungle
bronze lark
slate swan
novel prairie
#

YOUR TOKEN

bronze lark
#

XD

novel prairie
#

CHANGE IT FAST

swift pumice
novel prairie
#

LMAO

slate swan
#

I think I'll create a walkthrough for setting up a basic bot if there still isn't one yet pepe_exit

glacial jungle
#

It's not a real toke

novel prairie
#

DELETE THATTTTTTTTT

novel prairie
bronze lark
#

i have screen xd

cloud dawn
# glacial jungle So what should I do
import asyncio

from discord import Intents
from discord.ext.commands import Bot, Context

class BasicBot(Bot):
    def __init__(self) -> None:
        super().__init__(
            intents=Intents.all(),
            command_prefix="!",
            help_command=None
            )

     async def on_ready(self) -> None:
         print("Ready")


bot = BasicBot()

@bot.command(name="test")
async def foo(ctx: Context) -> None:
    await ctx.send("Hello!")

async def main() -> None:
    async with client:
        await client.start("token")

if __name__ == "__main__":
    asyncio.run(main())
``` there you go a simple bot
bronze lark
#

XD

slate swan
#

And make it a stickied message here

eternal fox
glacial jungle
slate swan
# slate swan True true

nvm, just as I thought about the work I'll have to do 💀 dropped the idea in under 10 seconds kek

swift pumice
novel prairie
slate swan
bronze lark
slate swan
#

That’s it ezy tutorial

slate swan
glacial jungle
cloud dawn
#

You basically only need a database.

slate swan
swift pumice
slate swan
#

Like me 💀

swift pumice
glacial jungle
#

Am already learning ik

swift pumice
#

🗿💀

slate swan
novel prairie
#
@bot.command()
@commands.is_owner()
async def say(ctx, *, message):
   embed=discord.Embed (title= "**You dont have the permission to mention someone**") 
   if '@' in message:
      return await ctx.reply(embed=embed)
      await ctx.message.delete()
   embed=discord.Embed (title= message)
   await ctx.message.delete()
   await ctx.send(embed=embed)``` how can i make the bot delete the message that has a mention on it?
swift pumice
slate swan
cloud dawn
#

Sure every project can be done in one file.

glacial jungle
#

Tf do I do now

swift pumice
#

imagine not putting everything in one file

slate swan
cloud dawn
ivory wraith
#

with discord.py buttons, how should you get the person who clicked the button, as a member?

bronze lark
#
@bot.event
async def on_raw_reaction_add(payload):
  message_id = payload.message_id
  if message_id == 1001813362189021286:
    guild_id = payload.guild_id
    guild = discord.utils.find(lambda g : g.id == guild_id, bot.guilds)

    if payload.emoji.name == 'statue_of_liberty':
      print('Test')

my code don't print
without error

slate swan
glacial jungle
novel prairie
slate swan
#

what is happening and why is everyone getting indentation errors

slate swan
slate swan
#

“Everyone”

glacial jungle
#

Can u fucking help me

glacial jungle
#

Joe mama

eternal fox
slate swan
novel prairie
glacial jungle
slate swan
novel prairie
#

lmao

glacial jungle
slate swan
#

ashley what the hellpithink

bronze lark
eternal fox
slate swan
slate swan
slate swan
slate swan
slate swan
#

I mean we can name the variable anything

fast musk
#

Bot gives you everything that Client does, plus the command extension

slate swan
#

esoteric code go brrrr

slate swan
fast musk
#

Client would be for very simple polling or something

#

Honestly I don't know why you would want it

ivory wraith
#

i mean i'll probably not use it but thanks

slate swan
novel prairie
slate swan
#

It’s just that bot feels good

#

Dk why 💀

fast musk
#

Oh, I thought they meant the difference between Client and Bot

#

idgaf what you name it. Call it self if you are evil enough

slate swan
#

well, I just wanted to get/fetch a member ASakashrug and I didnt specify and bot instance so I used the interaction's client, soooooooo

#

it was just an example

#

I’ll call it Ashley in my next bot

novel prairie
slate swan
slate swan
novel prairie
fast musk
#

reads like boobs to me

slate swan
#

It is

fast musk
#

giggity

slate swan
#

quagmire

novel prairie
#

(.) (.) boobs

velvet compass
#

What the fuck is this channel right now

novel prairie
slate swan
slate swan
eternal fox
novel prairie
#

lmao

paper sluice
novel prairie
velvet compass
eternal fox
paper sluice
slate swan
slate swan
slate swan
velvet compass
unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @novel prairie until <t:1658957870:f> (5 hours and 59 minutes).

velvet compass
#

!mute 981627297993998379 6h take a break and re-read the code-of-conduct

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @glacial jungle until <t:1658957883:f> (5 hours and 59 minutes).

slate swan
#

💀 ** **

eternal fox
#

Hmm anyways

slate swan
#

wow

#

ill take a break as well brad, i need to eat breakfast 🙇‍♂️

#

Now they dm me

paper sluice
slate swan
#

ok

eternal fox
#

i has a question,what command should i add for my bot like im running out of ideas

paper sluice
eternal fox
fast musk
#

What's the purpose of your bot?

slate swan
#

Oh hi robin

fast musk
#

The world does not need any more multi-purpose bots haha

sick birch
eternal fox
#

or all in one purpose

fast musk
#

oof. Alright. Do you have autorole?

slate swan
fast musk
#

That is usually a very highly requested feature

slate swan
#

I have one in my bot for dm bot

eternal fox
fast musk
#

A role of the admin's choosing yes

slate swan
fast musk
#

and perhaps multiple roles

slate swan
#

Or a verification system

eternal fox
eternal fox
fast musk
#

verification systems are lame. Discord is going to do this out-of-the-box soon enough. Not worth the effort

eternal fox
slate swan
#

Then go with economy

cloud dawn
#

n o

eternal fox
eternal fox
fast musk
#

If you are truly bored go on fiverr and make some bots for others

#

the pay is absolutely crap though

sick birch
slate swan
#

Or go touch grass if you haven’t

eternal fox
slate swan
slate swan
slate swan
eternal fox
slate swan
#

Watch a tutorial on how to touch grass

#

Will be helpful

eternal fox
slate swan
eternal fox
#

Oh and also if im gonna separate my bots commands to another file,how can i do that without rewriting it into cogs ?

torn sail
eternal fox
slate swan
#

Yup you can

#

async def your_command(ctx, user, review, quality, speed):

slate swan
#

Who’s your customer lemon_thinking

hybrid fjord
#

are buttons in dpy 2?

paper sluice
#

yes

hybrid fjord
#

link doc plz

paper sluice
#

!d discord.ui.Button

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.
hybrid fjord
#

cheers

#

either surround each parameter with " " during command usage or have * after the first non-multi-argument parameter

#

or have it with 1 parameter and use split with a comma or something

bronze lark
#

hi i need payload and member

@bot.event
async def on_member_join(member, *, payload):
  member= payload.member
  guild = member.guild
  role = discord.utils.get(guild.roles, name='Člen')
  await member.add_roles(role)
TypeError: on_member_join() missing 1 required keyword-only argument: 'payload'
patent bluff
#

Hey, i need some help with the ban. Im using @client.event in on_message() and my code wont work. Here is it: ```py
if message.content.startswith("&ban"):
banargs = message.content.split(" ")

    if len(banargs) == 1:
        await message.channel.send("Gib einen User ein!")

    if len(banargs) == 2:
        member: Member = discord.utils.find(lambda m: args[1] in m.name, message.guild.members)

        await member.ban()
sick birch
bronze lark
#

but i need payload

sick birch
sick birch
bronze lark
#

member= payload.member
guild = member.guild

sick birch
#

The member is already provided

#

You don’t need any sort of payload for that

bronze lark
#

oh

#

burh

#

i need study docs

#
@bot.event
async def on_member_join(member):
  guild = member.guild
  role = discord.utils.get(guild.roles, name='Člen')
  await member.add_roles(role
sick birch
#

Always a good idea

bronze lark
#

so like this

sick birch
#

You’re missing the last closing parenthesis but yeah

bronze lark
#

yeah ik

#

thx

#

its work +rep

patent bluff
#

?

slate swan
#

If you have the reason param

vocal snow
#

Discord has a built-in ban command fyi

patent bluff
#

Thanks

slate swan
slate swan
vocal snow
#

People still implement their own for some reason

slate swan
#

yuh

#

You can use reason inside .ban()

#

Why just make an embed to show the reason

#

Without actually using it

sick birch
#

Before you start, don’t use discord-py-slash-commands or any of those

#

I’m guessing you may have done a YouTube or google search and that’s what pops up

wraith wing
#
discord.ext.commands.errors.CommandRegistrationError: The command help is already an existing command or alias```.  There is no help command but there seems to be
wraith wing
sick birch
#

!d discord.ext.commands.Bot.remove_command

unkempt canyonBOT
#

remove_command(name, /)```
Remove a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") from the internal list of commands.

This could also be used as a way to remove aliases.

Changed in version 2.0: `name` parameter is now positional-only.
sick birch
#

I apologize for my fat fingers

#

Like <t:1658940000:R>?

#

<t:TIMESTAMP:FORMAT>

wraith wing
bronze lark
#

i need to stop command when is seconds none.

@bot.command()
async def slowmode(ctx, seconds: int=None):
  if seconds == None:
    embed= discord.Embed(title='Error', description='Použí `!!slowmode <sekudy na spomalení>`', color =0x552E12)
    await ctx.send(embed=embed)
  await ctx.channel.edit(slowmode_delay=seconds)
  await ctx.send(f"Set the slowmode delay in this channel to {seconds} seconds!")
#

can anybody help?

bronze lark
#

it is

glad cradle
#

so what's the problem?

white aurora
#

👀

glad cradle
#

ohh you can do return await ctx.send.... in the first condition

#

or write an else block

slate swan
#

!d discord.utils.format_ft

#

!d discord.utils.format_dt

unkempt canyonBOT
#

discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.10)") for presentation within Discord.

This allows for a locale-independent way of presenting data using Discord specific Markdown...
quaint scaffold
#

!d discord.PublicFlags.all

unkempt canyonBOT
#
Noooooo!!

No documentation found for the requested symbol.

quaint scaffold
#

There we go

#

!d discord.Member.public_flags

unkempt canyonBOT
#

property public_flags```
Equivalent to [`User.public_flags`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User.public_flags "discord.User.public_flags")
quaint scaffold
#

Do you have jishaku?

#

Try running ctx.author.public_flags.all()

slate swan
#

in the ban command, how do I see if the bot role is above that of the person I want to ban?

sick birch
slate swan
#

the bot sends the message that the person was banned even though they were not

sick birch
#

It'd be helpful to see any current code

slate swan
#

my bad

#

Evening all, sorry i am back 😄 I was wondering if anyone can help as I have pretty much brain farted now, https://paste.pythondiscord.com/cobagayila

in my on_raw_reaction_add, I thought with it being a user event, it would need to start of with payload.user_id but I thought wrong and not sure how I am even suppose to start this thing off. I have read over the docs, and didn't think I would need anything else but seem to be wrong; https://discordpy.readthedocs.io/en/stable/api.html?highlight=payload#discord.RawReactionActionEvent,

I usually add in print with some jibberish in to make sure it goes to each step or let me traceback tell me if anything is wrong, but neither are working so yeh I feel as though I'm just not doing the basics right

sick birch
slate swan
#

Yeah

sick birch
#

Cool so the command works, I'm guessing the event is what's not working?

slate swan
#

Yep, well more like I just dont know how to start it anymore, i must have tried so many different ways now and thought in the end with it being a user event, the only payload attribute i need is uder_id

sick birch
#

So:

if game_roles.get(str(payload.emoji)):
  role = game_roles.get(str(payload.emoji))
  # give the member the `role` role
slate swan
#

And this is why getting a second pair of eyes on things is always a good thing in the tech/dev world, I'll give it a whirl and see how I get thank you so much.

sick birch
#

Yup. Also keep in mind this approach would give the user a role if they reacted with the right emoji on any message. You'll want to add an if statement that checks if the message the reaction is coming from is the same one you sent in your ReactionRoles command. This should be pretty easy, though, so leave it for the end

vale wing
#

Enable presences intent and check for CustomActivity in member.activities

slate swan
sick birch
#

No problem. Feel free to ping me with any follow up questions you may have

slate swan
#

you can pass in a datetime object to the function and the style desired

from datetime import datetime, timedelta

ft_time = discord.utils.format_dt(datetime.now() + timedelta(minutes=42))
timid briar
#

i have the companyename.txt

snow trench
#

Guys

#

How can I make a bot that play music from Spotify?

timid briar
#

yep

#

soooooo any solu

slate swan
#

Is it CompanyeName or CompanyName? The error is obvious, it can't find the file/directory your looking for.

timid briar
#

nop

slate swan
#

Whats the full path to your bot main file? Can you grab it as text, not an image?

#

the slashes have to be from right to left

#

no problem, you'll get a unicode escape error😅

timid briar
#

ok wait

#

yea ik

#

SyntaxError: f-string expression part cannot include a backslash3176vibaeno

snow trench
#

How do you learn to how to make a discord bot with discord.py?

vale wing
#

You can just put it into a variable then put the variable into string

#

Although using absolute paths for project will make it break after renaming some parent folder or moving to other machine

#

So use relative 😉 👌

#

Just create good project structure

#

He's having issues with adding python to PATH?

#

Then what

vale wing
snow trench
#

guys guys

#

where can i install youtube_dl?

#

what i need to do?

vale wing
#

!ytdl @proven shale we don't help with anything related to it

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)
snow trench
#

can i dm you?

cobalt summit
#

I'm trying to make a discord bot that web scrapes a random Wikipedia article, but after you try it once, it repeats the same thing

My code:
#Importing
import requests
import webbrowser
from bs4 import BeautifulSoup
import discord
import random
#-----------------------------

#Var's
TOKEN = '#Not gonna show'

wiki_url = "https://en.wikipedia.org/wiki/Special:Random"

article_page = requests.get(wiki_url)

client = discord.Client()

soup = BeautifulSoup(article_page.text, "html.parser")

article_title = soup.find(id='firstHeading')
#---------------------------------------------------------------------------------

#Func's
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
username = str(message.author).split('#')[0]
user_message = str(message.content)
channel = (message.channel.name)
print(f'{username}: {user_message} ({channel})')

if message.author == client.user:
    return

if message.channel.name == 'bot':
    if user_message.lower() == 'hello wikibot':
        await message.channel.send(f'Hello {username}!')
        return
    elif user_message.lower == 'bye wikibot':
        await message.channel.send(f'See you later {username}!')
    while user_message.lower() == '!random wiki':
        response = f'The title of the Random article is:, {article_title.string}'
        await message.channel.send(response)
        break

#---------------------------------------------------------------------------------

client.run(TOKEN)

vale wing
#

Also doesn't wikipedia have the API? Like it's easier to use than scraper imo

cobalt summit
#

As the command

vale wing
#

Maybe it was added in a 2.0

#

!d discord.utils.format_dt

unkempt canyonBOT
#

discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.10)") for presentation within Discord.

This allows for a locale-independent way of presenting data using Discord specific Markdown...
vale wing
#

Yeah

#

You can make a function by yourself, it looks like this

unkempt canyonBOT
#

utils/utils.py lines 41 to 42

def datetime_to_timestamp(dt: datetime, modifier: str = "F") -> str:
    return f"<t:{int(dt.timestamp())}:{modifier}>"```
vale wing
#

Not very complicated as you can see

daring valley
#

i am installing the discord slash module
but when i try to
import discord_slash
it says that there is no such module
did the module name change or something??