Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preload Discord Roles #422

Open
kousu opened this issue Aug 13, 2023 · 3 comments
Open

Preload Discord Roles #422

kousu opened this issue Aug 13, 2023 · 3 comments

Comments

@kousu
Copy link

kousu commented Aug 13, 2023

Once #395 is merged, expand it by adding a "Load Discord Roles" button to the UI.

Discord will not hand out Discord roles through the API except to guild members, so this will have to trigger a download.

Once that's done, replace the free form text field on the left here

with a <select> that lists the Discord roles by name.

(remember that Discord roles can change name at any time, so internally, continue to use role IDs)

@kousu kousu changed the title Read Available Discord Roles Preload Discord Roles Aug 13, 2023
@pktiuk
Copy link
Contributor

pktiuk commented Jan 7, 2024

That's a pretty good idea.
Checking role ID-s is a bit tedious

@pktiuk
Copy link
Contributor

pktiuk commented May 31, 2024

I wanted to try to implement this feature, but tbh I am way too bad ad PHP to deal with this.

Changing frontend part is really simple.

My Vue code
diff --git a/src/components/settings/GroupMapping.vue b/src/components/settings/GroupMapping.vue
index 9f14d1d..6fae07b 100644
--- a/src/components/settings/GroupMapping.vue
+++ b/src/components/settings/GroupMapping.vue
@@ -3,7 +3,18 @@
     {{ t(appName, 'Add group mapping') }}
   </button>
   <div v-for="(mapping, mappingIdx) in groupMapping" :key="mapping">
+  <!-- Only for discord checklist with names-->
+  <template v-if="appName === 'discord'">
+    <select class="foreign-group" v-model="mapping.foreign">
+      <option v-for="(name, id) in getGroupsForDiscord()" :key="id" :value="id">
+        {{ name }}
+      </option>
+    </select>
+  <!-- else -->
+  </template>
+  <template v-else>
     <input type="text" class="foreign-group" v-model="mapping.foreign" />
+  </template>
     <select class="local-group" :name="mapping.foreign ? inputNamePrefix + '['+mapping.foreign+']' : ''">
       <option v-for="group in groups" :key="group" :value="group" :selected="mapping.local === group">
         {{ group }}
@@ -17,6 +28,12 @@
 export default {
   props: ['groups', 'groupMapping', 'inputNamePrefix']
 }
+
+// Function to get names and IDs of all groups_for_discord as dictionary
+function getGroupsForDiscord() {
+  return {131232:"Role1"};
+}
+
 </script>
 
 <style scoped>

But obtaining a list of roles in a safe and reliable manner requires redownloading list of Roles before opening Settings panel and passing it to the settings view. And this is not doable for me (in a reasonable amount of time).

@zorn-v
Copy link
Owner

zorn-v commented Jun 2, 2024

Backend is tricky part here, yes.
I wanted to see how you resolve it (frontend I can do by myself) 😄
Maybe sometime...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants