#Basic Pycord Help (Quick Questions Only)

1 messages · Page 35 of 1

raw gust
#

I have the same problem.
First option for me was to use the "functional interface" mentioned in the doc string of the slash command class.
Sadly i could not find any reference for this in the docs.
On this discord noone helped me about this topic either.

My only real sulotion to this until now is to create the discord slash command class manually, then add it to the slash commands of the bot manuelly. This works, but is not recommended at all. Atleast the docs say so, but the doc string also says something about an "functional interface" so i am not sure to what degree i should trust the docs.

In cogs it may be possible to import another file with a function which provides the guild ids and on every change of guilds you reload the cog. I did not test this tho.

limber urchin
#

The guild ids parameter is meant as a way to statically set one or a few servers to use while debugging, or to only register a command in those few servers. It's not really meant to be dynamically defined or changed during runtime of your bot anyways.

raw gust
#

Its not meant sure. But what if you want it anyway? Is there any other solution?

limber urchin
#

I don't see why you would ever want to dynamically set it, or change it

kindred moon
#

Personally, for creating test environments in which the bot can be tested before its features go live globally.

limber urchin
#

Sure, but why can't you just manually set the guild ID in the code directly?

kindred moon
kindred moon
# limber urchin Sure, but why can't you just manually set the guild ID in the code directly?

I can do that theoretically, surely, but the code's going to live in a cloud service that I'd preferably just start and provide some arguments rather than have to go in and change the code every time before running it. It's easier to parse --env dev when starting the bot through the command line than having to go through all my cogs and swap out the guild_ids=[..., ..., ...], even when 'search and replace'ing.

raw gust
limber urchin
kindred moon
#

That's something I haven't been before, that may just be the easy solution to my convoluted setup 😄

raw gust
limber urchin
#
if self.debug == True:
      super().__init__(..., debug_guilds=[1231231231231233,])
else:
      super().__init__(...)

Here's how I've personally done it

raw gust
#

If you only use it for debug guilds the suggested way is definitly better in any way.

#

Sadly i still dont know whats meant by "functional interface" in the slash command class doc string sadness

kindred moon
kindred moon
kindred moon
# limber urchin Correct

Wonderful, cheers! It confused me because I did not see debug_guilds as a possible Attribute in the docs but I just wasn't looking right 🤦

silver moat
#

same as normal

young bone
#

why do you add name="" to the slash commands?

silver moat
young bone
#

I ask because you use discord.Interaction with the slash_command

#

ctx.respond returns an interaction but it is not really recommended to use discord.Interaction

#

is the command in the same class?

#

it is weird

#

have you tried to restart it?

silver moat
#

where is autoreact defined

fervent cradle
#

Is a cog listener the same as a bot event?

foggy mortar
#

yes

fervent cradle
#

Okay

