Skip to content

Commit cb13684

Browse files
committed
fix: 因重複的頻道名稱導致自動清單無法顯示的問題
1 parent bbd32ff commit cb13684

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

  • Discord Stream Notify Bot/Interaction/Youtube

Discord Stream Notify Bot/Interaction/Youtube/Youtube.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,24 @@ public override async Task<AutocompletionResult> GenerateSuggestionsAsync(IInter
3838
{
3939
if (item.Key.Contains(value, StringComparison.CurrentCultureIgnoreCase) || item.Value.Contains(value, StringComparison.CurrentCultureIgnoreCase))
4040
{
41-
channelIdList2.Add(item.Key, item.Value);
41+
// 後來發現是有一個備用頻道的名稱跟主頻道名稱相同,之後備用頻道才改名稱,導致 Dictionary 出現重複的資料
42+
// 所以如果判定到有相同名稱的話就加上 "_2" 來區分
43+
44+
if (channelIdList2.ContainsKey(item.Key))
45+
channelIdList2.Add(item.Key + "_2", item.Value);
46+
else
47+
channelIdList2.Add(item.Key, item.Value);
4248
}
4349
}
4450
}
4551
else
4652
{
4753
foreach (var item in channelIdList)
4854
{
49-
channelIdList2.Add(item.Key, item.Value);
55+
if (channelIdList2.ContainsKey(item.Key))
56+
channelIdList2.Add(item.Key + "_2", item.Value);
57+
else
58+
channelIdList2.Add(item.Key, item.Value);
5059
}
5160
}
5261
}

0 commit comments

Comments
 (0)