The weeb for the next gen discord boat - Wamellow wamellow.com
bot discord

update local guild cache on tts updates

shi.gg bef1f9ba e74b3142

verified
+29 -18
+29 -1
app/dashboard/[guildId]/tts.component.tsx
··· 1 1 import { ChannelType } from "discord-api-types/v10"; 2 2 import { useParams } from "next/navigation"; 3 + import { useCallback } from "react"; 3 4 4 - import { guildStore } from "@/common/guilds"; 5 + import { type Guild, guildStore } from "@/common/guilds"; 5 6 import NumberInput from "@/components/inputs/number-input"; 6 7 import SelectMenu from "@/components/inputs/select-menu"; 7 8 import Switch from "@/components/inputs/switch"; ··· 12 13 const guild = guildStore((g) => g); 13 14 const params = useParams(); 14 15 16 + const edit = useCallback( 17 + <K extends keyof Guild["tts"]>(key: K, value: Guild["tts"][K]) => { 18 + guildStore.setState((g) => { 19 + if (!g) return g; 20 + g.tts[key] = value; 21 + return g; 22 + }); 23 + }, 24 + [guild] 25 + ); 26 + 15 27 return ( 16 28 <div className="lg:flex gap-6 mt-5"> 17 29 <div className="lg:w-1/2 flex flex-col gap-2"> ··· 22 34 items={createSelectableItems(guild?.channels, ["ViewChannel", "SendMessages", "EmbedLinks"], [ChannelType.GuildText, ChannelType.GuildVoice])} 23 35 description="Select a channel what channel should be used for tts." 24 36 defaultState={guild?.tts.channelId} 37 + onSave={(o) => edit("channelId", o.value as string)} 25 38 showClear 26 39 /> 27 40 <SelectMenu ··· 31 44 items={createSelectableItems(guild?.channels)} 32 45 description="Select a channel where usage logs should be posted into." 33 46 defaultState={guild?.tts.logChannelId} 47 + onSave={(o) => edit("logChannelId", o.value as string)} 34 48 showClear 35 49 /> 36 50 <SelectMenu ··· 40 54 items={createSelectableItems(guild?.roles)} 41 55 description="People with this role bypass the queue and speak immediately." 42 56 defaultState={guild?.tts.priorityRoleId} 57 + onSave={(o) => edit("priorityRoleId", o.value as string)} 58 + showClear 59 + /> 60 + <SelectMenu 61 + name="Blacklist role" 62 + url={`/guilds/${params.guildId}`} 63 + dataName="tts.blacklistRoleId" 64 + items={createSelectableItems(guild?.roles)} 65 + description="People with this role are not allowed to use tts." 66 + defaultState={guild?.tts.blacklistRoleId} 67 + onSave={(o) => edit("blacklistRoleId", o.value as string)} 43 68 showClear 44 69 /> 45 70 <Switch ··· 49 74 k="tts.announceUser" 50 75 description="If I should say who is currently speaking via tts." 51 76 defaultState={guild?.tts.announceUser || false} 77 + onSave={(value) => edit("announceUser", value)} 52 78 /> 53 79 <Switch 54 80 label="Queue messages" ··· 56 82 k="tts.queue" 57 83 description="Queue sent messages instead of refusing to speak." 58 84 defaultState={guild?.tts.queue || false} 85 + onSave={(value) => edit("queue", value)} 59 86 /> 60 87 <NumberInput 61 88 name="Max message length" ··· 64 91 dataName="tts.maxLength" 65 92 defaultState={guild?.tts.maxLength || 4000} 66 93 max={4000} 94 + onSave={(value) => edit("maxLength", value)} 67 95 /> 68 96 </div> 69 97
-17
components/tts-faq.tsx
··· 33 33 34 34 <Buttons guildId={params.guildId as string} /> 35 35 </AccordionItem> 36 - <AccordionItem 37 - key="2" 38 - aria-label="how to blacklist users" 39 - title="How to blacklist users" 40 - > 41 - Blacklist a user using discord channel permissions. 42 - 43 - <iframe 44 - className="mt-4 aspect-video rounded-lg" 45 - width="100%" 46 - src="https://www.youtube.com/embed/KLXm2vdH0ro?si=FyxofeytRb-LAOE6" 47 - title="Wamellow restrict Text to Speech access" 48 - allow="autoplay; clipboard-write; encrypted-media; picture-in-picture; web-share" 49 - /> 50 - 51 - <Buttons guildId={params.guildId as string} /> 52 - </AccordionItem> 53 36 </Accordion> 54 37 ); 55 38 }