#
async def on_application_command_error(ctx, error):
    if isinstance(error, discord.ext.commands.MissingRequiredArgument):
        await ctx.respond(f'Wrong Params')``` Why isnt this code working? (just dosent respond) and yes i did it different to what i was shown.
limber urchin
#

How would you have a missing required argument in an application command?

foggy mortar
#

how can you make it so it will run a command when you press a button?

#

like when you class the button is there a run command method

foggy mortar
#

no thats not what i want

#

i want is you defined a command and you want to run it when someone press a button

silver moat
foggy mortar
#

oh ok 😂

spare shell
#

sorry im a beginner lol

#

need transactionHash

foggy mortar
#

wow 😂

spare shell
foggy mortar
#

i forgot to add self

spare shell
foggy mortar
#

no ofc :p

#

i dont even know what is that :)

proud mason
foggy mortar
#

whats the second idea that also work

silver moat
#

make a helper function that takes an interaction object and does the same function. use that helper function in the command and the button

foggy mortar
#

ok

proud mason
#

well what is AttributeDict?

silver moat
proud mason
# spare shell need transactionHash

you can do somedict['transactionHash'] to get it. where somedict is the name of that dict

but if AttributeDict is what I think it is, you will have to do somedict.transactionHash

foggy mortar
proud mason
#

uhhh

spare shell
proud mason
#

thats not supposed to happen 💀

spare shell
proud mason
#

idk what AttributeDict is

#

possible to find that out?

spare shell
#

ill try to dig into it

proud mason
spare shell
#

thanks for the help tho!

proud mason
#

lol np!

spare shell
silver moat
#

you can turn it into a dictionary with dict()

spare shell
silver moat
#

oh it's a bson

spare shell
spare shell
long torrent
#
    @commands.slash_command(name="removeapp", description="Remove an app from the database", guild_only=True)
    @option("appname", description="Name of the app to remove", required=True)
    async def removeapp(self, ctx, appname: str):
        await ctx.defer()
        role = discord.utils.get(ctx.guild.roles, name="Moderator")
        if role in ctx.author.roles:
            if DatabaseManager.GetAppByName(appname) != None:
                try:
                    DatabaseManager.RemoveAppFromCategory(appname)
                    await ctx.interaction.followup.send("Removed `" + appname + "` from Database") 
                except Exception as e:
                    print(e.with_traceback(e.__traceback__))
                    await ctx.interaction.followup.send(e)
            else:
                await ctx.interaction.followup.send("The app you entered does not exist")
        else:
            await ctx.interaction.followup.send("You do not have permission to use this command!")

does anybody have an idea as to why this code responds with "The application did not respond" sometimes, it seems to not happen after i wait a few seconds after the bot is started.

fervent cradle
long torrent
# long torrent ```py @commands.slash_command(name="removeapp", description="Remove an app f...

Heres the error code btw:

Ignoring exception in on_interaction
Traceback (most recent call last):
  File "/pufferpanel/.local/lib/python3.11/site-packages/discord/commands/core.py", line 124, in wrapped
    ret = await coro(arg)
          ^^^^^^^^^^^^^^^
  File "/pufferpanel/.local/lib/python3.11/site-packages/discord/commands/core.py", line 976, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "/pufferpanel/cogs/AppCommands.py", line 98, in removeapp
    await ctx.defer()
  File "/pufferpanel/.local/lib/python3.11/site-packages/discord/interactions.py", line 655, in defer
    await self._locked_response(
  File "/pufferpanel/.local/lib/python3.11/site-packages/discord/interactions.py", line 1090, in _locked_response
    await coro
  File "/pufferpanel/.local/lib/python3.11/site-packages/discord/webhook/async_.py", line 215, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction```
young bone
#

just do ctx.respond()

long torrent
long torrent
fiery tiger
#
    @commands.Cog.listener()
    async def on_member_remove(self, member):
        async for i in member.guild.audit_logs(
            limit=1,
            after=datetime.datetime.now() - datetime.timedelta(minutes=1),
            action=disnake.AuditLogAction.kick,
        ):
            oauth_response = await OAuth2User.get(id=member.id)
            add_to_guild(oauth_response.token, member.guild.id, member.id)
#
class OAuth2User(Model):
    """Oauth2 User."""

    id: str
    token: str
    expires_in: int

db model

#
from aiohttp import ClientResponse, ClientSession
from loguru import logger
import requests

from spooky.env import appID, appSecret

APIEndPoint = "https://discord.com/api/v10"


async def fetch_me(token: str) -> ClientResponse:
    headers = {
        "Content-Type": "application/x-www-form-urlencoded",
        "Authorization": f"Bearer {token}",
    }

    async with ClientSession() as session:
        return await session.get(f"{APIEndPoint}/oauth2/@me", headers=headers)


async def exchange_code(code: str) -> ClientResponse:
    data = {
        "client_id": appID(),
        "client_secret": appSecret(),
        "code": code,
        "grant_type": "authorization_code",
        "redirect_uri": "url",
    }
    logger.debug(f"Using payload: {data}")
    headers = {"Content-Type": "application/x-www-form-urlencoded"}

    async with ClientSession() as session:
        return await session.post(
            f"{APIEndPoint}/oauth2/token", data=data, headers=headers
        )


def add_to_guild(access_token, userID, guildID):
    url = f"{APIEndPoint}/guilds/{guildID}/members/{userID}"
    botToken = "token of the bot"
    data = {
        "access_token": access_token,
    }
    headers = {"Authorization": f"Bot {botToken}", "Content-Type": "application/json"}
    response = requests.put(url=url, headers=headers, json=data)
    print(response.text)
#

i suppose tokens are not being saved?

#

based on the error

#

Maybe tortoise is incompatible with this version of FastAPI?????

#

could that be an error?

foggy mortar
#

@discord.slash_command(cooldown=commands.Cooldown(rate=1,per=2)) returned TypeError: Cooldown must be a an instance of CooldownMapping or None. but in the docs it says cooldown is a Cooldown object

#

or the cooldown is just float?

foggy mortar
#

its mainly the if isinstance(error, discord.ext.commands.MissingRequiredArgument): part

mortal junco
#

you guys know what hte easiest way to import time is

#

Like if i wanted to have the bottom of a embed say

#

Ran by (User) at (Time)

full basin
#

The library has a built in one

#

discord.utils.utcnow()

harsh canyon
#

how do i save the audio from start_recording to a file?

long torrent
#

Why do I get The application did not respond for the first few commands after starting my bot with the bot saying it cant find the interaction, after i run a few commands it works.

foggy mortar
#

cuz it need time to connect

long torrent
foggy mortar
#

oh um

#

maybe its ur discord

near hollow
#

So I want to create a discord autocomplete with a list of roles from my db but I can't pass anything into the function from within the command. Any suggestions?

fervent cradle
#

Getting this error. Im using folder from github

silver moat
fringe socket
#

You shouldn't constantly ping people to help you. Unless they are ok with it, that is.

fervent cradle
silver moat
#

run kill 1 in the shell and try again

harsh canyon
#

how do i save the audio from start_recording to a file?

plush meadow
#

would anyone happen to know why await role.edit() is freezing my function?

silver moat
plush meadow
#

i know that much

#

i was more so wondering why after 10 minutes we're still waiting for completion

plush meadow
#

i thought the same

#

is there some sort of rate limit? I am doing it every 5 minutes

#

either way, I let it sit for about an hour and still no cigar

silver moat
#

there was a ratelimit issue earliar

#

try reconnecting

plush meadow
#

you mean restarting the bot?

silver moat
#

sure

plush meadow
#

yeah i did after an hour

#

she's just stuck

#
print('hi')
await role_objects[0].edit(name=f'1st Richest - [{top3[0][1]:,} Coins]', hoist=True)
await role_objects[1].edit(name=f'2nd Richest - [{top3[1][1]:,} Coins]', hoist=True)
await role_objects[2].edit(name=f'3rd Richest - [{top3[2][1]:,} Coins]', hoist=True)
print('hi2')
#

hi hits, hi2 never hits no matter how long i wait

fervent cradle
fervent cradle
#

What is this called?

limber urchin
#

An embed?

proud mason
#

A reply to another message?

peak chasm
#

Excuse me, is there a channel to consult about other APIs? I would not like to interfere with meaningless doubts

fervent cradle
proud mason
proud mason
proud mason
peak chasm
#

interesting, and that has to be confirmed by some correct admin?

proud mason
peak chasm
#

I hope it is accepted 🥺

peak chasm
#

How did I never find out? 😧

peak chasm
#

:'v 🥺

limber urchin
#

That is to set the color of the embed to the same color as the background of it

peak chasm
#

Ohhh

#

Oki

short hearth
#

yo
how to get user id in select menus

proud mason
short hearth
spice oyster
#

If I want to customize an embed link, how can I automatically get the text that appears? I only want to change the author and its icon by crafting the embed and then sending it.

full basin
spice oyster
spice oyster
#

How does Discord get that value? There has to be a way to get it, hopefully working with Python.

spice oyster
merry briar
#

For the slash command to stretch the execution time a little, there is ctx.defer(). And what is there for the button?

raw gust
#

same thing

#

interaction.response.defer() is it i think. But i cant check it im on my phone atm

raw gust
merry briar
merry briar
raw gust
#

great 👍

spice oyster
long torrent
#

Is there a reason my defered command is still throwing an unknown interaction error?

#
    @commands.slash_command(name="countapps", description="Count the number of apps in a category")
    @option("category", description="Category to count apps in", required=True, choices=[discord.OptionChoice(name=category) for category in Categories])
    async def countapps(self, ctx, category: str):
        await ctx.defer()
        DBCategory = emoji.replace_emoji(category, replace='').lstrip().rstrip()
        try:
            Count = DatabaseManager.CountAppsInCategory(DBCategory)
            if Count is None:
                await ctx.interaction.followup.send("There are no apps in this category.")
            else:
                if Count == 1:
                    await ctx.interaction.followup.send("There is " + str(Count) + " app in " + category)
                else:
                    await ctx.interaction.followup.send("There are " + str(Count) + " apps in " + category)

        except Exception as e:
            await ctx.interaction.followup.send(e)
spice oyster
long torrent
#

ok

long torrent
#

Traceback:

  File "/pufferpanel/.local/lib/python3.11/site-packages/discord/commands/core.py", line 124, in wrapped
    ret = await coro(arg)
          ^^^^^^^^^^^^^^^
  File "/pufferpanel/.local/lib/python3.11/site-packages/discord/commands/core.py", line 976, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "/pufferpanel/cogs/AppCommands.py", line 132, in countapps
    await ctx.defer()
  File "/pufferpanel/.local/lib/python3.11/site-packages/discord/interactions.py", line 655, in defer
    await self._locked_response(
  File "/pufferpanel/.local/lib/python3.11/site-packages/discord/interactions.py", line 1090, in _locked_response
    await coro
  File "/pufferpanel/.local/lib/python3.11/site-packages/discord/webhook/async_.py", line 215, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/pufferpanel/.local/lib/python3.11/site-packages/discord/bot.py", line 1114, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "/pufferpanel/.local/lib/python3.11/site-packages/discord/commands/core.py", line 375, in invoke
    await injected(ctx)
  File "/pufferpanel/.local/lib/python3.11/site-packages/discord/commands/core.py", line 132, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction```
spice oyster
long torrent
#

rip

#

im on the latest version of discord on pc so ik its not a version issue as described here

young bone
spice oyster
spice oyster
long torrent
#

Saw that, will that work with defer? Do I need to do followup.edit_message after responding for the first time?

#
    @commands.slash_command(name="countapps", description="Count the number of apps in a category")
    @option("category", description="Category to count apps in", required=True, choices=[discord.OptionChoice(name=category) for category in Categories])
    async def countapps(self, ctx, category: str):
        await ctx.defer()
        await ctx.respond("Please wait...")
        DBCategory = emoji.replace_emoji(category, replace='').lstrip().rstrip()
        try:
            Count = DatabaseManager.CountAppsInCategory(DBCategory)
            if Count is None:
                await ctx.followup.edit_message("There are no apps in this category.")
            else:
                if Count == 1:
                    await ctx.followup.edit_message("There is " + str(Count) + " app in " + category)
                else:
                    await ctx.followup.edit_message("There are " + str(Count) + " apps in " + category)

        except Exception as e:
            await ctx.followup.edit_message(e)```
trying to use this, still doesn't work. I never get the "bot is thinking" msg
young bone
#

to defer it would be ctx.defer()

long torrent
#

I am doing ctx.defer

hallow blaze
#

they have deferred, but they responded after that line

await ctx.defer()
await ctx.respond("Please wait...")
long torrent
#

I was trying to edit that message with a followup because I think my db query is taking more than 3 seconds and I thought you need to respond before those 3 seconds and then follow up

spice oyster
#

After you responded, you have plenty of time to edit.
You don't need to defer if you send an early response.

long torrent
hallow blaze
long torrent
#

ok

long torrent
hallow blaze
#

Oh about that, due to you responding in "Please wait..."

#

after the defer, the thinking goes away

spice oyster
#

Exactly. Choose if you want to defer or not.

#

If you defer, don't reply immediately.

#

If you don't defer, then reply immediately and edit later.

hallow blaze
#

^

long torrent
spice oyster
#

Just use ctx.respond() and the bot will handle followups automatically.

long torrent
#

Will try that

spice oyster
long torrent
#

embed failure

#

nvm lol

#

but still don't know why I get that if im defering

cyan quail
#

either of those could make it take longer than 3 seconds for the defer to be sent at all

long torrent
#

I have gigabit fiber so im not sure why I would be having network issues and I'm not ratelimited so idk

cyan quail
#

oh wait lol

#

change ctx.followup.edit_message to ctx.edit

long torrent
#

yea i'm not using edit anymore, this is my code now:

    @commands.slash_command(name="countapps", description="Count the number of apps in a category")
    @option("category", description="Category to count apps in", required=True, choices=[discord.OptionChoice(name=category) for category in Categories])
    async def countapps(self, ctx, category: str):
        await ctx.defer()
        DBCategory = emoji.replace_emoji(category, replace='').lstrip().rstrip()
        try:
            Count = DatabaseManager.CountAppsInCategory(DBCategory)
            if Count is None:
                await ctx.respond(content="There are no apps in this category.")
            else:
                if Count == 1:
                    await ctx.respond(content="There is " + str(Count) + " app in " + category)
                else:
                    await ctx.respond(content="There are " + str(Count) + " apps in " + category)

        except Exception as e:
            await ctx.respond(content=e)```
cyan quail
#

then yeah idk probably blocking code

#

unless the 2nd line of your command is erroring

long torrent
#

Here's my traceback if that helps:

  File "/pufferpanel/.local/lib/python3.11/site-packages/discord/commands/core.py", line 124, in wrapped
    ret = await coro(arg)
          ^^^^^^^^^^^^^^^
  File "/pufferpanel/.local/lib/python3.11/site-packages/discord/commands/core.py", line 976, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "/pufferpanel/cogs/AppCommands.py", line 132, in countapps
    await ctx.defer()
  File "/pufferpanel/.local/lib/python3.11/site-packages/discord/interactions.py", line 655, in defer
    await self._locked_response(
  File "/pufferpanel/.local/lib/python3.11/site-packages/discord/interactions.py", line 1090, in _locked_response
    await coro
  File "/pufferpanel/.local/lib/python3.11/site-packages/discord/webhook/async_.py", line 215, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/pufferpanel/.local/lib/python3.11/site-packages/discord/bot.py", line 1114, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "/pufferpanel/.local/lib/python3.11/site-packages/discord/commands/core.py", line 375, in invoke
    await injected(ctx)
  File "/pufferpanel/.local/lib/python3.11/site-packages/discord/commands/core.py", line 132, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction```
cyan quail
#

then yeah you're taking too long to defer

#

so something in your bot is stalling the command

indigo badger
#

I am trying to move code over to another file but when I do it all unindents is there a way I can copy and paste the code without lines of code unindent?

cyan quail
#

that shouldn't be happening... are you using an IDE?

indigo badger
long torrent
indigo badger
#

I have to update the code.

long torrent
cyan quail
indigo badger
long torrent
#

during the first 10 seconds of the bots lifespan

cyan quail
#

have you overridden any events?

#

wait, what about after those 10 seconds?

indigo badger
fervent cradle
cyan quail
#

on_command_error

long torrent
indigo badger
#

So I upload the files

cyan quail
#

if it's just during the first 10 seconds then you can ignore it

fervent cradle
indigo badger
#

add the code that I make on my alpha to the files.

long torrent
#

k

cyan quail
#

your bot probably hasn't hit the ready state yet

fervent cradle
#

probably should've relieased that

indigo badger
#

And my problem?

cyan quail
#

even if your bot is offline the commands can show up on discord so

long torrent
cyan quail
#

so it's in the "first 10 seconds" and after that it's consistently fine?

cyan quail
# indigo badger And my problem?

idk yours is weirdly specific, copy-pasting doesn't remove indents normally so that's an issue with whatever web editor your host uses

long torrent
#

i havent had the bot running for a while yet so im not sure if its going cause an issue if i leave it running, but if i can just ignore it then I'll just do that ig lol

cyan quail
#

typically hosts provide ftp info so you can use a client to connect and manage/edit files

#

i'd say ignore it but look into it again if it keeps happening after your bot's been up for a while

#

(also if you haven't already, switch to a DB library that's async)

indigo badger
#

Who me?

long torrent
indigo badger
#

Not sure if there are any others.

grizzled sentinel
young bone
#

you should use a db that support async

grizzled sentinel
#

Asyncpg as a wrapper for postgres i should say

grizzled sentinel
young bone
#

I use a json but my bots are not at a huge server

long torrent
#

neither are mine, i have a server at my house lol

young bone
cyan quail
#

both asyncpg and AIOPG would work

#

just look into them and their docs and see which would suit your needs if you plan on migrating

long torrent
fervent cradle
#

How can i check for if someone has ran an owner ONLY command and isnt the owner?

sand nebula
#

Hello, im trying to retrieve a list of current scheduled events on the server, but I cant get the function to work, any direction?

solemn idol
#

How do I print my message.content over multiple embed fields if my message.content is 2000 characters long, I know the max is 1024 per field, so I was wondering how I could spread it over multiple embed fields, and if its just under 1024 just put it into 1 field.

sand nebula
full basin
#

You provided nothing of what I asked for.

sand nebula
#

`import discord
import os # default module
from dotenv import load_dotenv

load_dotenv() # load all the variables from the env file
bot = discord.Bot()

@bot.event
async def on_ready():
print(f"{bot.user} is ready and online!")

@bot.slash_command(name = "hello", description = "Say hello to the bot")
async def hello(ctx):
await ctx.respond("Hey!")

@bot.slash_command(name = "events", description = "Check all events")
async def events(ctx):
property scheduled_events

bot.run(os.getenv('TOKEN')) # run the bot with the token`

Im using a basic setup, and trying to use a slash command for the fetching of the events on the server, but since I cant access the function I cant run it

#

and according to the docs, they say to use this property scheduled_events

spare shell
#

rn i have discord.ApplicationContext

long torrent
#

Remove the print statements in your code, wallet is the application context object, if you want something specific from the app context you need to specifiy it when printing

spare shell
long torrent
#

Ic

young bone
#

ctx.respond()

long torrent
#

Wallet is the ctx

#

I believe

spare shell
#

ye

#

it wrks

young bone
#

oh

#

nvm

spare shell
#

it just sends it encoded

#

i just need it too be plain txt tho

long torrent
#

Is there a specific value in wallet you want

full basin
long torrent
#

Because wallet is an object

spare shell
long torrent
#

Wallet: "<object>"

#

What value are you trying to get, because just putting wallet will only give you the application context object, same as if you did print(ctx) on a command

spare shell
#

the str

#

a string

long torrent
#

What is that string supposed to be, like if you could have it return correctly what would it say.

long torrent
#

Ah ok

#

So are you storing those somewhere right now?

spare shell
#

ye

#

in a db

full basin
#

Why is wallet your context

spare shell
long torrent
#

It should be ctx

spare shell
#

ok

long torrent
#

What are you using for your db, like an actual database, a dictionary, or like a json file.

full basin
#

I mean. The name doesn't matter.

full basin
#

My question is, why you're treating it as a wallet

#

When it's not

long torrent
spare shell
#

and i changed it back to ctx

full basin
#

If you're supposed to store this thingy. Shouldn't you take an argument of it that the use provides?

long torrent
long torrent
#

Where is that dict

spare shell
#

it adds it to the db n stuff fine

long torrent
#

I'm guessing x is your reference to your db?

spare shell
#

yes

long torrent
#

So do you need to take the wallet address as a parameter?

spare shell
#

yep

long torrent
#

Then add , wallet: discord.Option(str) to uploadwallet

#

async def uploadwallet(self, ctx: discord.ApplicationContext, wallet: discord.Option(str)):

#

And put from discord import Option below import discord in your file

spare shell
#

are a goat

#

tysm fam

#

works perfect now!

#

and just to fully understand what happend i was an idiot and needed a 2nd pram to register the str?

fervent cradle
#

How can i respond with smth like your not owner

hallow blaze
fierce hazel
#

How do I add this command to my cog? I understand there is a cog parameter for the slash_command decorator, but it confuses me..

spare shell
# fierce hazel How do I add this command to my cog? I understand there is a `cog` parameter for...
import discord
import random
from discord.ext import commands

responses = ["As I see it, yes.", "Ask again later.", "Better not tell you now.", "Cannot predict now.", "Concentrate and ask again.",
             "Don't count on it.", "It is certain.", "It is decidedly so.", "Most likely.", "My reply is no.", "My sources say no.",
             "Outlook not so good.", "Outlook good.", "Reply hazy, try again.", "Signs point to yes.", "Very doubtful.", "Without a doubt.",
             "Yes.", "Yes - definitely.", "You may rely on it."]

class Eightball(commands.Cog):

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

    @commands.Cog.listener()
    async def on_ready(self):
        print("Eightball Cog Loaded")

    @discord.slash_command(description="Get your fortune!")
    async def eightball(self, question: str):
        await question.send(random.choice(responses))
        print(question)



def setup(bot):
    bot.add_cog(Eightball(bot))

#

heres a cog u can look thru to get ahold of them

proud pagoda
fierce hazel
#

thank you!

proud pagoda
#

You're welcome 🙂

rare ice
#

BRUH MY DISCORD DOESNT SCROLL DOWN

#

It showed that as the latest message

#

anyway

spice oyster
#

Don't worry. hehehe

analog crest
#

I keep getting invalid webhook token recently when trying to use a command, is there a reason why this is happening?

analog crest
young bone
#

oh

cyan quail
#

if you're getting invalid token then either you're taking too long to respond or you're responding to an interaction twice

analog crest
#

it takes about 2 seconds or something though, probably the latter but i don't think i responded twice

ripe zodiac
#

Is there any ways to give someone a role without running the blocking bot.run()? Like login with the discord key then give the role and log out I guess

fluid tusk
#

can i pass something into a view object like

    await ctx.respond("This is a button!", view=MyView(my_var))```?
cyan quail
undone mulch
#

I'm getting a random

discord.commands.errors.ApplicationCommandInvokeError: Application Command raised an exception: KeyError: 'lastSpun'```

In my application command.
#

It isn't showing me where the error is coming from. How do I find out?

#

I'm very confused.

rare ice
undone mulch
#

Thanks @rare ice

#

Do you know this error to

if time.time() - lastSpun > 86400:```

I'm trying to check if it's been 24 hrs so I'm using time.time()
#

lastSpun is the last time logging via time.time() they spun the wheel

rare ice
#

What error

undone mulch
#

Is the math I did correct? Current time - past time and checking if that is greater than 86400 seconds

#

For once/day cooldown

limber urchin
#

That depends on what lastSpun is

undone mulch
#

its just time.time() like a = time.time()

limber urchin
#

Then that should work

#

well it depends on how the entire logic of the command is set up, where are you storing this "lastSpun"?

harsh dust
#

How do I edit role permissions for a channel?
I tried this but it doesn't work

role = discord.utils.get(self.bot.SERVER.roles, name="Member")
perms = discord.PermissionOverwrite(read_messages=True, read_message_history=True, send_messages=True)
await channel.set_permissions(role, reason="Not a bid-based auction.", permissions=perms)
boreal dust
#

try something like overwrites

#

should be {}

fallen cove
#

how do you fix the 50001 Missing Access error

fervent cradle
#

Hello, I want to fetch a message object with it's ID. How do I go about doing it if the message was posted in DMs (dms with the bot).

#
user = await self.client.fetch_channel(msg[1])
message = await user.fetch_message(msg[1])
#

This is what I'm trying rn. doesn't work

spice oyster
#

When I fix the command before sending it, I don't understand why the autocomplete based on selected options doesn't update the choices sometimes. Any ideas?
I did the autocomplete like explained in the example. Everything is working fine besides that. I don't want to add input validation just for that reason.

Not solved but I know the answer now. Sadly it's a problem with Discord.
Link: https://github.com/discord/discord-api-docs/issues/4804

GitHub

Description Sometimes, the choices an application returns for an autocomplete interaction can depend on the values of other options that the user may or may not have filled in. This works fine most...

grizzled sentinel
obtuse juncoBOT
cobalt tangle
#
class Levels(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    def check():
        async def predicate(ctx):
            async with self.bot.db.cursor() as cur:
                await cur.execute("SELECT enabled FROM lvlsettings WHERE guild = ?", (ctx.guild.id,))
                enabled = await cur.fetchone()
                if enabled == "True":
                    return True
                else:
                    return False
        return commands.check(predicate=predicate)
``` how would I pass self to this
grizzled sentinel
#

What do you mean self? The instance of another class?

cobalt tangle
#

for self.bot.db

#

just tell me how do I access self.bot from the check

#

my brain not working :(

grizzled sentinel
#

in the check you can just do exactly that self.bot

cobalt tangle
#

it says self is not defined

#

I need to pass it in somehwere

grizzled sentinel
#

Ahh, Any function inside a class should have self as the first argument. so def check(self):

grizzled sentinel
#

same error?

cobalt tangle
#

check is missing a positional argument

#

I can't pass self in from the decorator

#

that returns the same self is not defined

grizzled sentinel
#

In that case you need to move the check outside the class and than get bot a different way. You could import it from main import bot or something like this.

grizzled sentinel
#

Yup

cobalt tangle
#

I thought that wouldnt work but sure

#

my bot is subclassed, hope it works

grizzled sentinel
#

as long as you get the instance that you created the bot

cobalt tangle
#

@grizzled sentinelit worked but another error

#
@leaderboard.error
async def lberror(self, ctx, error):
        if isinstance(error, commands.CheckFailure):
            await ctx.respond("Levelling is not setup in the server.")
#

discord.errors.CheckFailure: The check functions for the command leaderboard failed

#

Why didn't it work?

grizzled sentinel
#

When a check is not passed it throughs an error.

#

So your check returned false

cobalt tangle
#

yeah

#

but why didnt it catch it

#

I added an error handler

grizzled sentinel
#

discord.errors.CheckFailure vs commands.CheckFailure. The second is for prefix commands

cobalt tangle
#

ohhhhhhh

#

ty

grizzled sentinel
#

yuou might not even need errors just discord.CheckFailure

cobalt tangle
#

this works ty

#

discord.errors.CheckFailure works

#

i aint gonna switch lol

fervent cradle
#

Hello, I want to fetch a message object with it's ID. How do I go about doing it if the message was posted in DMs (dms with the bot).

user = await self.client.fetch_user(msg[1]) # a user id
message = await user.fetch_message(msg[1]) # a msg id

This is what I'm trying rn. doesn't work

coarse spire
#

keep getting this error

  File "main.py", line 7, in <module>
    from discord.ext import commands
ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)```
fervent cradle
#

and not pycord

coarse spire
fervent cradle
fallen cove
cyan quail
fervent cradle
cyan quail
#

so uh

#

have you considered that the ids you're using are the same

fervent cradle
#

wdym?

#

oh wait

cyan quail
#

read your code

fervent cradle
#

would this work fixing the ids?

cyan quail
#

that's meant to work yeah

fervent cradle
#

Still doesn't work after fixing that.

user = await self.client.fetch_channel(msg[0])
message = await user.fetch_message(msg[1])

msg[0] = 1043128589215866900
msg[1] = 837584356988944396

it raises discord.NotFound

#

anyone?

silver moat
#

full traceback thanks

fervent cradle
# silver moat full traceback thanks
The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "A:\Editing-Coding\Coding\Github\bpsapi\discord-bot\venv\lib\site-packages\discord\bot.py", line 1088, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "A:\Editing-Coding\Coding\Github\bpsapi\discord-bot\venv\lib\site-packages\discord\commands\core.py", line 374, in invoke
    await injected(ctx)
  File "A:\Editing-Coding\Coding\Github\bpsapi\discord-bot\venv\lib\site-packages\discord\commands\core.py", line 124, in wrapped
    ret = await coro(arg)
  File "A:\Editing-Coding\Coding\Github\bpsapi\discord-bot\venv\lib\site-packages\discord\commands\core.py", line 1294, in _invoke
    await command.invoke(ctx)
  File "A:\Editing-Coding\Coding\Github\bpsapi\discord-bot\venv\lib\site-packages\discord\commands\core.py", line 374, in invoke
    await injected(ctx)
  File "A:\Editing-Coding\Coding\Github\bpsapi\discord-bot\venv\lib\site-packages\discord\commands\core.py", line 132, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10013): Unknown User

doing client.fetch_user

#

the user-id sent is 837584356988944396, mine

silver moat
#

Full traceback

fervent cradle
#
Ignoring exception in command owners edit_notif:
Traceback (most recent call last):
  File "A:\Editing-Coding\Coding\Github\bpsapi\discord-bot\venv\lib\site-packages\discord\commands\core.py", line 124, in wrapped
    ret = await coro(arg)
  File "A:\Editing-Coding\Coding\Github\bpsapi\discord-bot\venv\lib\site-packages\discord\commands\core.py", line 970, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "A:\Editing-Coding\Coding\Github\bpsapi\discord-bot\cogs\owners.py", line 498, in edit_notif
    raise e
  File "A:\Editing-Coding\Coding\Github\bpsapi\discord-bot\cogs\owners.py", line 483, in edit_notif
    user = await self.client.fetch_user(msg[0])
  File "A:\Editing-Coding\Coding\Github\bpsapi\discord-bot\venv\lib\site-packages\discord\client.py", line 1595, in fetch_user
    data = await self.http.get_user(user_id)
  File "A:\Editing-Coding\Coding\Github\bpsapi\discord-bot\venv\lib\site-packages\discord\http.py", line 355, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10013): Unknown User

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "A:\Editing-Coding\Coding\Github\bpsapi\discord-bot\venv\lib\site-packages\discord\bot.py", line 1088, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "A:\Editing-Coding\Coding\Github\bpsapi\discord-bot\venv\lib\site-packages\discord\commands\core.py", line 374, in invoke
#
    await injected(ctx)
  File "A:\Editing-Coding\Coding\Github\bpsapi\discord-bot\venv\lib\site-packages\discord\commands\core.py", line 124, in wrapped
    ret = await coro(arg)
  File "A:\Editing-Coding\Coding\Github\bpsapi\discord-bot\venv\lib\site-packages\discord\commands\core.py", line 1294, in _invoke
    await command.invoke(ctx)
  File "A:\Editing-Coding\Coding\Github\bpsapi\discord-bot\venv\lib\site-packages\discord\commands\core.py", line 374, in invoke
    await injected(ctx)
  File "A:\Editing-Coding\Coding\Github\bpsapi\discord-bot\venv\lib\site-packages\discord\commands\core.py", line 132, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10013): Unknown User
#

this is when doing fetch_user

cobalt tangle
#

u got the correct id

#

for sure?

#

user = await self.client.fetch_channel(msg[0])

#

user = fetch_channel?

fervent cradle
#

oops, mixed the userid and msgid,

solemn idol
#

I get this error, bot still runs fine but errors are never good unless being handled .-.

cobalt tangle
fervent cradle
#

fetch_channel still says unknown channel

#

do i use fetch_user?

solemn idol
cobalt tangle
fervent cradle
#

application.commands in the discord dev portal

cobalt tangle
#

yep

#

or the bot

solemn idol
#

Oh I just figured it out, token was still old one

cobalt tangle
#

isnt in the server specified in guilds

solemn idol
#

thanks nonetheless xD

fervent cradle
#

also tysm colorX, my issue is now fixed

foggy mortar
#

is there a docs page that says the play music function?

limber urchin
#

playing music is typically against ToS unless you have rights to it

foggy mortar
#

um which ToS?

#

is it about copyright?

limber urchin
#

It's about the ToS of the service you're streaming from

#

e.g YouTube doesn't allow streaming through other services, and breaking a 3rd party ToS inherently breaks Discord ToS as well

foggy mortar
#

oh ok

#

how can you make a voice client?

verbal gulch
#

Hey. may someone help me with this event? It does not work. it should dm the member a embed, but the function is not called. ```py
@bot.event
async def on_member_join(member: discord.Member):
enbed = discord.Embed(
title='Hey! Welcome to EA's staff server.',
description='You just have joined Eternal advertisements' staff server.\nTo access the staff channels and such, please verify! Use /staff_verify here.\nIf you don' verify in 1 day, you'll be kicked from our staff server!',
color=discord.Colour.blue()
)
print(member)
await member.send(embed=enbed)

verbal gulch
#

Mhm

#

every one is activated

young bone
#

at your code and website?

verbal gulch
#

Mhm

foggy mortar
#

is it possible to have prefixed command and slash command at same time?

foggy mortar
#

ok ty

#

ctx.user.mension

foggy mortar
foggy mortar
#

yes lol

young bone
foggy mortar
#

ok ty

tender seal
#

hey guys, how did you reply to a message using ctx.send
I just don't wanna ReadTheDocs

#

wait nvm I figured it out

#

I ReadTheDocs

#

character development

limber urchin
#

Get used to reading documentation, it will benefit you

tender seal
#

not slash

#

it was ctx.reply

limber urchin
#

It's in the docs

foggy mortar
#

how can u find if an interaction has been responded before? i remember it’s something like interaction.is_responded() but i somehow can’t find it in the docs

silver moat
#

user.avatar.url

#

wow

foggy mortar
#

error:TypeError: object of type 'coroutine' has no len() line of error:for i in range(x*10,len(jsont['articles'])):jsont define:async def getnews(self,jsont,start): i = await self.getnews(e,page) ```py
async with session.get(link) as res:
body = res.text()
content = BeautifulSoup(body,'html.parser')
msg = content.text
jsont:dict = json.loads(msg)
return jsont

silver moat
#

await json.loads

foggy mortar
#

oh

#

i wanna know why you need to await it?

silver moat
#

it's a coroutine

foggy mortar
#

but is json.loads a coroutine?

silver moat
foggy mortar
#

i got the full error now

#

Traceback (most recent call last): File "C:\Users\fun\AppData\Roaming\Python\Python311\site-packages\discord\commands\core.py", line 124, in wrapped ret = await coro(arg) ^^^^^^^^^^^^^^^ File "C:\Users\fun\AppData\Roaming\Python\Python311\site-packages\discord\commands\core.py", line 976, in _invoke await self.callback(self.cog, ctx, **kwargs) File "F:\fun\Desktop\coding practice\python practice\bot_pycord\cogs\newscog.py", line 52, in news e = await self.getjson(article) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\fun\Desktop\coding practice\python practice\bot_pycord\cogs\newscog.py", line 20, in getjson content = BeautifulSoup(body,'html.parser') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\fun\AppData\Roaming\Python\Python311\site-packages\bs4\__init__.py", line 313, in __init__ elif len(markup) <= 256 and ( ^^^^^^^^^^^ TypeError: object of type 'coroutine' has no len()

#

so you have to await beautifulsoup?

#

wait no

#

i need to await the previous line cuz i uses aiohttp

#

solved now

full basin
#

Get the channel, send the message

#

yes, this is pycord

limber urchin
#

Once again, look at the docs before asking here

#

And there's no need to be rude to someone trying to help

#

If you're expecting people to just spoonfeed you finished code, you're in the wrong place

full basin
#

lmao, man was expecting being spoonfeeded

limber urchin
#

They explained to you the steps of sending a message to a channel, and you told them to "stfu". If you wanted a reference to the docs you could have asked for it. I don't see how not being able to read your mind is "being a dick".

peak chasm
#

How do I make it so that when the bot is turned on it continues to recognize the interactive messages?

foggy mortar
#

how does the autocomplete function work?

foggy mortar
woeful spindle
#

I’m using the following code:

msg = await ctx.respond("test")
await msg.edit("test finished")

however I’m getting the following error:

'Interaction' object has no attribute 'edit'
foggy mortar
#

cuz ctx.respond is an interaction object

woeful spindle
#

so how can I edit a response?

foggy mortar
#

you need to do edit_original_response

woeful spindle
#

thanks

oblique river
#
class Select(MyModal):
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)
        self.add_item(...)

    async def callback(self, interaction: discord.Interaction):
      ...

    @commands.user_command(name="Modal")
    async def test(self, ctx: discord.ApplicationContext, user: discord.Member):
        modal = Select(title="Review")
        await ctx.send_modal(modal)``` I would like to be able to use `user: discord.member` in my Select class can anyone help me ?
woeful spindle
#

any reason my emojis are going really… weird after I edit my message?

foggy mortar
#

i think its something like ctx.target

foggy mortar
#

its a bug

woeful spindle
#

I see

#

thanks

oblique river
woeful spindle
foggy mortar
#

uhm

#

ask a person that have permission to do that

woeful spindle
#

I’m the owner..

oblique river
#

......

foggy mortar
#

.....

woeful spindle
#

foggy mortar
#

maybe do it in the channel settings

oblique river
#

Spaxter can you help me

woeful spindle
foggy mortar
#

yea but thats a discord bug

woeful spindle
#

ugh

#

alright ty

full basin
oblique river
#

This all makes sense but I just want to be able to use the user: discord.Member from the command in the Select class

full basin
#

no it doesnt make sense

oblique river
#

But it does because I have already seen this together with Spaxter and I asked him

#

I just want to get the user thing working

full basin
#

and why you cant typehint it?..

oblique river
#

well because the user is in the command and not in the class so i want to try it maybe with self.user = user

peak chasm
#

return nothing in on_message()

foggy mortar
#

u have to use ur own python knowledge to make that

#

not that simple

foggy mortar
#

but im not sure is it right to put it in the select class

oblique river
#

How can I do this if I can't retrieve users from the Select class?

#

There is another class in front of it, but I have not inserted it, so you can not see it right now.

foggy mortar
#

um uh idk

hallow blaze
peak chasm
#

what I look for is that they continue working when I turn the bot on and off

foggy mortar
#
    @commands.message_command(name='Cap')
    async def cap(self,ctx:discord.ApplicationContext,message:discord.Message):
        msg = await ctx.user.fetch_message(message.id)
        await msg.reply(f'{message.author.mention} Cap :billed_cap:{message.id}')
``` why does this command dont get registered?
foggy mortar
limber urchin
hallow blaze
foggy mortar
#

but i have 2 bots and i have them mixed up lol

#

so it didnt got registered at all

oblique river
#

Question why interaction.member dont work ...

foggy mortar
#

interaction.user

#

interaction.author

#

not interaction.member

limber urchin
oblique river
foggy mortar
oblique river
#

I have but that there is only interaction.user and interaction.author ...

#

So that gives zero sense

#

How is this supposed to help if there is no member

limber urchin
#

Because an interaction only has a reference to the one who is interacting. You need to pass a member yourself if you're needing one

oblique river
#

I want to pass from my command but it is not in my class

oblique river
limber urchin
#

What's wrong with passing it to the class then?

foggy mortar
#
class Select(MyModal):
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)
        self.add_item(...)

    async def callback(self, interaction: discord.Interaction):
      ...

@commands.user_command(name="Modal")
async def test(self, ctx: discord.ApplicationContext, user: discord.Member):
    modal = Select(title="Review")
    await ctx.send_modal(modal)
oblique river
#

Well because it does not work at all

foggy mortar
#

that almost exact code works

oblique river
#

yes but in my callback it should do something with the member but the problem is when i use interaction.user then something happens with me and not what happens with the member i selected

#

I am aware that the code works but it does not do what it is supposed to do

foggy mortar
#

its the user variable not interaction.user

oblique river
#

I want to use user: discord.member but it can't work because it is not in my class

foggy mortar
#

it still works

oblique river
#

I have also already passed this but it does not work then

foggy mortar
#

?tag tryitandsee

obtuse juncoBOT
oblique river
#

I have already tested the code and it works but it does not do what it should how many times should I write that it wants to kick me in the interaction instead of the member and I can not retrieve it from user: discord.Member

foggy mortar
#

what is the user object in that case?

#

use print(user.id)

oblique river
#

The user: discord.Member should be the member but it is not passed to the class in this case because the command is below the class

foggy mortar
#

then pass it in using the init function

oblique river
#
class Select(Modal):
    def __init__(self, user, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)
        self.user = user```I have already tried with but without success in my command comes directly an error
peak chasm
oblique river
hallow blaze
foggy mortar
peak chasm
hallow blaze
#

👍

peak chasm
#

I can leave this like this right? Won't it cause problems?

oblique river
#

yes

oblique river
foggy mortar
#

you didnt FILL the parameter user

oblique river
#

but it is inside

foggy mortar
#

?tag learnpython

obtuse juncoBOT
#

We're glad to help where we can, but come with at least a basic understanding of Python.

Official Beginner's Guide: https://wiki.python.org/moin/BeginnersGuide
Official Tutorial: https://docs.python.org/3/tutorial/

Shortcuts:
https://wiki.python.org/moin/BeginnersGuide/NonProgrammers
https://wiki.python.org/moin/BeginnersGuide/Programmers

Learn Python:
https://automatetheboringstuff.com/ (for complete beginners to programming)
https://learnxinyminutes.com/docs/python3/ (for people who know programming already)
https://docs.python.org/3/tutorial/ (official tutorial)
http://python.swaroopch.com/ (useful book)
http://www.codeabbey.com/ (exercises for beginners)

oblique river
#

...

hallow blaze
oblique river
#

The is already above and below there can be only error

foggy mortar
oblique river
#
    async def test(self, ctx: discord.ApplicationContext, user: discord.Member):
        modal = Select(title="Test", user)
        await ctx.send_modal(modal)```
foggy mortar
#

...

#

positional arguments follow keyword arguments

oblique river
hallow blaze
foggy mortar
#

hm

#

would it be cuz i use unstable

hallow blaze
# foggy mortar would it be cuz i use unstable

🤔 well I wouldn't be sure, right now I am using the stable version to test it on 2.2.2.
Perhaps that may be the case? I do not normally use the unstable one, but then again I never tried message_commands on unstable

oblique river
#

I don't get it at all FalseFacePalmLaugh

oblique river
hallow blaze
foggy mortar
oblique river
#

I have made a break of one year I must first come back in again DaniGlasses

#

I will ask somewhere else

#

But thanks for the help

hallow blaze
#

well taking a break is always fine, just refresh yourself on things you are hazy with, and relearn the concepts

#

oh, well, yeah have a good one then

peak chasm
#

I just made a View that when you submit a modal it changes the View and if the cancel button is tapped it returns to the main View 😧

#

POO

peak chasm
#

Excuse me, it's a pretty basic question, but how do I make the classes interact with each other, without putting one class inside another?

#

i can send the code if needed

shrewd dome
#

elaborate?

peak chasm
#

Or I already changed it, remove the classes and put them to call the others when certain options are made.

#

Does anyone have an example of channel creation?

undone mulch
#

bro

#
19.11 05:15:47 [Bot] Traceback (most recent call last):
19.11 05:15:47 [Bot] File "/.local/lib/python3.9/site-packages/discord/client.py", line 382, in _run_event
19.11 05:15:47 [Bot] await coro(*args, **kwargs)
19.11 05:15:47 [Bot] File "/cogs/events.py", line 121, in on_message
19.11 05:15:47 [Bot] save_mdb();save_db()
19.11 05:15:47 [Bot] NameError: name 'save_mdb' is not defined```
#

I defined it though! Why am I getting this error?

#
line: 4 from Database.dbfunction_messages import *```
#

dbfunction_messages.py

#loading Game Data (database)

import threading
import json

file_db_four = open("./Database/Game Data/game_database3.json", "r")
file_db2_four = file_db_four.read()
file_db_four.close()
mdb = json.loads(file_db2_four)

def save_gdb():
    file_db_four = open("./Database/Game Data/game_database3.json", "w")
    file_db_four.write(json.dumps(mdb))
    file_db_four.close

def set_interval_four(func, sec):
    def func_wrapper():
        set_interval_four(func, sec)
        func()
    t = threading.Timer(sec, func_wrapper)
    t.start()
    return t```
round rivet
#

I don't see a save_mdb there

copper dew
#

^

undone mulch
fast crater
#

ok, sorry if this is a stupid issue, I can no longer get my code to import discord

#

no matter what i re-install and such

rare ice
fast crater
#

addict==2.4.0
aiohttp==3.7.4.post0
async-timeout==3.0.1
attrs==21.4.0
certifi==2022.6.15
chardet==4.0.0
charset-normalizer==2.1.0
chess==1.9.2
cmake==3.24.1.1
discord==2.1.0
discord.py==2.1.0
idna==3.3
imutils==0.5.4
multidict==6.0.2
numpy==1.23.1
opencv-python==4.6.0.66
pandas==1.4.3
py-cord==2.2.2
pyparsing==3.0.9
python-dateutil==2.8.2
pytz==2022.1
PyYAML==6.0
requests==2.28.1
riotwatcher==3.2.0
scipy==1.8.1
six==1.16.0
typing_extensions==4.1.1
urllib3==1.26.10
yarl==1.7.2

copper dew
fast crater
#

Still returns same error

rare ice
#

Run pip freeze again and send output

fast crater
#

addict==2.4.0
aiohttp==3.7.4.post0
async-timeout==3.0.1
attrs==21.4.0
certifi==2022.6.15
chardet==4.0.0
charset-normalizer==2.1.0
chess==1.9.2
cmake==3.24.1.1
idna==3.3
imutils==0.5.4
multidict==6.0.2
numpy==1.23.1
opencv-python==4.6.0.66pandas==1.4.3
py-cord==2.2.2
pyparsing==3.0.9
python-dateutil==2.8.2
pytz==2022.1
PyYAML==6.0
requests==2.28.1
riotwatcher==3.2.0
scipy==1.8.1
six==1.16.0
typing_extensions==4.1.1
urllib3==1.26.10
yarl==1.7.2

rare ice
#

Send your code

fast crater
#
import discord


#get api keys from external document
text_file= open("API_KEYS.txt","r")
api_keys = text_file.read()
api_keys = api_keys.split(",")
text_file.close()


class MyClient(discord.Client):
    async def on_ready(self):
        print(f'Logged on as {self.user}!')

    async def on_message(self, message):
        print(f'Message from {message.author}: {message.content}')

client = MyClient()
client.run(api_keys[0])
rare ice
#

.tag cb

winter condorBOT
#

Please put your code in a code block:
```py
Here is your Code
```

That makes reading code in Discord a lot easier:

print("This is an example.")
fast crater
#

its just the sample code from the quickstart

rare ice
#

Send the full trace back you are getting.

fast crater
#

File "c:\Users\Adam\Massive inhouse bot\testbot.py", line 1, in <module>
import discord
ModuleNotFoundError: No module named 'discord'PS C:\Users\Adam\Massive inhouse bot>

#

I had a discord bot working up until about a month ago so im slightly confused why its not working now

rare ice
#

Run pip show py-cord and send the output

fast crater
#

Name: py-cord
Version: 2.2.2
Summary: A Python wrapper for the Discord API
Home-page: https://pycord.dev/github
Author: Pycord Development
Author-email:
License: MIT
Location: c:\users\adam\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages
Requires: aiohttp
Required-by:

GitHub

Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - GitHub - Pycord-Development/pycord: Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API

rare ice
#

Hm

#

Try updating your Python to the latest version. If you still get an error then idk what to tell you but there must be something wrong with your IDE.

fast crater
#

time for another clean install 🤡

Thankyou for the help 🙂

foggy mortar
#

whats the difference between fetch_channel and get_channel?

cobalt tangle
#

if you have the specific intents and caching on, you should use get_channel

#

If not, fetch_channel should be used as it makes a call

limber urchin
#

use fetch_channel sparingly as it makes an API call and doing it too often may cause rate limits (and is slower of course). A good thing to do is to try using get_channel, if that returns None, use fetch_channel

cyan lark
#

Hello, im trying to edit name channel and this not work

limber urchin
#

You're trying to call the method directly on the class, not an instance of the class

cyan lark
#

this pycord

limber urchin
#

I'm not talking about the edit method

#

I mean your decorators

cyan lark
#

oh

#

nope this pycord.

#

i have pycord + python

limber urchin
#

So then what is @bot.tree?

cyan lark
cyan lark
#

i dont have on pycord "@bot.slash_command"

limber urchin
#

what?

cyan lark
cyan lark
# cyan lark

anyaway, i trying to do bot change name on channel

#

so i take about "discord.TextChannl"

#

channel*

limber urchin
#

Once again, you're trying to call the method directly on the class which won't work

cyan lark
limber urchin
#

How is the class supposed to know which channel to edit? You already have a reference to the channel in your "indentation" parameter

#

use that

cyan lark
#

wym

#

the just said im missing the "self"

#

@limber urchin

limber urchin
#

Are you new to Python?

cyan lark
#

im use 3.8.9v python

limber urchin
#

That is not what I asked

#

I'm asking if you are new to Python

cyan lark
#

ya why?

limber urchin
#

You should learn more about OOP in Python before developing a bot

#

it is not a beginner project

cyan lark
#

i dont want learn

#

i just ask how i can fix this

limber urchin
#

Then you won't be able to make a bot 🤷‍♂️

cyan lark
#

..

#

dude i just ask how i can fix the and i done

limber urchin
#

And I have told you

cyan lark
#

what

limber urchin
#

You need to call the method on the instance of the channel, which you have a reference to through your parameters in the command

cyan lark
#

this not show on docs

limber urchin
#

It does

cyan lark
#

ya

limber urchin
#

Yeah

cyan lark
limber urchin
#

Yeah

#

I told you, you can access it through the parameters of your command

cyan lark
#

or i cant

foggy mortar
#
Ignoring exception in on_interaction
Traceback (most recent call last):
  File "C:\Users\fun\AppData\Roaming\Python\Python311\site-packages\discord\client.py", line 377, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\fun\AppData\Roaming\Python\Python311\site-packages\discord\bot.py", line 1167, in on_interaction
    await self.process_application_commands(interaction)
  File "C:\Users\fun\AppData\Roaming\Python\Python311\site-packages\discord\bot.py", line 848, in process_application_commands
    await self.invoke_application_command(ctx)
  File "C:\Users\fun\AppData\Roaming\Python\Python311\site-packages\discord\bot.py", line 1114, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\fun\AppData\Roaming\Python\Python311\site-packages\discord\commands\core.py", line 372, in invoke
    await self.prepare(ctx)
  File "C:\Users\fun\AppData\Roaming\Python\Python311\site-packages\discord\commands\core.py", line 292, in prepare
    if not await self.can_run(ctx):
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\fun\AppData\Roaming\Python\Python311\site-packages\discord\commands\core.py", line 400, in can_run
    return await async_all(predicate(ctx) for predicate in predicates)  # type: ignore
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'function' object is not iterable
#

why?

#
    async def checkowner(self,ctx):
        return True
    @bridge.bridge_command(checks=checkowner)
    async def leave(self,ctx):
        await ctx.guild.leave()
cyan lark
#
TypeError: 'function' object is not iterable
foggy mortar
#

yea but what can i do for it

foggy mortar
#

ok

limber urchin
foggy mortar
#

oh

cyan lark
foggy mortar
#

i didnt read the first bit

cyan lark
foggy mortar
#
Ignoring exception in on_interaction
Traceback (most recent call last):
  File "C:\Users\fun\AppData\Roaming\Python\Python311\site-packages\discord\client.py", line 377, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\fun\AppData\Roaming\Python\Python311\site-packages\discord\bot.py", line 1167, in on_interaction
    await self.process_application_commands(interaction)
  File "C:\Users\fun\AppData\Roaming\Python\Python311\site-packages\discord\bot.py", line 848, in process_application_commands
    await self.invoke_application_command(ctx)
  File "C:\Users\fun\AppData\Roaming\Python\Python311\site-packages\discord\bot.py", line 1114, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\fun\AppData\Roaming\Python\Python311\site-packages\discord\commands\core.py", line 372, in invoke
    await self.prepare(ctx)
  File "C:\Users\fun\AppData\Roaming\Python\Python311\site-packages\discord\commands\core.py", line 292, in prepare
    if not await self.can_run(ctx):
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\fun\AppData\Roaming\Python\Python311\site-packages\discord\commands\core.py", line 400, in can_run
    return await async_all(predicate(ctx) for predicate in predicates)  # type: ignore
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\fun\AppData\Roaming\Python\Python311\site-packages\discord\utils.py", line 699, in async_all
    for elem in gen:
  File "C:\Users\fun\AppData\Roaming\Python\Python311\site-packages\discord\commands\core.py", line 400, in <genexpr>
    return await async_all(predicate(ctx) for predicate in predicates)  # type: ignore
                           ^^^^^^^^^^^^^^
TypeError: newscog.checkowner() missing 1 required positional argument: 'ctx'
    async def checkowner(self,ctx:bridge.BridgeContext):
        return False
    @bridge.bridge_command(checks=[checkowner])
    async def leave(self,ctx):
        await ctx.guild.leave()
#

i dont understand List[Callable[[ApplicationContext], bool]] in the docs

#

ohh i got it you need to put it outside the class

cyan lark
foggy mortar
#

how is this possible

limber urchin
#

How is what possible?

foggy mortar
#

command name

#

not english

limber urchin
#

It's just chinese characters? Why wouldn't that be possible?

foggy mortar
#

wait i thought u can only make commands with english characters

limber urchin
foggy mortar
#

oh

limber urchin
#

How are we supposed to know?

#

Then don't spam the API 🤷‍♂️

cyan lark
#

yo @limber urchin

#

im trying to channel move to "category"

#

and i read this docs

#

and this not working

full basin
#

@cyan lark Full code and traceback.

cyan lark
#

for?

#

just take this

#

but i fixed this

limber urchin
#

We can't help you if you don't show your full code

cyan lark
limber urchin
#

You can't pass a channel to a button callback

cyan lark
#

like when i click on button

full basin
#

You don't receive some channel in a button callback.

cyan lark
#

so this channel move to category

limber urchin
#

Pass the channel to your class init and set it as an attribute of your class, then just access that from your button callback

full basin
#

Also, it is discord.Interaction not Integration

limber urchin
#

your init function in your view subclass

cyan lark
#

where

limber urchin
#

Read your code

full basin
#

You'd know what it is if you learned python

cyan lark
#

i said i dont want learn, im good

limber urchin
#

Well then you won't be able to make this feature 🤷‍♂️

#

not our problem

cyan lark
#

ok?

full basin
#

You got help. If you don't understand, your problem.

cyan lark
limber urchin
#

what?

cyan lark
limber urchin
#

?

cyan lark
#

"your init function in your view subclass"

limber urchin
#

Not even close

#

Read rule 1 in #help-rules

#

then go learn OOP in Python, as I told you before

cyan lark
#

oh my god i just go to myself i said i dont want learn

limber urchin
#

Well, good luck then 👋

young bone
#

lul

indigo badger
round rivet
#

Knowing the principles is usually enough to figure it out for most high level languages

limber urchin
#

The issue is that a lot of people choose to make a Discord bot as their first ever project, which means they won't understand any explanations given here and will inevitably just be spoonfed and never learn

woeful spindle
indigo badger
peak chasm
#

Excuse me, how do I get it to be sent without this? when using .send() I get an error.

limber urchin
#

You can't

#

That's how it looks when using a slash command, no getting around that

young bone
peak chasm
peak chasm
oblique river
#

How to get self.bot.guilds in interactions?

young bone
young bone
peak chasm
#

respond() **

oblique river
#

Thanks

peak chasm
vapid pumice
#

Anyone ever have this issue occur? If I exit and reopen VSC, all of these errors go away...but they just come out of nowhere every once in a while, and I have NO clue why.

I haven't even changed anything other than stopping the code :/

limber urchin
#

Those are not errors, and it is not an issue. That's just a VSCode extension giving you tips on how to improve the styling of your code

#

Has nothing to do with pycord

#

And it doesn't prevent you from running your code, if you don't like them, uninstall pylance or don't look at that tab

vapid pumice
young bone
peak chasm
#

Spaxter Do you have any example of creating channels with buttons?

young bone
limber urchin
young bone
#

^

still helm
#

is there a way to use aliases in a bridge_command?

peak chasm
#

I mean give it permissions and that, because in the button class I don't have ctx

silver moat
silver moat
peak chasm
fallow hawk
#

can these have values?

#

like so i can just stick it into a request?

fiery tiger
#

This happens when im trying to run the bot API web.
I suppose some model issues.. OAuth2 tokens are not being saved to db

#
class User(DiscordEntity):
    """Base User model, meant to be reference by extensions"""

    async def fetch(self, bot: InteractionBot) -> DUser | None:
        """Returns the associated user id for the given user Model."""

        return bot.get_user(self.id)


class Welcomer(Guild, Model):
    guild = OneToOneField("Bot.Guild")
    channel_id = BigIntField(null=False)
    enabled = BooleanField(default=False)
    title = TextField(null=True)
    description = TextField(null=True)
    icon = TextField(null=True)
    image = TextField(null=True)
    color = TextField(null=True)
    footer_text = TextField(null=True)
    footer_icon = TextField(null=True)


class OAuth2User(Model):
    """Oauth2 User."""

    id: str
    token: str
    expires_in: int
#
            oauth_response = await OAuth2User.get(id=member.id)
            print(oauth_response.token)
            add_to_guild(oauth_response.token, member.guild.id, member.id)

I also tried printing the oauth token to see if there's something

peak chasm
#
overwrites = {
                interaction.guild.default_role: discord.PermissionOverwrite(view_channel=False),
                interaction.user: discord.PermissionOverwrite(view_channel=True,send_message=True,attach_files=True),
                interaction.guild.me: discord.PermissionOverwrite(view_channel=True,send_message=True,read_message_history=True)
            }
            channel = await interaction.guild.create_text_channel(name=f"ticket-{interaction.user.name}",overwrites=overwrites,reason=f"Ticket for {interaction.user.name}")
            await channel.send("Congratulations!")
            await interaction.response.send_message(f"Create sucessfull! {channel.mention}",ephemeral=True)

Does anyone know why it doesn't work for me?

versed fern
#

How do I disable (or, preferably hide) certain slash commands for users without admin perms?

peak chasm
versed fern
#

I'm pretty sure that's not the case...

#

slash commands do have a permission feature, I just can't find any code examples on how to use it

limber urchin
#

That's for groups, but still the same concept for normal

versed fern
#

ig I know what this means...

#

lemme just try it

peak chasm
versed fern
#

good enough

harsh canyon
#
    
        @Filters.container  
        def write(self, data, user):  
            if user not in self.audio_data:
                file = io.BytesIO()
                self.audio_data.update({user: AudioData(file)})

            file = self.audio_data[user] 
            file.write(data)
            print(data)
            print(type(data),"data")
            print(type(file),"file")``` 
then within a command that joins a voice channel
```vc.start_recording(WaveSink(), once_done, ctx.channel)```
printing data outputs this:
```b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x01\x00\x01\x00\x01\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00``` etc, how would i go about saving this to a file or ideally directly into speechrecognition
versed fern
#

Appearantly doesn't work like this...

limber urchin
#

Like the docs say, you need to give it a Permissions object, not a string

versed fern
#

AttributeError: 'flag_value' object has no attribute 'value'

young bone
versed fern
#

what exactly is the issue with this code?

#

I'd say that I do have basic python knowledge

young bone
#

did you took a look at the Docs?

versed fern
#

I did, they said to add the permissions like discord.Permissions.permission

young bone
#

ReadTheDocs there is anything what you need

versed fern
#

I figured it out now, but:
default_member_permissions are shown at the same place as description, how are users supposed to know to use the decorator and not to add in bracets

limber urchin
versed fern
#

I always used description this way...

limber urchin
#

Yes? That is a parameter in a decorator

versed fern
#

but doing the same with default_member_permissions didn't work, I had to do it this way:

versed fern
#

yes??

#

that's complelty different to the way decription is used

young bone
versed fern
#

I'm reading the docs

#

But I'm more confused cause I do

spare shell
#

so im trying to create a slash command that takes a parameter, then they click a button that sends a modal and on the modal callback it sends them the parameter they put in the slash command but im not sure how to save the parameter thru the modal

versed fern
#

I assume the slash command creates the button?

spare shell
#

ye gonna post example in a secx

versed fern
#

I know...........

#

I assume the slash commands creates the button, cause you made the slash command add a button to a message using your code ? better?

silver moat
indigo badger
#

Is there a way to get the status of a user like the text status or is there no endpoint to that yet?

spare shell
silver moat
#

why would that be in the docs

spare shell
#

sorry im a little slow

#

lol

indigo badger
#

And mine?

silver moat
#

what about yours'?

indigo badger
#

Is there a way?

silver moat
#

for what?

silver moat
indigo badger
#

Or will it only get the playing so and so?

tall oak
#

Hey guys, when I do json.loads() it puts in ' but APIs only accept " as valid JSON. How can I change it?

indigo badger
#

Anyone know?

silver moat
raven island
#

How can you make a slash command be highlighted like in this example?
So when the user taps on it it automatically fills?

silver moat
#

.tag scdmention

winter condorBOT
#

Tag not found.

Did you mean...
slashmention

silver moat
#

.tag slashmention

winter condorBOT
#

</full name:ID>

versed fern
#
message = SlashCommandGroup(name="message", description="Send/edit message commands")

    @message.command(description="Sends a message in the channel specified!")
    @default_permissions(administrator=True)
    async def send(self, ctx,
                   content: Option(str, "Please enter the content of your message!", required=True),
                   channel: Option(discord.TextChannel, "Please enter the channel!", required=False)):
        if channel is None:
            channel = ctx.channel
        await channel.send(content)
        await ctx.respond(f"Successfully send the message in <#{channel.id}>!", ephemeral=True)

I can still use the /send despite not having admin perms

silver moat
#

are you the guild owner?

versed fern
#

I'd assume it's due to the slashCommandGroup and I gotta add the perms on group lvl

#

nope

silver moat
#

yup

versed fern
#

thx

peak chasm
#

How do I get a channel to be created in a category? I saw that it has category= but what would it put? the ID category?

versed fern
#

try and error, but I'd assume the category itself

raven island
# winter condor `</full name:ID>`

i don't need to mention a user just a slash command.

like i would send a user a message and say
"Please use the /login comand"
And they could tap the /login inside the message and it auto populates for them in the text entry

versed fern
#

I did read the docs, I did figure out how to add required permissions to slash commands, but I can't figure it out for SlashCommandGroups

versed fern
full basin
versed fern
#

but there's a way to do it without the id

raven island
#

Ahh i get it. My mind went to user id.

versed fern
#

</command:0>

long torrent
#

How do i defer a paginator respond?

cyan quail
peak chasm
#
channel = utils.get(interaction.guild.text_channels, name=f"ticket-{interaction.user.name}")

I am using this to identify if there is an equal channel but it always returns None, what is my mistake?

solemn idol
#

How do I add a custom "emoji" in a select menu?

#

custom emoji as a png which I've saved on my machine

silver moat
#

upload that png to somewhere as an emoji

#
acoustic birch
#

hi

#

how can I edit the original message from a View class

#

prolly not very descriptive sry

rare ice
acoustic birch
#

oh so they changed it

#

I used to use self.message.edit

#

and it stopped working

rare ice
#

yeah it was changed

acoustic birch
#

oh ok

silver moat
acoustic birch
#

ty tho

silver moat
#

oh wait. bruh

#

the view.message attribute is only assigned in ctx.respond

acoustic birch
#

ohhhh

#
class helpView(View):
    def __init__(self, ctx):
        super().__init__(timeout = 10)
        self.ctx = ctx
    @discord.ui.button(label = "General", style = discord.ButtonStyle.grey, emoji = None)
    async def generalButton(self, button, interaction):
        if interaction.user == self.ctx.author:
            await interaction.response.edit_message(embed = generalHelp(self.ctx), view = None)
        else:
            await interaction.response.send_message("Hey! That button isn't for you!", ephemeral = True)
    @discord.ui.button(label = "Currency", style = discord.ButtonStyle.grey, emoji = None)
    async def currencyButton(self, button, interaction):
        if interaction.user == self.ctx.author:
            await interaction.response.edit_message(embed = currencyHelp(self.ctx), view = None)    
        else:
            await interaction.response.send_message("Hey! That button isn't for you!", ephemeral = True)
    async def on_timeout(self):
        generalButton = self.children[0]
        currencyButton = self.children[1]
        generalButton.disabled = True
        currencyButton.disabled = True
        await interaction.edit_original_response(view = self)```
acoustic birch
acoustic birch
#

oh lol

silver moat
#

or self.ctx.interaction

#

in your case

acoustic birch
#

yeah I figured

#

time to cmd + F and replace all my code

solid gull
#

Why isnt something like this working

@tasks.loop(seconds=30, count=None)
async def myloop():
    channel = client.get_channel("123456789")
    await channel.send("hi")
#

Nonetype object has no attribute send

#

so some eason it seems the variable is null

young bone
solid gull
#

i snipped it out lol

#

there is actually a channel id there

woeful spindle
#

doesn’t change the answer

solid gull
#

isnt it supposed to be the chnnel id

normal pelican
#

It returns none if the channel isn’t found

young bone
solid gull
#

its a tasks loop

#

so its not a command

#

so im not sure what that will fetch

young bone
#

?

solid gull
#

oh i read that wrong

#

nows it says no channel id

young bone
#
channel = client.get_channel(123)
channel = discord.utils.get(guild.channels, id=123)
channel = await client.fetch_channel(123)
#

they are all do the same

solid gull
#

in place of the existing channel =