expander

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

discordgo-expander

Discord Message URL extraction, parsing, fetching, and expansion library for discordgo.

discordgo向けのDiscord Message URL抽出・解析・取得・展開ライブラリです。

Preview / プレビュー

discordgo-expander preview

Features / 機能

  • URL extraction / URL抽出
  • URL parsing / URL解析
  • Message fetching / メッセージ取得
  • Message expansion / メッセージ展開

Installation / インストール

go get github.com/o8sumeStudio/discordgo-expander@v0.1.0

Usage / 使い方

Expand
package main

import (
	"fmt"

	"github.com/bwmarrin/discordgo"
	expander "github.com/o8sumeStudio/discordgo-expander"
)

func handler(session *discordgo.Session, message *discordgo.MessageCreate) {
	messageURL := expander.ExtractMessageURL(message.Content)
	if messageURL == "" {
		return
	}

	expandedMessage, err := expander.Expand(session, messageURL)
	if err != nil {
		return
	}

	fmt.Println(expandedMessage.Guild.Name)
	fmt.Println(expandedMessage.Content)
	fmt.Println(expandedMessage.Author.DisplayName())
}

API

High-level API / 高レベルAPI
  • Expand
    • Parses, fetches, and expands a Discord Message URL into an ExpandedMessage.
    • Discord Message URLを解析・取得し、ExpandedMessageとして展開します。
  • ExpandFromParsed
    • Expands an already parsed MessageURL.
    • 解析済みのMessageURLを展開します。
Low-level API / 低レベルAPI
  • ExtractMessageURL
    • Extracts the first Discord Message URL from text.
    • テキストから最初のDiscord Message URLを抽出します。
  • ParseMessageURL
    • Parses a Discord Message URL into MessageURL.
    • Discord Message URLをMessageURLに解析します。
  • FetchMessage
    • Fetches the referenced *discordgo.Message from a Discord Message URL.
    • Discord Message URLから参照先の*discordgo.Messageを取得します。
  • FetchMessageFromParsed
    • Fetches the referenced message from an already parsed MessageURL.
    • 解析済みのMessageURL から参照先メッセージを取得します。

Requirements / 要件

A bot session with access to the target Guild/Channel is required.

対象のGuild/ChannelへアクセスできるBot Sessionが必要です。

Version / バージョン

The API may change before v1.0.0.

v1.0.0まではAPIが変更される可能性があります。

License / ライセンス

MIT License. See LICENSE for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractMessageURL

func ExtractMessageURL(message string) string

ExtractMessageURL はDiscord Message URLのみを抽出して返す https://discord.com/channels/123456789123456789/123456789123456789/123456789123456789

func FetchMessage

func FetchMessage(session *discordgo.Session, url string) (*discordgo.Message, error)

FetchMessage はDiscord Message URLから*discordgo.Messageを取得して返す

func FetchMessageFromParsed

func FetchMessageFromParsed(session *discordgo.Session, parsedURL MessageURL) (*discordgo.Message, error)

FetchMessageFromParsed はParse済みのMessageURLから*discordgo.Messageを取得して返す

Types

type ExpandedMessage

type ExpandedMessage struct {
	Guild       *discordgo.Guild
	GuildID     string
	ChannelID   string
	MessageID   string
	Content     string
	Author      *discordgo.User
	Timestamp   time.Time
	Attachments []*discordgo.MessageAttachment
	Embeds      []*discordgo.MessageEmbed
	JumpURL     string
}

ExpandedMessage はDiscord Message URLの展開結果を保持

func Expand

func Expand(session *discordgo.Session, url string) (*ExpandedMessage, error)

Expand はDiscord Message URLからMessageを展開して返す

func ExpandFromParsed

func ExpandFromParsed(session *discordgo.Session, parsedURL MessageURL) (*ExpandedMessage, error)

ExpandFromParsed はParse済みMessageURLからMessageを展開して返す

type MessageURL

type MessageURL struct {
	URL       string
	GuildID   string
	ChannelID string
	MessageID string
}

MessageURL はDiscord Message URLと各IDを保持

func ParseMessageURL

func ParseMessageURL(url string) (MessageURL, error)

ParseMessageURL はDiscord Message URLを解析し、URL・GuildID・ChannelID・MessageIDを返す

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL