Add a UI to send
This commit is contained in:
parent
ce1689d404
commit
06268cdb45
@ -1,4 +1,5 @@
|
||||
from discord.ext import commands
|
||||
from discord.ui import Select, View
|
||||
from discord import option
|
||||
import core_utils
|
||||
import discord
|
||||
@ -98,9 +99,33 @@ class ServerUtils(commands.Cog):
|
||||
pass
|
||||
|
||||
@commands.command(name="send")
|
||||
async def send(self, ctx: commands.Context, *, message):
|
||||
async def send(self, ctx, message):
|
||||
if ctx.message.author.id == core_utils.my_id:
|
||||
await self.bot.get_channel(int(152921472304676865)).send(message)
|
||||
return
|
||||
select = Select(
|
||||
placeholder="Select a server to send a message to",
|
||||
options=[
|
||||
discord.SelectOption(
|
||||
label=(server.name),
|
||||
emoji="🔹",
|
||||
description=server.name,
|
||||
)
|
||||
for server in self.bot.guilds
|
||||
],
|
||||
)
|
||||
|
||||
async def my_callback(interaction):
|
||||
for guild in self.bot.guilds:
|
||||
if guild.name == select.values[0]:
|
||||
channel = discord.utils.get(ctx.guild.channels, name="general")
|
||||
channel_id = channel.id
|
||||
|
||||
await self.bot.get_channel(int(channel_id)).send(message)
|
||||
|
||||
select.callback = my_callback
|
||||
view = View()
|
||||
view.add_item(select)
|
||||
await ctx.send("Choose a server", view=view)
|
||||
|
||||
@commands.slash_command(
|
||||
guild_ids=None,
|
||||
|
Loading…
x
Reference in New Issue
Block a user