瀏覽代碼

better logging for slash commands

Markus-Rost 4 年之前
父節點
當前提交
419ef43504
共有 2 個文件被更改,包括 6 次插入1 次删除
  1. 6 0
      bot.js
  2. 0 1
      interactions/verify.js

+ 6 - 0
bot.js

@@ -248,6 +248,12 @@ client.ws.on( 'INTERACTION_CREATE', interaction => {
  * @param {Discord.TextChannel} [channel] - The channel for the interaction.
  * @param {Discord.TextChannel} [channel] - The channel for the interaction.
  */
  */
 function slash_command(interaction, channel) {
 function slash_command(interaction, channel) {
+	if ( interaction.data.name !== 'inline' ) {
+		console.log( ( interaction.guild_id || '@' + interaction.user.id ) + ': Slash: /' + interaction.data.name + ' ' + ( interaction.data.options?.map( option => {
+			return option.name + ':' + option.value;
+		} ).join(' ') || '' ) );
+	}
+	else console.log( ( interaction.guild_id || '@' + interaction.user.id ) + ': Slash: /' + interaction.data.name );
 	if ( !slash.hasOwnProperty(interaction.data.name) ) {
 	if ( !slash.hasOwnProperty(interaction.data.name) ) {
 		console.log( '- Slash: Unknown command: ' + ( isDebug ? JSON.stringify(interaction, null, '\t') : interaction.data.name ) );
 		console.log( '- Slash: Unknown command: ' + ( isDebug ? JSON.stringify(interaction, null, '\t') : interaction.data.name ) );
 		return client.api.interactions(interaction.id, interaction.token).callback.post( {
 		return client.api.interactions(interaction.id, interaction.token).callback.post( {

+ 0 - 1
interactions/verify.js

@@ -26,7 +26,6 @@ function slash_verify(interaction, lang, wiki, channel) {
 			}
 			}
 		}
 		}
 	} ).catch(log_error);
 	} ).catch(log_error);
-	console.log( interaction.guild_id + ': Slash: /' + interaction.data.name + ' ' + interaction.data.options?.[0]?.value );
 	if ( !channel.guild.me.permissions.has('MANAGE_ROLES') ) {
 	if ( !channel.guild.me.permissions.has('MANAGE_ROLES') ) {
 		console.log( channel.guild.id + ': Missing permissions - MANAGE_ROLES' );
 		console.log( channel.guild.id + ': Missing permissions - MANAGE_ROLES' );
 		return interaction.client.api.interactions(interaction.id, interaction.token).callback.post( {
 		return interaction.client.api.interactions(interaction.id, interaction.token).callback.post( {