Add a UI to send

This commit is contained in:
Luke Robles 2022-10-18 22:12:16 -07:00
parent ce1689d404
commit 06268cdb45

View File

@ -1,4 +1,5 @@
from discord.ext import commands from discord.ext import commands
from discord.ui import Select, View
from discord import option from discord import option
import core_utils import core_utils
import discord import discord
@ -98,9 +99,33 @@ class ServerUtils(commands.Cog):
pass pass
@commands.command(name="send") @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: 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( @commands.slash_command(
guild_ids=None, guild_ids=None,