Lukemul69
Lukemul69

Reputation: 187

How to get discord bot to create a channel

I have a script that scrapes info from a webpage. I want my discord bot to create a channel with the product title from the webpage (This product title will be different every time depending on which page I am scraping). Anyway, I would like it to scrape the webpage, read the title of the product, create a channel with said product name and then send the embed in that new channel it created. If you need any more info please just ask I will try to answer best as I can, I am fairly new to coding...

async def start(ctx):

Code that __scrapes__ webpage...

# Discord Embed Setup   
    embed = Embed(
        description=" ",
        color=0x0d0d22,
        timestamp='now'  # sets the timestamp to current time
        )#f'[{name}]({link})'

    embed.set_title(title="**__"+Titles+"__**", url=ProductLink)

    embed.add_field(name="**Release Date**", value=Dates, inline=False)
    embed.add_field(name="**Retail**", value=Prices, inline=False)
    embed.add_field(name="**Colorway**", value=ColorWay, inline=False)
    embed.add_field(name="**PID**", value=PIDs, inline=False)
    embed.add_field(name="**Raffle**", value="**"+f'[{Link}]({RaffleLink})'+"**", inline=False)
    embed.add_field(name="**Resell**", value="**"+f'[{stock}]({StockXSearch})'+"|"+f'[{goat}]({GoatSearch})'+"**", inline=False)

    embed.set_footer(text='Test', icon_url=ICON)

    embed.set_image(image.get_attribute('src'))

    await ctx.send(embed=embed)

    print("Embed sent to discord!")

@client.command()
async def release(ctx):
    await start(ctx)

Upvotes: 0

Views: 318

Answers (2)

THEMEGACODERS
THEMEGACODERS

Reputation: 93

You can do it like the guy above me but if you want to do your own name for the channel you can do:

@bot.command()
async def create(ctx, name):
    channel = await ctx.guild.create_text_channel(name)
    await channel.send('Text in channel')

Upvotes: 0

Abdulaziz
Abdulaziz

Reputation: 3426

You can create it like this and send a message to it.

@bot.command()
async def create(ctx):
    channel = await ctx.guild.create_text_channel('Name here')
    await channel.send('Text in channel')

Upvotes: 1

Related Questions