Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utilisation #4

Closed
thomaskeig opened this issue Dec 16, 2020 · 5 comments
Closed

Utilisation #4

thomaskeig opened this issue Dec 16, 2020 · 5 comments

Comments

@thomaskeig
Copy link

Is the code below a new command, how would I add slash commands to and existing @bot.command() command?

​@​slash​.​slash​(​name​=​"test"​)​
​async​ ​def​ ​_test​(​ctx​: ​SlashContext​):
    ​embed​ ​=​ ​discord​.​Embed​(​title​=​"embed test"​)
    ​await​ ​ctx​.​send​(​content​=​"test"​, ​embeds​=​[​embed​])
@thomaskeig
Copy link
Author

Oh, I think I understand. You use it as a seperate command.

@thomaskeig
Copy link
Author

Ok no, I dont understand. The code below is exactly what I've used but when I type in "/" it just shown inbuilt commands. I've also done CTRL+R to restart discord while the bot is still running.

import discord
from discord.ext import commands
from discord_slash import SlashCommand
from discord_slash.model import SlashContext

bot = commands.Bot(command_prefix="!")
slash = SlashCommand(bot)


@slash.slash(name="test")
async def _test(ctx: SlashContext):
    embed = discord.Embed(title="embed test")
    await ctx.send(content="test", embeds=[embed])

@bot.event
async def on_ready():
    print('Bot loaded')

bot.run("TOKEN-HERE")

@thomaskeig
Copy link
Author

I'm pretty sure I have the same issue as this guy #3 I'll do what they did...

@Leastrio
Copy link

You need to either use the libs built in way or send a post request to discords api, https://discord.com/developers/docs/interactions/slash-commands#create-guild-application-command

@thomaskeig
Copy link
Author

Ok thanks

i0bs pushed a commit that referenced this issue Dec 20, 2021
* test #1

* test #2

* test #3

* test #4

* test #5

* test #6

* test #7

* test #8

* test #9

* test #10

* test #11

* test #12

* almost final

* final formatted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants