Skip to content

Commit

Permalink
🐛 Remove guild ID validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Androz2091 committed Feb 17, 2021
1 parent 0d130b9 commit 7ad24b0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
v-else-if="missingScope && $route.name !== 'Settings'"
class="text-center mt-28"
>
You selected a guild (<code>{{ $store.state.selectedGuildID }}</code>) on which your bot can't create Slash Commands. You can authorize it by clicking <a
You selected a guild (<code>{{ $store.state.selectedGuildID }}</code>) on which your bot can't create Slash Commands OR the guild doesn't exist. You can authorize it by clicking <a
:href="`https://discord.com/api/oauth2/authorize?client_id=${$store.state.clientID}&scope=applications.commands&guild_id=${$store.state.selectedGuildID}&disable_guild_select=true`"
class="link"
target="_blank"
Expand Down
17 changes: 0 additions & 17 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,6 @@ export function getToken (clientID, clientSecret, proxyURL) {
});
}

/**
* Check if the bot has access to this guild
* @param {string} clientID
* @param {string} token
* @param {string} proxyURL
* @param {string} guildID
*/
export function checkGuild (clientID, token, proxyURL, guildID) {
return new Promise((resolve, reject) => {
const url = getURL(clientID, guildID);
request(token, proxyURL, url, 'GET').then((value) => {
if (value) resolve();
else reject();
});
});
}

export function fetchCommands (clientID, token, proxyURL, guildID) {
const url = getURL(clientID, guildID);
return request(token, proxyURL, url, 'GET');
Expand Down
1 change: 0 additions & 1 deletion src/util/helpers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export const fakePromise = () => new Promise((resolve) => resolve());
export const cloneObject = (object) => Object.assign({}, object);
export const formatString = (string) => string.charAt(0).toUpperCase() + string.substr(1, string.length).toLowerCase();
23 changes: 8 additions & 15 deletions src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@
</template>

<script>
import { fakePromise } from '../util/helpers';
import { getToken, checkGuild, fetchApplication } from '../api';
import { getToken, fetchApplication } from '../api';
import LoadingAnimation from '../components/LoadingAnimation.vue';
export default {
Expand Down Expand Up @@ -186,21 +185,15 @@ export default {
expiresAt: Date.now() + (tokenData.expires_in * 1000),
value: tokenData.access_token
});
const fetchGuildPromise = this.guildID ? checkGuild(this.$store.state.clientID, this.$store.state.token.value, this.proxyURL, this.guildID) : fakePromise();
fetchGuildPromise.then(() => {
fetchApplication(this.$store.state.clientID).then((application) => {
this.$toast.success(`Successfully logged in as ${application.username}!`, {
duration: 10000,
pauseOnHover: true
});
this.$router.push('/');
fetchApplication(this.$store.state.clientID).then((application) => {
this.$toast.success(`Successfully logged in as ${application.username}!`, {
duration: 10000,
pauseOnHover: true
});
this.loading = false;
this.$root.loadCommands();
}).catch(() => {
this.loading = false;
this.invalidGuildIDs.add(this.guildID);
this.$router.push('/');
});
this.loading = false;
this.$root.loadCommands();
}
}).catch(() => {
this.loading = false;
Expand Down

0 comments on commit 7ad24b0

Please # to comment.