Overflow channels
This commit is contained in:
parent
56a5080890
commit
fdc12849b3
@ -119,6 +119,25 @@ func (s *Settings) Validate(guildId uint64) error {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
group.Go(func() error {
|
||||||
|
if s.Settings.OverflowCategoryId != nil {
|
||||||
|
ch, ok := cache.Instance.GetChannel(*s.Settings.OverflowCategoryId)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("Invalid overflow category")
|
||||||
|
}
|
||||||
|
|
||||||
|
if ch.GuildId != guildId {
|
||||||
|
return fmt.Errorf("Overflow category guild ID does not match")
|
||||||
|
}
|
||||||
|
|
||||||
|
if ch.Type != channel.ChannelTypeGuildCategory {
|
||||||
|
return fmt.Errorf("Overflow category is not a category")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
return group.Wait()
|
return group.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,8 +16,19 @@
|
|||||||
bind:value={data.welcome_message}/>
|
bind:value={data.welcome_message}/>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<ChannelDropdown label="Archive Channel" col2=true channels={channels} withNull={true} bind:value={data.archive_channel}/>
|
<ChannelDropdown label="Archive Channel" col3=true channels={channels} withNull={true} bind:value={data.archive_channel}/>
|
||||||
<CategoryDropdown label="Channel Category" col2=true channels={channels} bind:value={data.category}/>
|
<CategoryDropdown label="Channel Category" col3=true channels={channels} bind:value={data.category}/>
|
||||||
|
<Dropdown label="Overflow Category" col3=true bind:value={data.overflow_category_id}>
|
||||||
|
<option value=-1>Disabled</option>
|
||||||
|
<option value=-2>Uncategorised (Appears at top of channel list)</option>
|
||||||
|
{#each channels as channel}
|
||||||
|
{#if channel.type === 4}
|
||||||
|
<option value={channel.id}>
|
||||||
|
{channel.name}
|
||||||
|
</option>
|
||||||
|
{/if}
|
||||||
|
{/each}
|
||||||
|
</Dropdown>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<NamingScheme col4=true bind:value={data.naming_scheme}/>
|
<NamingScheme col4=true bind:value={data.naming_scheme}/>
|
||||||
@ -103,7 +114,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
async function updateSettings() {
|
async function updateSettings() {
|
||||||
// Svelte hack
|
// Svelte hack - I can't even remember what this does
|
||||||
let mapped = Object.fromEntries(Object.entries(data).map(([k, v]) => {
|
let mapped = Object.fromEntries(Object.entries(data).map(([k, v]) => {
|
||||||
if (v === "null") {
|
if (v === "null") {
|
||||||
return [k, null];
|
return [k, null];
|
||||||
@ -112,6 +123,18 @@
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// "Normalise" data.overflow_category_id
|
||||||
|
// Svelte doesn't always keep its promise of using integers, so == instead of ===
|
||||||
|
if (mapped.overflow_category_id == -1) {
|
||||||
|
mapped.overflow_enabled = false;
|
||||||
|
mapped.overflow_category_id = null;
|
||||||
|
} else if (mapped.overflow_category_id == -2) {
|
||||||
|
mapped.overflow_enabled = true
|
||||||
|
mapped.overflow_category_id = null;
|
||||||
|
} else {
|
||||||
|
mapped.overflow_enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
const res = await axios.post(`${API_URL}/api/${guildId}/settings`, mapped);
|
const res = await axios.post(`${API_URL}/api/${guildId}/settings`, mapped);
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
if (showValidations(res.data)) {
|
if (showValidations(res.data)) {
|
||||||
@ -184,6 +207,14 @@
|
|||||||
data.category = first.id;
|
data.category = first.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.overflow_enabled === false) {
|
||||||
|
data.overflow_category_id = "-1";
|
||||||
|
} else if (data.overflow_enabled === true) {
|
||||||
|
if (data.overflow_category_id === null) {
|
||||||
|
data.overflow_category_id = "-2";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
withLoadingScreen(async () => {
|
withLoadingScreen(async () => {
|
||||||
|
2
go.mod
2
go.mod
@ -6,7 +6,7 @@ require (
|
|||||||
github.com/BurntSushi/toml v0.3.1
|
github.com/BurntSushi/toml v0.3.1
|
||||||
github.com/TicketsBot/archiverclient v0.0.0-20210220155137-a562b2f1bbbb
|
github.com/TicketsBot/archiverclient v0.0.0-20210220155137-a562b2f1bbbb
|
||||||
github.com/TicketsBot/common v0.0.0-20210910205523-7ce93fba6fa5
|
github.com/TicketsBot/common v0.0.0-20210910205523-7ce93fba6fa5
|
||||||
github.com/TicketsBot/database v0.0.0-20220209175741-201322cf97c9
|
github.com/TicketsBot/database v0.0.0-20220213185554-1b21129e2e3b
|
||||||
github.com/TicketsBot/worker v0.0.0-20211108224403-97ac8e44b789
|
github.com/TicketsBot/worker v0.0.0-20211108224403-97ac8e44b789
|
||||||
github.com/apex/log v1.1.2
|
github.com/apex/log v1.1.2
|
||||||
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff // indirect
|
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff // indirect
|
||||||
|
12
go.sum
12
go.sum
@ -14,12 +14,12 @@ github.com/TicketsBot/common v0.0.0-20210910205523-7ce93fba6fa5/go.mod h1:SVwX6g
|
|||||||
github.com/TicketsBot/database v0.0.0-20200516170158-fd8a949aec2c/go.mod h1:eky4tBL+IZ0svPgTT0N/9i6j7ygHDQH3784DW+HgfcA=
|
github.com/TicketsBot/database v0.0.0-20200516170158-fd8a949aec2c/go.mod h1:eky4tBL+IZ0svPgTT0N/9i6j7ygHDQH3784DW+HgfcA=
|
||||||
github.com/TicketsBot/database v0.0.0-20210902172951-4e1f8ced84b7/go.mod h1:A4T2uQFIWC/ttCYpfgv7AkPjR09mMRgzG13lgoV/+aI=
|
github.com/TicketsBot/database v0.0.0-20210902172951-4e1f8ced84b7/go.mod h1:A4T2uQFIWC/ttCYpfgv7AkPjR09mMRgzG13lgoV/+aI=
|
||||||
github.com/TicketsBot/database v0.0.0-20211108142700-c406ab0fc1bb/go.mod h1:72oWvH/Gq1iKeXCZhVRZn1JFbNVC5iAgERZWTrEarEo=
|
github.com/TicketsBot/database v0.0.0-20211108142700-c406ab0fc1bb/go.mod h1:72oWvH/Gq1iKeXCZhVRZn1JFbNVC5iAgERZWTrEarEo=
|
||||||
github.com/TicketsBot/database v0.0.0-20211202174040-bd189305f898 h1:bbDirB6NmLjJ+9Zbw+Zy3073I7vRGxlKOb+jTRXm3vE=
|
github.com/TicketsBot/database v0.0.0-20220213184807-16b6fe83ee5a h1:SfqC3eSlMmHbRWcOt4e34Foj3FGQVZv2sPCWkFn4hPQ=
|
||||||
github.com/TicketsBot/database v0.0.0-20211202174040-bd189305f898/go.mod h1:72oWvH/Gq1iKeXCZhVRZn1JFbNVC5iAgERZWTrEarEo=
|
github.com/TicketsBot/database v0.0.0-20220213184807-16b6fe83ee5a/go.mod h1:72oWvH/Gq1iKeXCZhVRZn1JFbNVC5iAgERZWTrEarEo=
|
||||||
github.com/TicketsBot/database v0.0.0-20220209175359-fa4c83cc47c5 h1:H1K2LqV+3LXYvD9atS5oOPJMLnBPREYsXSpIhib2HzQ=
|
github.com/TicketsBot/database v0.0.0-20220213185312-dc9f658164ba h1:22NdXBhrtyEWE8Pxe++Qn69WcPGjtsFNfBxpnTAVUzQ=
|
||||||
github.com/TicketsBot/database v0.0.0-20220209175359-fa4c83cc47c5/go.mod h1:72oWvH/Gq1iKeXCZhVRZn1JFbNVC5iAgERZWTrEarEo=
|
github.com/TicketsBot/database v0.0.0-20220213185312-dc9f658164ba/go.mod h1:72oWvH/Gq1iKeXCZhVRZn1JFbNVC5iAgERZWTrEarEo=
|
||||||
github.com/TicketsBot/database v0.0.0-20220209175741-201322cf97c9 h1:n08Opi+1LFUP5O/B8wdScTJE3j4UWZxR2K1zEBorJpI=
|
github.com/TicketsBot/database v0.0.0-20220213185554-1b21129e2e3b h1:yzEFTIygtUGRYqi92auS/mZbVR/Af03R0Jlf45TSN6I=
|
||||||
github.com/TicketsBot/database v0.0.0-20220209175741-201322cf97c9/go.mod h1:72oWvH/Gq1iKeXCZhVRZn1JFbNVC5iAgERZWTrEarEo=
|
github.com/TicketsBot/database v0.0.0-20220213185554-1b21129e2e3b/go.mod h1:72oWvH/Gq1iKeXCZhVRZn1JFbNVC5iAgERZWTrEarEo=
|
||||||
github.com/TicketsBot/logarchiver v0.0.0-20200423221245-a3f92edf8c14/go.mod h1:whts8TRxrAF4WuDuEAMllkWA/inKem0NhDEFeyuoOvE=
|
github.com/TicketsBot/logarchiver v0.0.0-20200423221245-a3f92edf8c14/go.mod h1:whts8TRxrAF4WuDuEAMllkWA/inKem0NhDEFeyuoOvE=
|
||||||
github.com/TicketsBot/ttlcache v1.6.1-0.20200405150101-acc18e37b261 h1:NHD5GB6cjlkpZFjC76Yli2S63/J2nhr8MuE6KlYJpQM=
|
github.com/TicketsBot/ttlcache v1.6.1-0.20200405150101-acc18e37b261 h1:NHD5GB6cjlkpZFjC76Yli2S63/J2nhr8MuE6KlYJpQM=
|
||||||
github.com/TicketsBot/ttlcache v1.6.1-0.20200405150101-acc18e37b261/go.mod h1:2zPxDAN2TAPpxUPjxszjs3QFKreKrQh5al/R3cMXmYk=
|
github.com/TicketsBot/ttlcache v1.6.1-0.20200405150101-acc18e37b261/go.mod h1:2zPxDAN2TAPpxUPjxszjs3QFKreKrQh5al/R3cMXmYk=
|
||||||
|
Loading…
x
Reference in New Issue
Block a user